diff --git a/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs b/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs index 4bc70d80c..f846e499e 100644 --- a/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs +++ b/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs @@ -12,6 +12,7 @@ using Elsa.Api.Client.Resources.Resilience.Contracts; using Elsa.Api.Client.Resources.Scripting.Contracts; using Elsa.Api.Client.Resources.StorageDrivers.Contracts; using Elsa.Api.Client.Resources.Tasks.Contracts; +using Elsa.Api.Client.Resources.Tests; using Elsa.Api.Client.Resources.VariableTypes.Contracts; using Elsa.Api.Client.Resources.WorkflowActivationStrategies.Contracts; using Elsa.Api.Client.Resources.WorkflowDefinitions.Contracts; @@ -86,6 +87,7 @@ public static class DependencyInjectionExtensions services.AddApi(builderOptions); services.AddApi(builderOptions); services.AddApi(builderOptions); + services.AddApi(builderOptions); }); } diff --git a/src/clients/Elsa.Api.Client/Resources/Tests/ITestsApi.cs b/src/clients/Elsa.Api.Client/Resources/Tests/ITestsApi.cs new file mode 100644 index 000000000..09748d7e1 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/Tests/ITestsApi.cs @@ -0,0 +1,18 @@ +using Refit; + +namespace Elsa.Api.Client.Resources.Tests; + +/// +/// Represents a client for the testing API. +/// +public interface ITestsApi +{ + /// + /// Sends the specified request to the login API. + /// + /// The request. + /// The cancellation token. + /// The response. + [Post("/tests/activities")] + Task TestActivityAsync([Body] TestActivityRequest request, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/Tests/TestActivityRequest.cs b/src/clients/Elsa.Api.Client/Resources/Tests/TestActivityRequest.cs new file mode 100644 index 000000000..49dfe56d0 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/Tests/TestActivityRequest.cs @@ -0,0 +1,9 @@ +using Elsa.Api.Client.Resources.WorkflowDefinitions.Models; + +namespace Elsa.Api.Client.Resources.Tests; + +public class TestActivityRequest +{ + public WorkflowDefinitionHandle WorkflowDefinitionHandle { get; set; } = null!; + public ActivityHandle ActivityHandle { get; set; } = null!; +} \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/Tests/TestActivityResponse.cs b/src/clients/Elsa.Api.Client/Resources/Tests/TestActivityResponse.cs new file mode 100644 index 000000000..2830e7431 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/Tests/TestActivityResponse.cs @@ -0,0 +1,12 @@ +using Elsa.Api.Client.Resources.WorkflowInstances.Models; +using Elsa.Api.Client.Shared.Models; + +namespace Elsa.Api.Client.Resources.Tests; + +public class TestActivityResponse +{ + public IDictionary? Outputs { get; set; } + public ICollection? Outcomes { get; set; } + public ExceptionState? Exception { get; set; } + public ActivityStatus Status { get; set; } +} \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/ActivityHandle.cs b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/ActivityHandle.cs new file mode 100644 index 000000000..c6ee9fd16 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/ActivityHandle.cs @@ -0,0 +1,16 @@ +namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models; + +/// +/// Represents a handle to an activity. +/// +public class ActivityHandle +{ + public static ActivityHandle FromActivityId(string activityId) => new() { ActivityId = activityId }; + public static ActivityHandle FromActivityNodeId(string activityNodeId) => new() { ActivityNodeId = activityNodeId }; + public static ActivityHandle FromActivityInstanceId(string activityInstanceId) => new() { ActivityInstanceId = activityInstanceId }; + public static ActivityHandle FromActivityHash(string activityHash) => new() { ActivityHash = activityHash }; + public string? ActivityId { get; init; } + public string? ActivityNodeId { get; init;} + public string? ActivityInstanceId { get; init;} + public string? ActivityHash { get; init;} +} \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinitionHandle.cs b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinitionHandle.cs new file mode 100644 index 000000000..1cbc95abc --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinitionHandle.cs @@ -0,0 +1,48 @@ +using Elsa.Api.Client.Shared.Models; + +namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models; + +/// +/// Represents a handle to a workflow definition. +/// +public class WorkflowDefinitionHandle +{ + /// + /// Gets or sets the definition ID. When set, the property is ignored. + /// + public string? DefinitionId { get; set; } + + /// + /// Gets or sets the version options. When set, the property is ignored. + /// + public VersionOptions? VersionOptions { get; set; } + + /// + /// Gets or sets the definition version ID. When set, the and properties are ignored. + /// + public string? DefinitionVersionId { get; set; } + + /// + /// Creates a new instance with the specified definition ID and version options. + /// + public static WorkflowDefinitionHandle ByDefinitionId(string definitionId, VersionOptions? versionOptions = null) => new() { DefinitionId = definitionId, VersionOptions = versionOptions }; + + /// + /// Creates a new instance with the specified definition version ID. + /// + /// + /// + public static WorkflowDefinitionHandle ByDefinitionVersionId(string definitionVersionId) => new() { DefinitionVersionId = definitionVersionId }; + + /// + public override string ToString() + { + if (DefinitionId != null) + return $"DefinitionId: {DefinitionId}, VersionOptions: {VersionOptions}"; + + if (DefinitionVersionId != null) + return $"DefinitionVersionId: {DefinitionVersionId}"; + + return string.Empty; + } +} \ No newline at end of file