using DeepDrftModels.Enums;
using Models.Entities;

namespace DeepDrftModels.Entities;

// The release-cardinal half of the normalized track schema (Phase 8 §8.0). One ReleaseEntity is
// shared by every track on the same album; track-cardinal data stays on TrackEntity, which points
// back here via a nullable ReleaseId (singles and loose tracks have no release context).
//
// Inherits Id, CreatedAt, UpdatedAt, IsDeleted from BaseEntity (Cerebellum.BlazorBlocks.Models).
// BaseEntity ships the audit columns but does not declare IEntity itself, so subclasses declare it
// explicitly to satisfy the generic constraints on Repository<>/Manager<>/etc.
public class ReleaseEntity : BaseEntity, IEntity
{
    // App-minted GUID-string public handle, mirroring TrackEntity.EntryKey exactly: required string,
    // entry_key column, unique index, born app-side as Guid.NewGuid().ToString() at release creation
    // (the FindOrCreateRelease path). Fronts the int Id (the DB-only PK, unused by the app) so the
    // public site/API address releases by an opaque key, never the transparent sequential id
    // (Phase 11 §3e). Unlike a track's EntryKey it has no vault job — it is purely an identifier.
    public required string EntryKey { get; set; }
    public required string Title { get; set; }
    public required string Artist { get; set; }
    public string? Genre { get; set; }
    // Free-text prose blurb describing the release. Uniform across media (Cut/Session/Mix), so it
    // lives on the base table alongside Genre rather than in a per-medium satellite. Plain text,
    // max 4000 (configured in ReleaseConfiguration); nullable so existing rows migrate as NULL.
    public string? Description { get; set; }
    public DateOnly? ReleaseDate { get; set; }
    public string? ImagePath { get; set; }
    public ReleaseType ReleaseType { get; set; } = ReleaseType.Single;
    public ReleaseMedium Medium { get; set; } = ReleaseMedium.Cut;
    public long? CreatedByUserId { get; set; }
    public ICollection<TrackEntity> Tracks { get; set; } = new List<TrackEntity>();

    // 1:1 satellites selected by Medium. Null unless this release is the matching medium —
    // Session releases carry SessionMetadata, Mix releases carry MixMetadata, Cut releases carry
    // neither (ReleaseType on this table is their discriminator data).
    public SessionMetadata? SessionMetadata { get; set; }
    public MixMetadata? MixMetadata { get; set; }
}
