using System.Collections.Generic;
using Svrnty.CQRS.Events.Abstractions.Models;
using System.Threading;
using System.Threading.Tasks;
namespace Svrnty.CQRS.Events.Abstractions.Schema;
///
/// Persistent storage for event schemas.
///
///
///
/// The schema store persists schema information to a database, enabling:
/// - Schema versioning across application restarts
/// - Centralized schema management in distributed systems
/// - Schema auditing and history tracking
///
///
/// Implementations:
/// - PostgresSchemaStore (stores schemas in PostgreSQL)
/// - InMemorySchemaStore (for testing)
///
///
public interface ISchemaStore
{
///
/// Stores a schema in the persistent store.
///
/// The schema information to store.
/// Cancellation token.
/// Task representing the async operation.
///
/// If a schema with the same EventType and Version already exists,
/// this method should throw an exception (schemas are immutable once registered).
///
Task StoreSchemaAsync(
SchemaInfo schema,
CancellationToken cancellationToken = default);
///
/// Retrieves a schema by event type and version.
///
/// The event type name.
/// The version number.
/// Cancellation token.
/// Schema information if found; otherwise null.
Task GetSchemaAsync(
string eventType,
int version,
CancellationToken cancellationToken = default);
///
/// Gets all schemas for an event type, ordered by version ascending.
///
/// The event type name.
/// Cancellation token.
/// List of schema information for all versions.
Task> GetSchemaHistoryAsync(
string eventType,
CancellationToken cancellationToken = default);
///
/// Gets the latest version number for an event type.
///
/// The event type name.
/// Cancellation token.
/// The latest version number, or null if no versions exist.
Task GetLatestVersionAsync(
string eventType,
CancellationToken cancellationToken = default);
///
/// Gets all registered event types.
///
/// Cancellation token.
/// List of unique event type names.
Task> GetAllEventTypesAsync(
CancellationToken cancellationToken = default);
///
/// Checks if a schema exists for the given event type and version.
///
/// The event type name.
/// The version number.
/// Cancellation token.
/// True if the schema exists; otherwise false.
Task SchemaExistsAsync(
string eventType,
int version,
CancellationToken cancellationToken = default);
}