namespace Febe.Web.Api;
// JSON shapes of the copies to external folders (spec §4.10, tappa E2). Same conventions as Dtos.cs: English camelCase
// names, Italian texts, times as LocalTimeDto. Names of states and types on the wire:
// scope «general»|«account»; types «postFoto», «postVideo», «storie», «evidenza», «taggati», «profilo»;
// copy states «copied», «removed», «superseded», «failed»; job states «running», «interrupted», «paused», «completed»,
// «cancelled»; file states «pending», «copied», «adopted», «alreadyCopied», «skipped», «missing», «failed».
///
/// Where copies can go. : destinations are subfolders of (the page
/// lists them); otherwise any folder, with the native picker when .
/// false: nothing can be written, says why.
///
public sealed record ExportRootDto(bool Docker, bool Active, string? Root, string? Problem, bool PickFolder);
/// The library's naming schemes, to prefill «Uno schema suo», and the placeholders.
public sealed record ExportSchemesDto(string General, string Highlight, string Profile, IReadOnlyList Placeholders);
///
/// A destination. is the folder as shown («/esporta/usb» in Docker).
/// are the wire names of the content types; null schemes are «Come la libreria». : the reason
/// of its pause (or, with /status, why it does not answer now). : copies per state
/// (copied, removed, superseded, failed). and
/// only from /status. : an own folder whose account was
/// removed («era di @»).
///
public sealed record ExportDestinationDto(
long Id,
string Scope,
long? AccountId,
string? Username,
string Label,
string RootPath,
string Display,
IReadOnlyList Types,
string? NamingScheme,
string? HighlightNamingScheme,
string? ProfileNamingScheme,
bool Automatic,
LocalTimeDto? PausedAt,
string? Problem,
IReadOnlyDictionary Counts,
bool? Reachable = null,
long? FreeBytes = null,
bool Orphan = false,
string? FormerUsername = null,
string? PhotoFormat = null,
string? VideoFormat = null);
///
/// GET /api/export: Impostazioni → Esportazione and the notice of the Dashboard. :
/// onePerAccount or oneOnly. : interrupted or paused jobs («Riprendi»).
/// Formats (tappa E3) on the wire: original, jpg, png, webplossless, mp4; the
/// library ones are original while the conversion of the library is off. :
/// the state of that conversion.
///
public sealed record ExportOverviewDto(
ExportRootDto Root,
string SamePost,
ExportDestinationDto? General,
IReadOnlyList Own,
IReadOnlyList ActiveRunIds,
int UnfinishedRuns,
ExportSchemesDto Library,
string PhotoFormat = "original",
string VideoFormat = "original",
string LibraryPhotoFormat = "original",
string LibraryVideoFormat = "original",
LibraryConversionDto? LibraryConversion = null);
///
/// The conversion of the library (tappa E3, spec §4.10): files in the queue, converted, failed («Riprova»), that never
/// convert (: «non si convertono»), «In pausa», and why it waits (Italian, null when it does
/// not): an import, a copy or a rebuild at work, an engine session, low space. : the status line
/// («In coda 12 · convertiti 340 · non riusciti 2 · non si convertono 3»). : a library format is
/// chosen.
///
public sealed record LibraryConversionDto(int Pending, int Converted, int Failed, int AsIs, bool Paused, string? Waiting, string Text, bool On);
///
/// PUT /api/export/settings, every field optional (null keeps it): «Lo stesso post in due account»
/// (onePerAccount or oneOnly), the formats of the copies and of the library (wire names).
/// : the answer «Anche i N già in libreria» when a library format is turned on or
/// changed; it queues the files of the kinds whose library format this request changes, never those of the other.
///
public sealed record ExportSettingsRequest(
string? SamePost = null,
string? PhotoFormat = null,
string? VideoFormat = null,
string? LibraryPhotoFormat = null,
string? LibraryVideoFormat = null,
bool? ConvertExisting = null);
/// What PUT /api/export/settings did: a message, the overview after the change, the files queued.
public sealed record ExportSettingsSavedDto(string Message, ExportOverviewDto Overview, int Queued = 0);
///
/// «Converti anche i N file già in libreria?»: that would enter the queue, the bytes of their
/// originals («circa») and the line of the question («gli originali occupano circa 3,1 GB; i convertiti possono occupare
/// di più»).
///
public sealed record LibraryConversionPreviewDto(int Files, long Bytes, string Text);
/// Docker: the subfolders of a folder of /esporta. is "" for the root.
public sealed record ExportFolderListDto(string Relative, string? Parent, string Display, IReadOnlyList Folders);
/// POST /api/export/pick-folder: the destination being changed, to open the picker on its folder.
public sealed record ExportPickRequest(long? DestinationId);
/// The check of a candidate folder (before saving). : files over 4 GB cannot go there.
public sealed record ExportFolderCheckDto(bool Accepted, string FullPath, string Display, string? Problem, long? FreeBytes, bool Fat32);
/// The «Risultato» of a destination's naming. : general or account; null schemes are the library's.
public sealed record ExportNamingPreviewRequest(string Scope, string? General, string? Highlight, string? Profile);
///
/// A destination to add or change. : in Docker the folder relative to /esporta (as listed),
/// elsewhere the full path. : wire names, at least one. Null or empty schemes: «Come la
/// libreria». «Automatica» is stored only (tappa E5 acts on it).
///
public sealed record ExportDestinationRequest(
string Scope,
long? AccountId,
string Path,
string? Label,
IReadOnlyList Types,
string? NamingScheme,
string? HighlightNamingScheme,
string? ProfileNamingScheme,
bool Automatic = false,
bool OnlyNew = true,
string? PhotoFormat = null,
string? VideoFormat = null);
/// A saved destination (a change of folder gives a new id) and the warnings of its schemes.
public sealed record ExportDestinationSavedDto(ExportDestinationDto Destination, IReadOnlyList Warnings);
///
/// What a «Copia in…» copies: exactly one of (files of «Tutte le foto» or the viewer),
/// (a grouped selection), (the filter of the Libreria, as its query
/// string, with grouped or files) or (every file of
/// the account). : «Copia di nuovo anche i tolti o superati». Tappa E3:
/// / override the destination's for this request only
/// (null: as the destination); makes it a frames job («Fotogrammi…» → «Nella cartella delle
/// copie»), without formats.
///
public sealed record CopyJobRequestDto(
IReadOnlyList? MediaIds,
IReadOnlyList? EntryIds,
string? Query,
string? Mode,
long? AccountId,
bool CopyAgain = false,
string? PhotoFormat = null,
string? VideoFormat = null,
FramesRequestDto? Frames = null);
///
/// Which frames (spec §4.10 «Fotogrammi»): istante (at ),
/// ogni (every , at least 100) or numero ( in all, 1 to
/// 1.000); jpg, png (the default) or webplossless.
///
public sealed record FramesRequestDto(string? Mode, long? AtMs = null, long? EveryMs = null, int? Count = null, string? Format = null);
/// Files of a plan copied as they are, of one kind («3 HEIC copiati come sono»).
public sealed record ExportPlanAsIsDto(string Label, int Files);
/// A destination of a plan. : why it cannot be written now (paused, not reachable).
public sealed record ExportPlanDestinationDto(
long Id,
string Label,
string Display,
string Scope,
string? Username,
int Files,
long Bytes,
bool Paused,
string? Problem,
long? FreeBytes);
///
/// The summary of «Copia in…» (spec §10.3). /: what will be written
/// (with «Copia di nuovo» the tolti/superati too). : of accounts that are not exported
/// (switch off, no destination, type not taken). : not in the library. Tappa E3:
/// files predicted copied as they are («circa»), predicted
/// converted, «con perdita»; a frames job: ,
/// , and (videos over 1.000
/// frames: the job is refused). : the line of the dialog («312 file · 41 già copiati, saltati ·
/// circa 3 HEIC copiati come sono · circa 4,2 GB · con perdita»).
///
public sealed record ExportPlanDto(
int Files,
long Bytes,
int AlreadyCopied,
int RemovedOrSuperseded,
int NotExported,
int Missing,
IReadOnlyList Destinations,
bool HasDestination = true,
IReadOnlyList? AsIs = null,
int Converted = 0,
bool Lossy = false,
int Videos = 0,
int PhotosSkipped = 0,
int Frames = 0,
int OverCap = 0,
string? Summary = null);
/// The jobs a «Copia in…» started, one per destination (empty: nothing to copy), and the plan it followed.
public sealed record ExportJobDto(IReadOnlyList RunIds, ExportPlanDto Plan, string Message);
/// «Copia di nuovo» of a copy «Tolto» or «Superato» (the viewer).
public sealed record CopyAgainRequest(long CopyId);
///
/// GET /api/export/progress, polled by the Dashboard tab. : preparing, checking,
/// waitingForSession, copying, finished. : files of the job per state.
///
public sealed record ExportProgressDto(
long? RunId,
string Phase,
double Fraction,
int FilesDone,
int FilesTotal,
long BytesDone,
long BytesTotal,
string? CurrentFile,
string? Destination,
IReadOnlyDictionary ByState,
bool Running,
string? Error);
/// An export job. : copy or recognize; : manual or automatic.
public sealed record ExportRunDto(
long Id,
long DestinationId,
string Destination,
string Kind,
string Origin,
string State,
LocalTimeDto StartedAt,
LocalTimeDto? CompletedAt,
string? Error,
int Total,
int Done,
bool Running = false);
///
/// The files of one account in a job ( counts written and adopted files).
/// : files copied as they are, by kind («HEIC» → 3).
///
public sealed record ExportReportAccountDto(long? AccountId, string Username, int Copied, int AlreadyCopied, int Skipped, int Failed, IReadOnlyDictionary? AsIs = null);
/// A file of the report that needs a look, with its reason in Italian.
public sealed record ExportReportLineDto(long ItemId, string Username, string? Path, string State, string Text);
///
/// The report of a job (at most 200 problems). (tappa E3): files copied or adopted with a note
/// (what a conversion could not keep, a file copied as it is), at most 200.
///
public sealed record ExportReportDto(
ExportRunDto Run,
IReadOnlyDictionary ByState,
long BytesCopied,
IReadOnlyList Accounts,
IReadOnlyList Problems,
IReadOnlyList? Notes = null);
///
/// A copy of a file of the viewer (spec §4.6, §4.10). : copied, removed, superseded, failed;
/// : whole, converted or frame; : the wire name of a converted copy or
/// of a frame (null for a whole one); and («0:01,25») for a
/// frame. : with «Una copia sola», the account it was copied for when it is another one.
/// : «Copia di nuovo» of that same form. : why it failed.
///
public sealed record MediaCopyDto(
long CopyId,
string Destination,
bool DestinationRetired,
string State,
string Variant,
string? Format,
long? FrameAtMs,
LocalTimeDto At,
string? ForAccount,
bool CanCopyAgain,
string? FrameLabel = null,
string? Notes = null);
///
/// A converted file of the library next to its original (tappa E3, spec §4.10): (wire name),
/// pending, converted, failed, asIs («non si converte»),
/// superseded or removed, its size, and : what was not kept, or why it failed or
/// does not convert. : the file is on disk («Scarica», «Mostra nella cartella»).
///
public sealed record MediaConversionDto(long Id, string Format, string State, long? Bytes, string? Notes, bool Available, string? FileName);
///
/// «Copie esterne» of the account card. : the effective one (its own folder, else the
/// general folder), null when there is none. Counts are of due files (decision D3 of tappa E2): with the switch off
/// they are zero.
///
public sealed record ExportAccountDto(
bool Enabled,
bool HasOwnFolder,
ExportDestinationDto? Destination,
int Due,
int NotCopied,
int RemovedOrSuperseded,
int Failed);
// ---------------------------------------------------------------------------------------------- frames (tappa E3)
///
/// GET /api/media/{id}/frames/info: whether frames can be taken from the video (:
/// «Fotogramma non disponibile per questo video»), its length and its size as shown (rotation applied).
///
public sealed record FrameInfoDto(bool Available, string? Unavailable, long DurationMs, int Width, int Height, bool HasAudio);
///
/// One instant of a frames request: the one asked for, the one really shown (the frame's identity, ms rounded up), its
/// label («0:01,25») and the suffix of its file name (_t0m01s250, _f001).
///
public sealed record FrameInstantDto(int Index, long RequestedMs, long ActualMs, string Label, string Suffix);
///
/// GET /api/media/{id}/frames/instants: the instants of a mode for one video (at most 1.000). :
/// how many it asks; : why none is given (over 1.000, not available).
///
public sealed record FrameInstantsDto(long DurationMs, int Total, bool OverCap, string? Problem, IReadOnlyList Instants);
///
/// The frames of a selection («Fotogrammi…» from the selection bars): exactly one of ,
/// (every video of those entries) or with ,
/// and which frames.
///
public sealed record FramesSelectionRequest(IReadOnlyList? MediaIds, IReadOnlyList? EntryIds, string? Query, string? Mode, FramesRequestDto? Frames);
///
/// POST /api/frames/plan: what «Scarica» would give. : videos without frames (or
/// not on disk); : videos over 1.000 frames; : more than
/// 500 frames («Nella cartella delle copie»); : more than 20 (only outside engine sessions
/// and other long work). : why «Scarica» cannot run now; : the line
/// of the dialog («12 fotogrammi da 4 video · le 3 foto si saltano»).
///
public sealed record FramesPlanDto(int Videos, int PhotosSkipped, int NotAvailable, int Frames, int OverCap, bool TooManyToDownload, bool NeedsQuiet, string? Problem, string Summary);
/// A download of frames ready: open once within 5 minutes.
public sealed record FramesTokenDto(string Token, int Frames, string Url);
/// A converted file of the library («Mostra nella cartella»).
public sealed record ConversionActionRequest(long ConversionId);
///
/// What «Elimina dalla libreria» would remove (tappa E3, spec §4.6): the entries, their files and the converted files of
/// the library made from them («elimino gli elementi interi, 9 file e 2 file convertiti»).
///
public sealed record EntryDeletionPreviewDto(int Entries, int Files, int ConvertedFiles);