namespace Chronos.Protocol;
/// Sequence summary for lists (BRIEF §12.2 card data).
/// Frames that decode only through their embedded preview (BRIEF §8.2 tier 2).
public sealed record SequenceDto(
Guid Id,
string? Title,
string DisplayTitle,
string Folder,
string? CameraMake,
string? CameraModel,
string? Lens,
DateTime? FirstCapture,
DateTime? LastCapture,
int FrameCount,
double? MedianInterval,
long TotalBytes,
long Status,
int RenderedCount,
Guid? HeroFrameId,
IReadOnlyList Tags,
int Rating,
string? Notes,
int SettingsVersion,
int FramesVersion,
int WarningCount,
Guid? OwnerUserId,
DateTimeOffset UpdatedAt,
int PreviewOnlyCount = 0);
/// A page of results with an opaque keyset cursor; null cursor = last page.
public sealed record Page(IReadOnlyList Items, string? NextCursor, long? Total);
/// POST /api/v1/sequences.
public sealed record CreateSequenceRequest(string? Title, string? CameraHint);
///
/// PATCH /api/v1/sequences/{id}. enables conflict detection (409).
/// names the frame the sequence shows (one of its own; clears it).
/// is the frames version the settings' frame positions were written against: the
/// edit is refused (409 frames_conflict) when frames were added or removed since.
///
public sealed record UpdateSequenceRequest(
string? Title,
IReadOnlyList? Tags,
int? Rating,
string? Notes,
string? SettingsJson,
int? ExpectedSettingsVersion,
Guid? HeroFrameId = null,
int? ExpectedFramesVersion = null);
/// Width of the largest embedded preview before orientation, like ; 0 when unknown.
/// Height of that preview before orientation; 0 when unknown.
public sealed record FrameDto(
Guid Id,
Guid SequenceId,
int Index,
string FileName,
long Size,
string? Sha256,
DateTime? CapturedAt,
int? UtcOffsetMinutes,
double? ExposureTime,
double? FNumber,
int? Iso,
double? FocalLength,
int Orientation,
int Width,
int Height,
string Format,
long Flags,
int PreviewWidth = 0,
int PreviewHeight = 0);
/// GET /api/v1/sequences/{id}/manifest: what a client needs to diff a sequence (BRIEF §14.5).
/// How to make the proxies the server asks for (); null when it makes none.
///
/// Tombstones of the photos removed from the sequence (owner review 2, R6): a client never offers them back, and counts a
/// replaced photo and its replacement as one; null from servers before owner review 2 and when there are none.
///
public sealed record SequenceManifest(
Guid SequenceId,
int FramesVersion,
int SettingsVersion,
string? SettingsJson,
IReadOnlyList Tags,
IReadOnlyList Frames,
IReadOnlyList Renders,
ProxySpec? Proxies = null,
IReadOnlyList? Removed = null);
///
/// A photo removed from a sequence (owner review 2, R6): its lower-case hex SHA-256, the replacement's when a conversion
/// replaced it, why (deleted, replaced) and when.
///
public sealed record RemovedPhotoDto(string Sha256, string? Replacement, string Reason, DateTimeOffset At);
/// One frame of a manifest: its content, whether the server has a proxy and thumbnail of it, and its flags.
/// Lower-case hex SHA-256; empty while the server has not hashed it (a folder adopted and not verified yet).
/// The frame's FrameFlags bits (missing, corrupt, excluded…).
///
/// The server cannot decode this original and has no proxy of it (BRIEF §2.3, §8.1: HEIF): a client or render node that
/// decodes it sends one with PUT /api/v1/frames/{id}/proxy, made as says.
///
public sealed record ManifestFrame(Guid Id, int Index, string FileName, long Size, string Sha256, bool HasProxy, bool HasThumb, long Flags = 0,
bool WantsProxy = false);
/// How the server's proxies are made (BRIEF §8.5): long edge in pixels (0 = full size) and JPEG quality.
public sealed record ProxySpec(int LongEdge, int Quality);
public sealed record RenderDto(
Guid Id,
string PresetName,
string? Codec,
int Width,
int Height,
double Fps,
double DurationSeconds,
long Bytes,
DateTimeOffset Created,
string? ProducedBy);
/// Aggregates for the archive dashboard and the admin panel.
/// Free bytes of the space volume: the server's space path when one is set, else the archive's volume.
/// Size of the space volume.
///
/// Free bytes of the archive's own volume, where uploads are written, when a space path is in use and its figures
/// differ (an Unraid share's primary storage, often the cache); null otherwise and from servers before owner review 2.
///
/// Size of that write volume, with .
/// Filesystem type of the space volume (ext4, NTFS, fuse.shfs for an Unraid share); null when unknown.
/// The space volume is the server's space path, not the archive's volume.
public sealed record ArchiveStatsDto(
long Sequences,
long Photos,
long Bytes,
long FreeBytes,
long CapacityBytes,
int Cameras,
int? FirstYear,
int? LastYear,
IReadOnlyList ByYear,
IReadOnlyList ByMonth,
IReadOnlyList ByCamera,
IReadOnlyList ByFormat,
int SequencesWithoutProxies,
int UnverifiedSequences,
long? WriteFreeBytes = null,
long? WriteCapacityBytes = null,
string? FileSystem = null,
bool UsesSpacePath = false);
public sealed record KeyValueCount(string Key, long Count, long Bytes);
/// GET /api/v1/sequences/{id}/stats: frame totals by format and flagged frames.
public sealed record SequenceStatsDto(
Guid SequenceId,
int FrameCount,
long TotalBytes,
DateTime? FirstCapture,
DateTime? LastCapture,
double? MedianInterval,
IReadOnlyList ByFormat,
long MissingFrames,
long CorruptFrames,
long DuplicateFrames,
long ExcludedFrames);
///
/// DELETE /api/v1/sequences/{id}: what the delete does (with ?dryRun=true) or did. The folder is moved
/// to inside the archive, never erased.
///
public sealed record SequenceDeletePlan(Guid SequenceId, string? Folder, string? TrashFolder, int FrameCount, long TotalBytes, int RenderCount, bool DryRun);
/// GET/PUT /api/v1/archive/settings (admin). The root path comes from the server configuration.
public sealed record ArchiveSettingsDto(Guid Id, string Name, string RootPath, string FolderTemplate, string FileTemplate, int ProxyLongEdge);