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 @»). Tappa E5: is «Automatica»,
/// its «Solo i nuovi» instant («Automatica dal …»; null with «Copia anche quelli già
/// in libreria» or when it is off); , only for a destination in pause, the files that wait for
/// it: what it would copy by itself when it is automatic, else what its unfinished jobs still have to copy.
///
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,
LocalTimeDto? AutomaticSince = null,
int? Waiting = null);
///
/// GET /api/export: Impostazioni → Esportazione and the notice of the Dashboard. :
/// onePerAccount or oneOnly. : interrupted or paused jobs of Alberto
/// («Riprendi»); the automatic ones resume by themselves and are not counted (tappa E5).
/// 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. : the automatic copies (tappa E5), null when they do not
/// run (the demonstration, a start with problems).
///
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,
ExportAutomaticStatusDto? Automatic = null);
///
/// The automatic copies now (tappa E5, spec §4.10): a destination in use has «Automatica»
/// on; why they wait (an engine session, an import, a copy of Alberto's…), or null;
/// and of the recovery round («giro di recupero», at start-up and
/// every hour); : «Interrompi» stopped them until then («Riprendi ora»).
///
public sealed record ExportAutomaticStatusDto(bool AnyAutomatic, string? Waiting, LocalTimeDto? LastRound, LocalTimeDto? NextRound, LocalTimeDto? HeldUntil);
///
/// POST /api/export/automatic-preview (tappa E5): how many files an automatic destination would copy by itself.
/// :
/// switchOn, the question «Solo i nuovi / Copia anche gli N già in libreria» when «Automatica» is turned on (the
/// destination as the dialog has it: , , ,
/// ; the copies of count only while the folder stays the same);
/// widen, the files in more when add types to the automatic destination
/// ;
/// removeOwn, the files of that go by themselves to the automatic general folder
/// once its own folder is taken away;
/// account, the files of that its automatic destination copies by itself
/// («Esporta questo account» turned on again).
///
public sealed record ExportAutomaticPreviewRequest(
string Mode,
long? DestinationId = null,
string? Scope = null,
long? AccountId = null,
string? Path = null,
IReadOnlyList? Types = null);
///
/// What POST /api/export/automatic-preview counted: , the bytes of their originals
/// («circa»), the line to show and, for a stored folder, its free space (null when unknown).
///
public sealed record ExportAutomaticPreviewDto(int Files, long Bytes, string Text, long? FreeBytes = null);
/// «Riconosci le copie già presenti» started (tappa E5): the message and the job.
public sealed record ExportRecognizeStartedDto(string Message, long RunId);
///
/// 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» (tappa E5); is the answer when it is
/// turned on («Solo i nuovi»; false: «Copia anche quelli già in libreria»), kept while it stays on.
///
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), or fermo («Salva il fotogramma» of one still video, tappa E4: the instant of its analysis, nothing
/// else); 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»). Tappa E4, «Salva il fotogramma»:
/// videos that are not «Fermo» or were never analysed (skipped).
///
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,
int NotStill = 0);
/// 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. Tappa E5, from the job
/// being worked on: copy or recognize (null for «Controlla le copie»),
/// manual or automatic. : a job of Alberto's runs
/// or starts (an automatic one is not: «Riprendi» makes it give way, answer 49).
///
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,
string? Kind = null,
string? Origin = null,
bool ManualRunning = false);
/// 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. Tappa E5, for «Riconosci le copie già
/// presenti»: of the skipped files, are not in the folder and
/// have another file where the copy would be (those are problems; the ones not found are not).
///
public sealed record ExportReportDto(
ExportRunDto Run,
IReadOnlyDictionary ByState,
long BytesCopied,
IReadOnlyList Accounts,
IReadOnlyList Problems,
IReadOnlyList? Notes = null,
int NotFound = 0,
int Different = 0);
///
/// 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);
// ---------------------------------------------------------------------------------------------- still videos (tappa E4)
///
/// The analysis of a video («È un video fermo?», spec §4.10, tappa E4), on and as the answer
/// of POST /api/media/{id}/still; a video never analysed has none. : still,
/// moving or notAnalyzable; : made by the algorithm of this Febe (otherwise
/// «Analizza di nuovo»); and («0:01,125»): the frame
/// «Salva il fotogramma» saves, only on still; : English codes separated by spaces
/// (FrameNotAvailable, DurationUnknown, Unreadable, TooSlow, AllDark,
/// SingleColor, SmallMotion); : the local day of the analysis (yyyy-MM-dd).
///
public sealed record StillVideoDto(string Outcome, bool Current, long? FrameAtMs, string? FrameLabel, string? Note, string Day);
///
/// The selection of «Cerca i video fermi»: exactly one of ,
/// (every video of those entries), with , or .
///
public sealed record StillVideosSelectionRequest(IReadOnlyList? MediaIds, IReadOnlyList? EntryIds, string? Query, string? Mode, long? AccountId = null);
///
/// POST /api/still-videos/plan: the confirmation of «Cerca i video fermi», by file (two entries of one video count
/// once). = + (skipped) +
/// (not in the library); : photos of the selection;
/// : «28 video da analizzare · 12 già analizzati · le 5 foto si saltano»;
/// : why the job would wait now (an engine session, an import, copies or a rebuild), or null.
///
public sealed record StillVideosPlanDto(int Videos, int ToAnalyse, int AlreadyAnalysed, int PhotosSkipped, int Missing, string Summary, string? Waiting);
///
/// The job «Cerca i video fermi» (GET /api/still-videos/progress, and the answer of start and stop):
/// of settled as , ,
/// or (file gone or changed); :
/// ended by «Interrompi»; : why it waits now; : the file analysed
/// now; : «Analizzati 28 video: 3 fermi, 24 in movimento, 1 non analizzabile»;
/// : in the answer of start, the videos it added to the job (0 when all were queued already).
///
public sealed record StillVideosProgressDto(
bool Running,
int Total,
int Done,
int Still,
int Moving,
int NotAnalyzable,
int Skipped,
bool Stopped,
string? Waiting,
long? CurrentMediaId,
string Summary,
int Added);