Restructure folders in API client and add WorkflowInstances API client

This commit is contained in:
Sipke Schoorstra 2023-07-07 13:53:44 +02:00
parent 5d1ef7fc68
commit 8bf20732be
75 changed files with 611 additions and 132 deletions

View file

@ -1,5 +1,5 @@
using Elsa.Api.Client.Extensions;
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Activities;

View file

@ -1,5 +1,5 @@
using Elsa.Api.Client.Extensions;
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Activities;

View file

@ -1,6 +1,6 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Converters;

View file

@ -1,6 +1,6 @@
using System.ComponentModel;
using System.Globalization;
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Converters;

View file

@ -18,4 +18,8 @@
<PackageReference Include="Refit.HttpClientFactory" Version="6.3.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Shared\Enums\" />
</ItemGroup>
</Project>

View file

@ -1,5 +1,5 @@
using Elsa.Api.Client.Activities;
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Extensions;

View file

@ -10,6 +10,7 @@ using Elsa.Api.Client.Resources.StorageDrivers.Contracts;
using Elsa.Api.Client.Resources.VariableTypes.Contracts;
using Elsa.Api.Client.Resources.WorkflowActivationStrategies.Contracts;
using Elsa.Api.Client.Resources.WorkflowDefinitions.Contracts;
using Elsa.Api.Client.Resources.WorkflowInstances.Contracts;
using Elsa.Api.Client.Services;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
@ -34,6 +35,7 @@ public static class DependencyInjectionExtensions
services.AddActivityTypeService();
services.AddApi<IWorkflowDefinitionsApi>(CreateRefitSettings);
services.AddApi<IWorkflowInstancesApi>(CreateRefitSettings);
services.AddApi<IActivityDescriptorsApi>(CreateRefitSettings);
services.AddApi<IStorageDriversApi>(CreateRefitSettings);
services.AddApi<IVariableTypesApi>(CreateRefitSettings);

View file

@ -1,4 +1,6 @@
using Elsa.Api.Client.Resources.ActivityDescriptors.Models;
using Elsa.Api.Client.Resources.ActivityDescriptors.Requests;
using Elsa.Api.Client.Resources.ActivityDescriptors.Responses;
using Refit;
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Contracts;

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Models;
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Enums;
/// <summary>
/// Represents the kind of an activity, which affects how it is executed.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Models;
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Enums;
/// <summary>
/// The type of a port.

View file

@ -1,3 +1,5 @@
using Elsa.Api.Client.Resources.ActivityDescriptors.Enums;
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Models;
/// <summary>

View file

@ -1,3 +1,5 @@
using Elsa.Api.Client.Resources.ActivityDescriptors.Enums;
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Models;
/// <summary>

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Models;
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Requests;
/// <summary>
/// Represents a request to list activity descriptors.

View file

@ -1,4 +1,6 @@
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Models;
using Elsa.Api.Client.Resources.ActivityDescriptors.Models;
namespace Elsa.Api.Client.Resources.ActivityDescriptors.Responses;
/// <summary>
/// Represents a response from listing activity descriptors.

View file

@ -1,4 +1,5 @@
using Elsa.Api.Client.Resources.Identity.Models;
using Elsa.Api.Client.Resources.Identity.Requests;
using Elsa.Api.Client.Resources.Identity.Responses;
using Refit;
namespace Elsa.Api.Client.Resources.Identity.Contracts;

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.Identity.Models;
namespace Elsa.Api.Client.Resources.Identity.Requests;
/// <summary>
/// Represents a request to log in.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.Identity.Models;
namespace Elsa.Api.Client.Resources.Identity.Responses;
/// <summary>
/// The response of logging in.

View file

@ -1,4 +1,5 @@
using Elsa.Api.Client.Resources.StorageDrivers.Models;
using Elsa.Api.Client.Resources.StorageDrivers.Responses;
using Refit;
namespace Elsa.Api.Client.Resources.StorageDrivers.Contracts;

View file

@ -1,4 +1,6 @@
namespace Elsa.Api.Client.Resources.StorageDrivers.Models;
using Elsa.Api.Client.Resources.StorageDrivers.Models;
namespace Elsa.Api.Client.Resources.StorageDrivers.Responses;
/// <summary>
/// The response containing the storage drivers.

