using DodoSSH.Client.Domain;
using DodoSSH.Client.Storage;

namespace DodoSSH.Client.Sync;

/// <summary>
/// The buckets in this vault, decrypted, with unpushed local changes laid over them.
/// </summary>
/// <remarks>
/// The eighth facade over the same generic repository, and the pattern has not needed a change since the
/// fourth — which is the point of the item-kind seam. Nothing here is on a transfer's data path: a bucket is
/// read when the file screen's picker is built, and the object-store client is constructed from the result.
/// </remarks>
public sealed class ObjectStoreRepository(
    ItemStore items,
    OutboxStore outbox,
    VaultKeyring keyring,
    IActivityLogSink? activity = null)
{
    private readonly VaultItemRepository<ObjectStoreSecret> stores =
        new(ObjectStoreKind.Instance, items, outbox, keyring, activity);

    /// <inheritdoc cref="VaultItemRepository{TSecret}.ListAsync" />
    public Task<ItemListing<ObjectStoreSecret>> ListAsync(
        Guid vaultId,
        CancellationToken cancellationToken) =>
        stores.ListAsync(vaultId, cancellationToken);

    /// <inheritdoc cref="VaultItemRepository{TSecret}.CreateAsync" />
    public Task<Guid> CreateAsync(
        Guid vaultId,
        ObjectStoreSecret store,
        CancellationToken cancellationToken) =>
        stores.CreateAsync(vaultId, store, cancellationToken);

    /// <inheritdoc cref="VaultItemRepository{TSecret}.UpdateAsync" />
    public Task UpdateAsync(
        Guid vaultId,
        Guid entityId,
        ObjectStoreSecret store,
        CancellationToken cancellationToken) =>
        stores.UpdateAsync(vaultId, entityId, store, cancellationToken);

    /// <inheritdoc cref="VaultItemRepository{TSecret}.DeleteAsync" />
    public Task DeleteAsync(Guid vaultId, Guid entityId, CancellationToken cancellationToken) =>
        stores.DeleteAsync(vaultId, entityId, cancellationToken);
}
