using System;
using System.Collections.Generic;
namespace Svrnty.CQRS.Sagas.Abstractions;
///
/// Represents the persistent state of a saga instance.
///
public class SagaState
{
///
/// Unique identifier for this saga instance.
///
public Guid SagaId { get; set; } = Guid.NewGuid();
///
/// The fully qualified type name of the saga.
///
public string SagaType { get; set; } = string.Empty;
///
/// Correlation ID for tracing across services.
///
public Guid CorrelationId { get; set; }
///
/// Current execution status.
///
public SagaStatus Status { get; set; } = SagaStatus.NotStarted;
///
/// Index of the current step being executed.
///
public int CurrentStepIndex { get; set; }
///
/// Name of the current step being executed.
///
public string? CurrentStepName { get; set; }
///
/// Results from completed steps, keyed by step name.
///
public Dictionary StepResults { get; set; } = new();
///
/// Names of steps that have been completed.
///
public List CompletedSteps { get; set; } = new();
///
/// Errors that occurred during saga execution.
///
public List Errors { get; set; } = new();
///
/// Serialized saga data (JSON).
///
public string? SerializedData { get; set; }
///
/// When the saga was created.
///
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
///
/// When the saga was last updated.
///
public DateTimeOffset? UpdatedAt { get; set; }
///
/// When the saga completed (successfully or compensated).
///
public DateTimeOffset? CompletedAt { get; set; }
}
///
/// Represents an error that occurred during saga step execution.
///
public record SagaStepError(
string StepName,
string ErrorMessage,
string? StackTrace,
DateTimeOffset OccurredAt
);