View file

@ -1,4 +1,5 @@
using Elsa.Api.Client.Resources.VariableTypes.Models;
using Elsa.Api.Client.Resources.VariableTypes.Responses;
using Refit;
namespace Elsa.Api.Client.Resources.VariableTypes.Contracts;

View file

@ -1,4 +1,6 @@
namespace Elsa.Api.Client.Resources.VariableTypes.Models;
using Elsa.Api.Client.Resources.VariableTypes.Models;
namespace Elsa.Api.Client.Resources.VariableTypes.Responses;
/// <summary>
/// A response containing a list of variable types.

View file

@ -1,5 +1,5 @@
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Resources.WorkflowActivationStrategies.Models;
using Elsa.Api.Client.Shared.Models;
using Refit;
namespace Elsa.Api.Client.Resources.WorkflowActivationStrategies.Contracts;

View file

@ -1,6 +1,8 @@
using System.Net.Mime;
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
using Elsa.Api.Client.Resources.WorkflowDefinitions.Requests;
using Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
using Elsa.Api.Client.Shared.Models;
using JetBrains.Annotations;
using Refit;

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Enums;
/// <summary>
/// Defines the order by options for workflow definitions.

View file

@ -1,5 +1,5 @@
using Elsa.Api.Client.Activities;
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;

View file

@ -6,62 +6,28 @@ namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
/// <summary>
/// Represents a serializable workflow definition.
/// </summary>
/// <param name="Id"></param>
/// <param name="DefinitionId"></param>
/// <param name="Name"></param>
/// <param name="Description"></param>
/// <param name="CreatedAt"></param>
/// <param name="Version"></param>
/// <param name="Variables"></param>
/// <param name="Inputs"></param>
/// <param name="Outputs"></param>
/// <param name="Outcomes"></param>
/// <param name="CustomProperties"></param>
/// <param name="IsReadonly"></param>
/// <param name="IsLatest"></param>
/// <param name="IsPublished"></param>
/// <param name="Options">The type of <c>IWorkflowActivationStrategy</c> to apply when new instances are requested to be created.</param>
/// <param name="Root"></param>
[PublicAPI]
public record WorkflowDefinitionModel(
string Id,
string DefinitionId,
string? Name,
string? Description,
DateTimeOffset CreatedAt,
int Version,
Version? ToolVersion,
ICollection<VariableDefinition>? Variables,
ICollection<InputDefinition>? Inputs,
ICollection<OutputDefinition>? Outputs,
ICollection<string>? Outcomes,
IDictionary<string, object>? CustomProperties,
bool IsReadonly,
bool IsLatest,
bool IsPublished,
WorkflowOptions? Options,
Activity? Root
)
public class WorkflowDefinitionModel
{
/// <inheritdoc />
public WorkflowDefinitionModel() : this(
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!,
default!)
{
}
public string Id { get; set; } = default!;
public string DefinitionId { get; set; } = default!;
public string? Name { get; set; }
public string? Description { get; set; }
public DateTimeOffset CreatedAt { get; set; }
public int Version { get; set; }
public Version? ToolVersion { get; set; }
public ICollection<VariableDefinition>? Variables { get; set; }
public ICollection<InputDefinition>? Inputs { get; set; }
public ICollection<OutputDefinition>? Outputs { get; set; }
public ICollection<string>? Outcomes { get; set; }
public IDictionary<string, object>? CustomProperties { get; set; }
public bool IsReadonly { get; set; }
public bool IsLatest { get; set; }
public bool IsPublished { get; set; }
/// <summary>The type of <c>IWorkflowActivationStrategy</c> to apply when new instances are requested to be created.</summary>
public WorkflowOptions? Options { get; set; }
/// <summary></summary>
public Activity? Root { get; set; }
}

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Requests;
/// <summary>
/// A request to delete many workflow definitions.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Requests;
/// <summary>
/// A request to publish many workflow definitions.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Requests;
/// <summary>
/// A request to retract many workflow definitions.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Requests;
/// <summary>
/// Represents a request to get a workflow definition.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Requests;
/// <summary>
/// Request to retract a workflow definition.

