using DeepDrftModels.DTOs;
using Models.Common;
using NetBlocks.Models;
namespace DeepDrftData;
///
/// SQL-side track service. Repository outputs entities; this service outputs DTOs via
/// TrackConverter. In-process consumers (UnifiedTrackService, CLI, DeepDrftPublic) all
/// receive DTOs.
///
public interface ITrackService
{
Task> GetById(long id);
Task> GetByEntryKey(string entryKey);
///
/// Returns a single track chosen uniformly at random, or null when the library is empty
/// (a valid state, not a failure). Backs the public "Stream Now" instant-play feature.
///
Task> GetRandom(CancellationToken cancellationToken = default);
Task>> GetAll();
Task>> GetPaged(int pageNumber, int pageSize, string? sortColumn, bool sortDescending, TrackFilter? filter = null, CancellationToken cancellationToken = default);
/// All releases, title-ascending, each carrying its non-deleted track count.
Task>> GetReleases(CancellationToken cancellationToken = default);
/// Distinct non-null genres with track counts, genre-ascending.
Task>> GetDistinctGenres(CancellationToken cancellationToken = default);
///
/// Resolve the release matching + , creating
/// one from when none exists. Backs the upload flow's FK
/// resolution so a track lands on a shared release rather than duplicating release-cardinal data.
///
Task> FindOrCreateRelease(
string title, string artist, ReleaseDto releaseData, CancellationToken cancellationToken = default);
///
/// Read-only peek for an existing release by its natural key, or null when none exists — a find
/// with no create side-effect. Backs the upload cardinality pre-check, which must read a release's
/// medium and live-track count before deciding whether to admit an upload, without creating a
/// release for an upload it may reject. The returned DTO carries TrackCount.
///
Task> GetReleaseByTitleAndArtist(
string title, string artist, CancellationToken cancellationToken = default);
Task> Create(TrackDto newTrack);
Task> Update(TrackDto track);
Task Delete(long id);
/// Soft-delete a release row by id. Idempotent — a missing or already-deleted row is a no-op.
Task DeleteRelease(long id, CancellationToken cancellationToken = default);
///
/// Count of non-deleted tracks on a release. Backs the delete-cascade decision: when a track
/// delete leaves a release with zero live tracks, the release is soft-deleted too.
///
Task> CountLiveTracksByRelease(long releaseId, CancellationToken cancellationToken = default);
}