namespace Chronos.Protocol;
///
/// POST /api/v1/sequences/{id}/frames/delete (owner review 2, R6): the photos to move into the archive's trash.
/// is the frames version the ids were read at: a sequence whose frames changed since
/// answers 409 frames_conflict. only reports what would happen.
///
public sealed record FrameDeleteRequest(IReadOnlyList FrameIds, int? ExpectedFramesVersion, bool DryRun);
///
/// What a photo deletion does (dry run) or did: the photos and bytes that go, the sequence's frames version (as it is on a
/// dry run, after the deletion otherwise) and the trash entry made (null on a dry run).
///
public sealed record FrameDeleteResultDto(Guid SequenceId, int Photos, long Bytes, int FramesVersion, int FrameCount, string? TrashEntry, bool DryRun);
///
/// An entry of the archive's trash (GET /api/v1/archive/trash): a deleted sequence ( sequence)
/// or photos deleted from one (photos; replaced for originals a conversion replaced).
/// identifies it in restore and empty requests. In the dry run of an emptying, marks
/// replaced originals whose conversion was deleted since, which may be the last copy of their photos.
///
public sealed record TrashEntryDto(string Name, string Kind, Guid SequenceId, string Title, string Folder, int Photos, int Files, long Bytes,
string? DeletedBy, DateTimeOffset DeletedAt, bool ConversionDeleted = false);
/// GET /api/v1/archive/trash: the entries, newest first, and their total size.
public sealed record TrashListDto(IReadOnlyList Entries, long Bytes);
///
/// POST /api/v1/archive/trash/{name}/restore: the sequence the entry went back into (a new one when the photos'
/// sequence is gone: ), how many photos came back, and the photos kept in the trash: their names
/// (), why each stayed (, in the same order: mismatch, its files no
/// longer match their record; not_moved, they could not be moved back; in_sequence, the sequence holds it
/// already; no_file, its original was missing when it was deleted) and one sentence per reason in the request's
/// language (; null when none stayed).
///
public sealed record TrashRestoreDto(string Name, string Kind, Guid SequenceId, int Photos, IReadOnlyList Kept, bool NewSequence,
IReadOnlyList? KeptReasons = null, string? Message = null);
///
/// POST /api/v1/archive/trash/empty: erase the entries (null: every entry). A dry run answers the
/// plan with its ; the erase itself must send that fingerprint back (409
/// trash_changed when the trash changed since) and runs as an empty-trash job (202).
///
public sealed record TrashEmptyRequest(IReadOnlyList? Names, bool DryRun, string? Fingerprint);
/// The dry run of emptying the trash: the entries measured on disk, their totals, the fingerprint, and names not in the trash.
public sealed record TrashEmptyPlanDto(IReadOnlyList Entries, int Photos, int Files, long Bytes, string Fingerprint, IReadOnlyList Unknown);
/// POST /api/v1/sequences/bulk/delete: move these sequences into the trash (or, with , say what would).
public sealed record BulkDeleteRequest(IReadOnlyList Ids, bool DryRun);
/// POST /api/v1/sequences/bulk/retag: add and remove tags on these sequences (the same edit as a PATCH of their tags).
public sealed record BulkRetagRequest(IReadOnlyList Ids, IReadOnlyList? Add, IReadOnlyList? Remove);
///
/// POST /api/v1/sequences/bulk/jobs: queue one job of (analyse, deep, proxies,
/// thumbnails, verify) over these sequences.
///
public sealed record BulkJobsRequest(IReadOnlyList Ids, string Kind);
///
/// One sequence of a bulk operation: ok, or skipped with the error code that says why
/// (, e.g. not_found, forbidden, sequence_busy) and its localised sentence.
///
/// For a delete: where the folder goes (or went) in the trash; null when it has no folder.
public sealed record BulkItemResult(Guid Id, string Outcome, string? Reason = null, string? Message = null, string? TrashFolder = null);
///
/// The result of a bulk operation: one item per id asked for, the counts, the photos and bytes a delete moves (or moved),
/// and the job a bulk job request queued (null when nothing was queued).
///
public sealed record BulkResultDto(IReadOnlyList Items, int Ok, int Skipped, bool DryRun, int Photos = 0, long Bytes = 0, JobDto? Job = null);
///
/// A value a Library filter offers: as GET /api/v1/sequences takes it (year, camera,
/// tag), the sequences that have it, and the label a menu shows when it differs (a camera model with its make).
///
public sealed record FacetDto(string Value, int Sequences, string? Label = null);
///
/// GET /api/v1/sequences/facets (owner review 2, R6): the years of first capture (newest first), camera models (most
/// sequences first) and tags in use (by name) of the archive's sequences, for the admin panel's Library filters.
///
public sealed record LibraryFacetsDto(IReadOnlyList Years, IReadOnlyList Cameras, IReadOnlyList Tags);
///
/// POST /api/v1/archive/reorganize (owner review 2, R7; administrators of the archive): new folder, file and title
/// templates applied to sequences already in the archive, or every one with
/// (exactly one of the two). A null template keeps that part; at least one is given, each valid as the archive settings'
/// templates are. answers the plan () and changes nothing; the server
/// keeps it a few minutes, a refusal too, so the same dry run again (also after one cut off) is answered from it; 503
/// plan_dropped when the server stopped making it (it took too long, or too many were asked at once). The change
/// itself sends that plan's back and runs as a move job (202): 409 plan_changed
/// when the index changed since in what the plan reads (the sequences' rows, and which of their photos are hashed, as a
/// verify does); a change made on disk alone, which the index does not have yet, is found by the job, which then fails and
/// changes nothing.
///
public sealed record ReorganizeRequest(IReadOnlyList? SequenceIds, bool All, string? FolderTemplate, string? FileTemplate, string? TitleTemplate,
bool DryRun, string? Fingerprint = null);
/// A file a Reorganize renames: its name before and after, relative to the sequence folder (originals/…).
public sealed record ReorganizeFileDto(string From, string To);
///
/// Why part of a sequence stays as it is in a Reorganize, as one localised sentence: photos that keep their names,
/// in_place (kept in place outside originals/), unhashed (never verified) or
/// missing, with how many; or unreadable (0 photos): the sequence's sidecar cannot be read, so the sequence
/// keeps its folder, title and names, and so does every folder it is inside.
///
public sealed record ReorganizeBlockedDto(string Reason, int Photos, string Message);
///
/// One sequence of a Reorganize plan, in the order the steps apply: its folder and title before and after,
/// when it only moves with a folder it is inside, the frames version its file names were planned at
/// (0 when none changes), how many photos get a new name with the first of them (), and what stays
/// as it is (). A step that changes nothing lists only that.
///
public sealed record ReorganizeStepDto(Guid SequenceId, string FromFolder, string ToFolder, string? FromTitle, string? ToTitle, bool Carried,
int FramesVersion, int FileChanges, IReadOnlyList FileSamples, IReadOnlyList Blocked);
///
/// The dry run of a Reorganize: its steps (those that change nothing list only what stays as it is), the sequences that
/// change (carried ones included), the photos renamed, the photos that keep their names (a sequence that stays as it is
/// whole, unreadable, counts none), and the fingerprint the change sends back.
///
public sealed record ReorganizePlanDto(IReadOnlyList Steps, int Sequences, int Files, int Kept, string Fingerprint);
///
/// POST /api/v1/archive/convert (owner review 2, R7; administrators of the archive): the photos of
/// , or of every sequence with (exactly one of the two), converted to
/// (jpeg, tiff16 or linear-dng, the archival choice) with 1–100
/// for a JPEG (default 95, ignored otherwise). , chosen at every run: replace (the converted files
/// become the frames, the originals go to the archive's trash) or new-sequence (copies in a new sequence, the source
/// untouched, the photos it leaves as they are not copied into it). answers the plan
/// () and changes nothing; the server keeps it a few minutes, a refusal too, so the same dry run
/// again (also after one cut off, in either mode, at any quality of a lossless target) is answered from it with the busy
/// sequences and the free space as they are then; 503 plan_dropped when the server stopped making it (it took too
/// long, or too many were asked at once). The change itself sends that plan's back and takes the
/// plan kept (503 plan_dropped when none is kept for the index as it is now, let go since or the index changed in
/// what the plan reads, the sequences' rows and the formats, sizes, hashes and flags of their photos: ask the dry run
/// again, then confirm that one; 409 plan_changed when the plan kept is not the one confirmed: a job made one of its
/// sequences busy or free since, or a conversion of them was queued) and runs as a convert job (202), which
/// converts the photos of that plan alone and leaves as it is a sequence where one of them no longer fits.
///
public sealed record ConvertRequest(IReadOnlyList? SequenceIds, bool All, string? Target, int? Quality, string? Mode, bool DryRun,
string? Fingerprint = null);
///
/// Photos of a sequence a conversion leaves as they are: same_format, convert_on_pc (the
/// server cannot read them at full resolution: a CR3, a HEIC, a body its RAW decoder does not support), undecodable,
/// missing, unhashed (never verified), eight_bit (a RAW the host develops at 8 bits only, for a 16-bit
/// target), color_profile (a colour profile the target can neither keep nor convert to), too_large or
/// inaccessible (another program held the file open, or it could not be opened, when the plan was made), how many,
/// and the reason as one localised sentence: of a sequence new-sequence copies, that the new sequence lacks them (it
/// holds the converted copies alone).
///
public sealed record ConvertSkippedDto(string Reason, int Photos, string Message);
/// Why a whole sequence is not converted now: busy, offline, unreadable or frames_changed, as one localised sentence too.
public sealed record ConvertBlockedDto(string Reason, string Message);
///
/// One sequence of a conversion plan: its title, folder and the frames version it was planned at, the photos converted
/// with their size now and the estimated size after, the photos left as they are and why, and what blocks the sequence
/// (it is then not converted).
///
public sealed record ConvertSequenceDto(Guid SequenceId, string Title, string Folder, int FramesVersion, int Photos, long BytesBefore, long BytesAfter,
IReadOnlyList Skipped, IReadOnlyList Blocked);
///
/// The space a conversion needs on the archive's volume (the estimate × 1.15 plus a 512 MiB reserve; with replace the
/// originals stay in the trash, so it adds up), what is free there (null when it cannot be measured), whether it is
/// enough, and the line the dialog shows.
///
public sealed record ConvertSpaceDto(long Required, long? Free, bool Enough, string Message);
///
/// The dry run of a conversion: the target, quality and mode, each sequence asked for in order (), the
/// sequences and photos converted, the photos skipped, the bytes before and the estimate after, the space, and the
/// fingerprint the change sends back.
///
public sealed record ConvertPlanDto(string Target, int Quality, string Mode, IReadOnlyList Steps, int Sequences, int Photos, int Skipped,
long BytesBefore, long BytesAfter, ConvertSpaceDto Space, string Fingerprint);