View file

@ -1,4 +1,6 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models
using Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Requests
{
/// <summary>
/// Represents a request to save a workflow definition.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
/// <summary>
/// The response from a request to delete workflow definitions.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
/// <summary>
/// The response from a request to publish workflow definitions.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
/// <summary>
/// The response from a request to publish workflow definitions.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
/// <summary>
/// A response containing the number of workflow definitions.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
/// <summary>
/// A response containing a value indicating whether a workflow definition name is unique.

View file

@ -1,7 +1,8 @@
using Elsa.Api.Client.Models;
using Elsa.Api.Client.Resources.WorkflowDefinitions.Enums;
using Elsa.Api.Client.Shared.Models;
using Refit;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
/// <summary>
/// Represents a request to list workflow definitions.
@ -19,10 +20,16 @@ public class ListWorkflowDefinitionsRequest
public int? PageSize { get; set; }
/// <summary>
/// The IDs of the workflow definitions to filter by.
/// The definition IDs of the workflow definitions to filter by.
/// </summary>
[Query(CollectionFormat.Multi)]
public ICollection<string>? DefinitionIds { get; set; }
/// <summary>
/// The IDs of the workflow definitions to filter by.
/// </summary>
[Query(CollectionFormat.Multi)]
public ICollection<string>? Ids { get; set; }
/// <summary>
/// The name of the workflow materializer to filter by.

View file

@ -1,4 +1,6 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
using Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
/// <summary>
/// Represents a response from listing workflow definitions.

View file

@ -1,3 +1,8 @@
using Elsa.Api.Client.Resources.WorkflowInstances.Models;
using Elsa.Api.Client.Resources.WorkflowInstances.Requests;
using Elsa.Api.Client.Shared.Models;
using Refit;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Contracts;
/// <summary>
@ -5,4 +10,25 @@ namespace Elsa.Api.Client.Resources.WorkflowInstances.Contracts;
/// </summary>
public interface IWorkflowInstancesApi
{
/// <summary>
/// Returns a list of workflow instances.
/// </summary>
[Get("/workflow-instances")]
Task<PagedListResponse<WorkflowInstanceSummary>> ListAsync(ListWorkflowInstancesRequest request, CancellationToken cancellationToken = default);
/// <summary>
/// Deletes a workflow instance.
/// </summary>
/// <param name="id">The ID of the workflow instance to delete.</param>
/// <param name="cancellationToken">The cancellation token.</param>
[Delete("/workflow-instances/{id}")]
Task DeleteAsync(string id, CancellationToken cancellationToken = default);
/// <summary>
/// Deletes a list of workflow instances.
/// </summary>
/// <param name="request">The request containing the IDs of the workflow instances to delete.</param>
/// <param name="cancellationToken">The cancellation token.</param>
[Post("/bulk-actions/delete/workflow-instances/by-id")]
Task BulkDeleteAsync(BulkDeleteWorkflowInstancesRequest request, CancellationToken cancellationToken);
}

View file

@ -0,0 +1,27 @@
namespace Elsa.Api.Client.Resources.WorkflowInstances.Enums;
/// <summary>
/// Defines the order by options for workflow instances.
/// </summary>
public enum OrderByWorkflowInstance
{
/// <summary>
/// Order by the date the workflow instance was created.
/// </summary>
Created,
/// <summary>
/// Order by the date the workflow instance was last executed.
/// </summary>
LastExecuted,
/// <summary>
/// Order by the date the workflow instance was finished.
/// </summary>
Finished,
/// <summary>
/// Order by the name of the workflow instance.
/// </summary>
Name
}

View file

@ -0,0 +1,17 @@
namespace Elsa.Api.Client.Resources.WorkflowInstances.Enums;
/// <summary>
/// Represents the current workflow status.
/// </summary>
public enum WorkflowStatus
{
/// <summary>
/// The workflow is running (although it may be waiting for external stimuli).
/// </summary>
Running,
/// <summary>
/// The workflow completed and is no longer running.
/// </summary>
Finished
}

View file

@ -0,0 +1,32 @@
namespace Elsa.Api.Client.Resources.WorkflowInstances.Enums;
/// <summary>
/// Represents the workflow sub-status.
/// </summary>
public enum WorkflowSubStatus
{
/// <summary>
/// The workflow is currently executing.
/// </summary>
Executing,
/// <summary>
/// The workflow is currently suspended and waiting for external stimuli to resume.
/// </summary>
Suspended,
/// <summary>
/// The workflow completed successfully.
/// </summary>
Finished,
/// <summary>
/// The workflow was cancelled.
/// </summary>
Cancelled,
/// <summary>
/// The workflow has faulted.
/// </summary>
Faulted,
}

View file

@ -0,0 +1,37 @@
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
/// <summary>
/// A serializable shape of an <c>ActivityExecutionContext</c>.
/// </summary>
public class ActivityExecutionContextState
{
/// <summary>
/// The ID of the activity instance.
/// </summary>
public string Id { get; set; } = default!;
/// <summary>
/// The ID of the parent of the activity instance.
/// </summary>
public string? ParentContextId { get; set; }
/// <summary>
/// The node ID of the scheduled activity.
/// </summary>
public string ScheduledActivityNodeId { get; set; } = default!;
/// <summary>
/// The node ID of the activity that owns the scheduled activity.
/// </summary>
public string? OwnerActivityNodeId { get; set; }
/// <summary>
/// A bag of properties.
/// </summary>
public IDictionary<string, object> Properties { get; set; } = new Dictionary<string, object>();
/// <summary>
/// The evaluated values of the activity's properties.
/// </summary>
public IDictionary<string, object>? ActivityState { get; set; }
}

View file

@ -0,0 +1,34 @@
using System.Text.Json.Serialization;
using JetBrains.Annotations;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
/// <summary>
/// A bookmark represents a location in a workflow where the workflow can be resumed at a later time.
/// </summary>
/// <param name="Id">The ID of the bookmark.</param>
/// <param name="Name">The name of the bookmark.</param>
/// <param name="Hash">The hash of the bookmark.</param>
/// <param name="Payload">The data associated with the bookmark.</param>
/// <param name="ActivityNodeId">The ID of the activity node associated with the bookmark.</param>
/// <param name="ActivityInstanceId">The ID of the activity instance associated with the bookmark.</param>
/// <param name="AutoBurn">Whether or not the bookmark should be automatically burned.</param>
/// <param name="CallbackMethodName">The name of the method on the activity class to invoke when the bookmark is resumed.</param>
[PublicAPI]
public record Bookmark(
string Id,
string Name,
string Hash,
object? Payload,
string ActivityNodeId,
string ActivityInstanceId,
bool AutoBurn = true,
string? CallbackMethodName = default
)
{
/// <inheritdoc />
[JsonConstructor]
public Bookmark() : this("", "", "", null, "", "")
{
}
}

View file

@ -0,0 +1,12 @@
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
public class CompletionCallbackState
{
public CompletionCallbackState()
{
}
public string OwnerInstanceId { get; init; } = default!;
public string ChildNodeId { get; init; } = default!;
public string? MethodName { get; init; } = default!;
}

View file

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
/// <summary>
/// A simplified, serializable model representing an exception.
/// </summary>
public record ExceptionState(Type Type, string Message, string? StackTrace, ExceptionState? InnerException)
{
/// <summary>
/// Initializes a new instance of the <see cref="ExceptionState"/> class.
/// </summary>
[JsonConstructor]
public ExceptionState() : this(default!, default!, default, default)
{
}
}

View file

@ -0,0 +1,14 @@
using System.Text.Json.Serialization;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
public class PersistentVariableState
{
[JsonConstructor]
public PersistentVariableState()
{
}
public string Name { get; set; } = default!;
public string StorageDriverId { get; set; } = default!;
}

View file

@ -0,0 +1,22 @@
using System.Text.Json.Serialization;
using JetBrains.Annotations;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
/// <summary>
/// Holds information about a workflow fault.
/// </summary>
/// <param name="Exception">The exception that occurred</param>
/// <param name="Message">A description about the fault. Usually the exception message, if there waa an exception.</param>
/// <param name="FaultedActivityId">The ID of the activity that caused the workflow to fault.</param>
[PublicAPI]
public record WorkflowFaultState(ExceptionState? Exception, string Message, string? FaultedActivityId)
{
/// <summary>
/// Initializes a new instance of the <see cref="WorkflowFaultState"/> class.
/// </summary>
[JsonConstructor]
public WorkflowFaultState() : this(default, default!, default)
{
}
}

View file

@ -0,0 +1,75 @@
using Elsa.Api.Client.Resources.WorkflowInstances.Enums;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
/// <summary>
/// Represents a workflow instance.
/// </summary>
public class WorkflowInstance : Entity
{
/// <summary>
/// The ID of the workflow definition.
/// </summary>
public string DefinitionId { get; set; } = default!;
/// <summary>
/// The version ID of the workflow definition.
/// </summary>
public string DefinitionVersionId { get; set; } = default!;
/// <summary>
/// The version of the workflow definition.
/// </summary>
public int Version { get; set; }
/// <summary>
/// The state of the workflow instance.
/// </summary>
public WorkflowState WorkflowState { get; set; } = default!;
/// <summary>
/// The status of the workflow instance.
/// </summary>
public WorkflowStatus Status { get; set; }
/// <summary>
/// The sub-status of the workflow instance.
/// </summary>
public WorkflowSubStatus SubStatus { get; set; }
/// <summary>
/// The ID of the workflow instance.
/// </summary>
public string? CorrelationId { get; set; }
/// <summary>
/// The name of the workflow instance.
/// </summary>
public string? Name { get; set; }
/// <summary>
/// The timestamp when the workflow instance was created.
/// </summary>
public DateTimeOffset CreatedAt { get; set; }
/// <summary>
/// The timestamp when the workflow instance was last executed.
/// </summary>
public DateTimeOffset? LastExecutedAt { get; set; }
/// <summary>
/// The timestamp when the workflow instance was finished.
/// </summary>
public DateTimeOffset? FinishedAt { get; set; }
/// <summary>
/// The timestamp when the workflow instance was cancelled.
/// </summary>
public DateTimeOffset? CancelledAt { get; set; }
/// <summary>
/// The timestamp when the workflow instance was faulted.
/// </summary>
public DateTimeOffset? FaultedAt { get; set; }
}

View file

@ -0,0 +1,50 @@
using Elsa.Api.Client.Resources.WorkflowInstances.Enums;
using JetBrains.Annotations;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
/// <summary>
/// Represents a summary view of a <see cref="WorkflowInstance"/>.
/// </summary>
[PublicAPI]
public record WorkflowInstanceSummary
{
/// <summary>The ID of the workflow instance.</summary>
public string Id { get; set; } = default!;
/// <summary>The ID of the workflow definition.</summary>
public string DefinitionId { get; set; } = default!;
/// <summary>The version ID of the workflow definition.</summary>
public string DefinitionVersionId { get; set; } = default!;
/// <summary>The version of the workflow definition.</summary>
public int Version { get; set; }
/// <summary>The status of the workflow instance.</summary>
public WorkflowStatus Status { get; set; }
/// <summary>The sub-status of the workflow instance.</summary>
public WorkflowSubStatus SubStatus { get; set; }
/// <summary>The ID of the workflow instance.</summary>
public string? CorrelationId { get; set; }
/// <summary>The name of the workflow instance.</summary>
public string? Name { get; set; }
/// <summary>The timestamp when the workflow instance was created.</summary>
public DateTimeOffset CreatedAt { get; set; }
/// <summary>The timestamp when the workflow instance was last executed.</summary>
public DateTimeOffset? LastExecutedAt { get; set; }
/// <summary>The timestamp when the workflow instance was finished.</summary>
public DateTimeOffset? FinishedAt { get; set; }
/// <summary>The timestamp when the workflow instance was cancelled.</summary>
public DateTimeOffset? CancelledAt { get; set; }
/// <summary>The timestamp when the workflow instance was faulted.</summary>
public DateTimeOffset? FaultedAt { get; set; }
}

View file

@ -0,0 +1,75 @@
using Elsa.Api.Client.Resources.WorkflowInstances.Enums;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
/// <summary>
/// Represents the current state of a workflow.
/// </summary>
public class WorkflowState : Entity
{
/// <summary>
/// The workflow definition ID.
/// </summary>
public string DefinitionId { get; set; } = default!;
/// <summary>
/// The workflow definition version.
/// </summary>
public int DefinitionVersion { get; set; }
/// <summary>
/// The correlation ID of the workflow, if any.
/// </summary>
public string? CorrelationId { get; set; }
/// <summary>
/// The status of the workflow.
/// </summary>
public WorkflowStatus Status { get; set; }
/// <summary>
/// The sub status of the workflow.
/// </summary>
public WorkflowSubStatus SubStatus { get; set; }
/// <summary>
/// Collected bookmarks.
/// </summary>
public ICollection<Bookmark> Bookmarks { get; set; } = new List<Bookmark>();
/// <summary>
/// The serialized workflow state, if any.
/// </summary>
public WorkflowFaultState? Fault { get; set; }
/// <summary>
/// A list of callbacks that activities registered in order to be notified when the activities they scheduled complete.
/// </summary>
public ICollection<CompletionCallbackState> CompletionCallbacks { get; set; } = new List<CompletionCallbackState>();
/// <summary>
/// A flattened list of <see cref="ActivityExecutionContextState"/> objects, representing the various active "call stacks" of the workflow.
/// </summary>
public ICollection<ActivityExecutionContextState> ActivityExecutionContexts { get; set; } = new List<ActivityExecutionContextState>();
/// <summary>
/// A dictionary of outputs produced by the workflow.
/// </summary>
public IDictionary<string, object> Output { get; set; } = new Dictionary<string, object>();
/// <summary>
/// A global property bag that contains properties set by application code and/or activities.
/// </summary>
public IDictionary<string, object> Properties { get; set; } = new Dictionary<string, object>();
/// <summary>
/// The created time of the workflow.
/// </summary>
public DateTimeOffset CreatedAt { get; set; }
/// <summary>
/// The last updated time of the workflow.
/// </summary>
public DateTimeOffset UpdatedAt { get; set; }
}

View file

@ -0,0 +1,6 @@
namespace Elsa.Api.Client.Resources.WorkflowInstances.Requests;
public class BulkDeleteWorkflowInstancesRequest
{
public ICollection<string> Ids { get; set; } = default!;
}

View file

@ -0,0 +1,18 @@
using Elsa.Api.Client.Resources.WorkflowInstances.Enums;
using Elsa.Api.Client.Shared.Models;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Requests;
public class ListWorkflowInstancesRequest
{
public int? Page { get; set; }
public int? PageSize { get; set; }
public string? SearchTerm { get; set; }
public string? DefinitionId { get; set; }
public string? CorrelationId { get; set; }
public int? Version { get; set; }
public WorkflowStatus? Status { get; set; }
public WorkflowSubStatus? SubStatus { get; set; }
public OrderByWorkflowInstance? OrderBy { get; set; }
public OrderDirection? OrderDirection { get; set; }
}

View file

@ -0,0 +1,8 @@
using System.Text.Json.Serialization;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Responses;
internal class BulkDeleteWorkflowInstancesResponse
{
[JsonPropertyName("deleted")] public int DeletedCount { get; }
}

View file

@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents designer metadata for an activity.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents an output binding for an activity.

View file

@ -1,7 +1,7 @@
using Elsa.Api.Client.Contracts;
using Elsa.Api.Client.Expressions;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
public class Case
{

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents a connection between two activities.

View file

@ -2,7 +2,7 @@ using Elsa.Api.Client.Activities;
using Elsa.Api.Client.Extensions;
using Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents a container activity.

View file

@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents a connection between two activities.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents an entity.

View file

@ -1,6 +1,6 @@
using Elsa.Api.Client.Activities;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents an expected status code in the FlowSendHttpRequest activity.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents a generic list response that offers a unified format for returning list of things from API endpoints.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents a reference to a memory block.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// The order direction.

View file

@ -0,0 +1,9 @@
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents a generic paged list response that offers a unified format for returning paged list of things from API endpoints.
/// </summary>
/// <param name="Items">A page of items.</param>
/// <param name="TotalCount">The total number of items.</param>
/// <typeparam name="T">The type of the items.</typeparam>
public record PagedListResponse<T>(ICollection<T> Items, long TotalCount);

View file

@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents a position.

View file

@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents a size.

View file

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
using Elsa.Api.Client.Converters;
using JetBrains.Annotations;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents the version to get.

View file

@ -1,4 +1,4 @@
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents an entity that is versioned.

View file

@ -1,6 +1,6 @@
using Elsa.Api.Client.Contracts;
namespace Elsa.Api.Client.Models;
namespace Elsa.Api.Client.Shared.Models;
/// <summary>
/// Represents an input value for an activity.

View file

@ -36,16 +36,16 @@ internal class List : ElsaEndpoint<Request, Response>
private WorkflowDefinitionFilter CreateFilter(Request request)
{
var versionOptions = request.VersionOptions != null ? VersionOptions.FromString(request.VersionOptions) : default(VersionOptions?);
var splitIds = request.DefinitionIds ?? Array.Empty<string>();
var versionOptions = string.IsNullOrWhiteSpace(request.VersionOptions) ? default(VersionOptions?) : VersionOptions.FromString(request.VersionOptions);
if (!string.IsNullOrWhiteSpace(request.SearchTerm)) {
return new WorkflowDefinitionFilter { SearchTerm = request.SearchTerm, VersionOptions = versionOptions };
}
return splitIds.Any()
? new WorkflowDefinitionFilter { DefinitionIds = splitIds, VersionOptions = versionOptions }
: new WorkflowDefinitionFilter { MaterializerName = request.MaterializerName, VersionOptions = versionOptions };
return new WorkflowDefinitionFilter
{
VersionOptions = versionOptions,
SearchTerm = request.SearchTerm?.Trim(),
MaterializerName = request.MaterializerName,
DefinitionIds = request.DefinitionIds,
Ids = request.Ids
};
}
private async Task<Page<WorkflowDefinitionSummary>> FindAsync(Request request, WorkflowDefinitionFilter filter, PageArgs pageArgs, CancellationToken cancellationToken)
@ -58,24 +58,24 @@ internal class List : ElsaEndpoint<Request, Response>
{
default:
{
var order = new WorkflowDefinitionOrder<DateTimeOffset>
{
KeySelector = p => p.CreatedAt,
Direction = direction
};
return await _store.FindSummariesAsync(filter, order, pageArgs, cancellationToken);
}
case OrderByWorkflowDefinition.Name:
var order = new WorkflowDefinitionOrder<DateTimeOffset>
{
var order = new WorkflowDefinitionOrder<string>
{
KeySelector = p => p.Name ?? string.Empty,
Direction = direction
};
KeySelector = p => p.CreatedAt,
Direction = direction
};
return await _store.FindSummariesAsync(filter, order, pageArgs, cancellationToken);
}
return await _store.FindSummariesAsync(filter, order, pageArgs, cancellationToken);
}
case OrderByWorkflowDefinition.Name:
{
var order = new WorkflowDefinitionOrder<string>
{
KeySelector = p => p.Name ?? string.Empty,
Direction = direction
};
return await _store.FindSummariesAsync(filter, order, pageArgs, cancellationToken);
}
case OrderByWorkflowDefinition.Version:
{
var order = new WorkflowDefinitionOrder<int>

View file

@ -9,6 +9,7 @@ internal class Request
{
public string? VersionOptions { get; set; }
public string[]? DefinitionIds { get; set; }
public string[]? Ids { get; set; }
[BindFrom("materializer")] public string? MaterializerName { get; set; }
[BindFrom("label")] public string[]? Labels { get; set; }
public int? Page { get; set; }

View file

@ -45,6 +45,4 @@ public class ActivityExecutionContextState
/// The evaluated values of the activity's properties.
/// </summary>
public IDictionary<string, object>? ActivityState { get; set; }
//public RegisterState Register { get; set; } = default!;
}