using Febe.Core.Engine; namespace Febe.Web.Api; // JSON shapes of the API. English names (camelCase on the wire); every text meant for Alberto is Italian. // Times: milliseconds since the Unix epoch (UTC), plus local strings computed in Alberto's zone where the page shows a // clock or a day, so the page never needs to know the zone of the server. /// An error the page shows as it is. public sealed record ProblemDto(string Message); /// A short answer of a command. public sealed record MessageDto(string Message); /// An instant with its local day and clock time. : 0 today, 1 tomorrow, -1 yesterday. public sealed record LocalTimeDto(long Ms, string Day, string Clock, int DayDelta); /// What this shell can do (the page adapts its buttons). public sealed record CapabilitiesDto( string Edition, bool Demo, string Access, bool ShowInFolder, bool PickFolder, bool OpenUrlNative, bool FoldersReadOnly, bool Autostart, bool BrowserWindow, bool Notifications, string Version, string? Scene, IReadOnlyList Scenes, long Now, string Today, IReadOnlyList Problems); public sealed record PreferencesDto(string Theme); // ---------------------------------------------------------------- library /// The cover of a tile. is the thumbnail key (null: neutral tile). public sealed record CoverDto(long MediaId, string Kind, int? Width, int? Height, double? Duration, string? Thumb); /// /// A tile of the mosaic: one entry, or with «Tutte le foto» one file of it (the cover is that file and /// its place in the series; null for an entry tile). /// public sealed record TileDto( long Id, long AccountId, string Username, string Kind, long PublishedAt, string Day, string Time, string Provenance, string State, int Files, CoverDto? Cover, int? Position = null); /// A window of tiles; cursors continue it (null: nothing more that way). public sealed record LibraryPageDto(IReadOnlyList Tiles, string? Older, string? Newer); /// What a line of the history of the Dashboard saved (spec §7.9): the first tiles and how many in all. public sealed record ArrivedDto(IReadOnlyList Tiles, int Total); /// A day of the mosaic: its count and the cursor that starts at its end. public sealed record DayDto(string Day, int Count, string Cursor); /// Days of the mosaic with the totals; only with «Tutte le foto» (the files of the entries). public sealed record LibraryDaysDto(long Now, string Today, int Entries, int Accounts, IReadOnlyList Days, int? Files = null); public sealed record AccountBriefDto(long Id, string Username, string? DisplayName, bool IsPrivate, bool IsFollowed, bool IsMine, string State, string? Avatar); public sealed record MediaDto( long Id, int Position, string Kind, int? Width, int? Height, double? Duration, long? Bytes, string? FileName, string? Folder, string? Thumb, bool Available, string State, bool Damaged = false); /// Everything the viewer shows of an entry. public sealed record EntryDto( long Id, string Kind, AccountBriefDto Account, long PublishedAt, string PublishedDay, string PublishedTime, string? Code, string? InstagramId, string? Caption, string? Author, string Provenance, string State, LocalTimeDto Discovered, LocalTimeDto? Downloaded, IReadOnlyList Highlights, string? InstagramUrl, IReadOnlyList Media); public sealed record EntryIdsRequest(IReadOnlyList Ids, string? Mode); public sealed record DeleteResultDto(int Deleted, int FilesRemoved, IReadOnlyList Problems, string Message); /// Export by keys, or by the current filter when no keys are given. public sealed record ExportRequest(IReadOnlyList? Ids, string? Query); public sealed record MediaActionRequest(long MediaId); // ---------------------------------------------------------------- accounts public sealed record ContentTypesDto(bool Photos, bool Videos, bool Stories, bool Highlights, bool Tagged, bool ProfilePicture); /// A row of the accounts table (mockup 03). public sealed record AccountRowDto( long Id, string Username, string? DisplayName, bool IsPrivate, bool IsFollowed, bool IsMine, string State, string? UnreachableReason, bool NeedsAttention, IReadOnlyList Notices, bool KeepUpdated, bool KeptUpdated, string Frequency, ContentTypesDto Types, int InLibrary, int Posts, int? PostCount, int NewPostsToday, int NewStoriesToday, bool BackfillResumesTomorrow, long? LastCheck, LocalTimeDto? NextCheck, LocalTimeDto? StateChanged, long AddedAt, string? Avatar, string? PreviousUsername); public sealed record AccountCountsDto(int All, int UpToDate, int Backfilling, int Paused, int ArchiveOnly, int NeedsAttention, int KeptUpdated); public sealed record AccountListDto(long Now, AccountCountsDto Counts, IReadOnlyList Accounts); public sealed record AccountStatsDto(int Entries, int Posts, int Stories, int HighlightItems, int Tagged, int ProfilePictures, int Collections, long Bytes, int PendingFiles); /// /// The editable settings of an account (mockup 05). is «Cosa scaricare prima» (spec §4.4): /// the names of the five kinds first to last for «Un ordine suo», null or empty for «Come le impostazioni generali». /// public sealed record AccountSettingsDto( bool KeepUpdated, string Frequency, double? CustomPostHours, double? CustomStoryHours, ContentTypesDto Types, string Depth, int? LastPosts, string? FromDate, int BackfillPerDay, double? MaxVideoMb, bool StoryVideos, string? Folder, IReadOnlyList? DownloadOrder = null); public sealed record PlanLineDto(string Key, string Title, string Text); /// «Con queste impostazioni» (spec §4.4). public sealed record PlanDto( IReadOnlyList Lines, IReadOnlyList Warnings, double Share, double OpensPerDay, int DailyBudget, bool OverBudget, string FrequencyHint, string? Note); public sealed record HighlightDto(long Id, string Title, int Count, bool Removed, IReadOnlyList EntryIds); public sealed record AccountDetailDto( AccountRowDto Account, AccountStatsDto Stats, AccountSettingsDto Settings, PlanDto Plan, string Folder, bool FolderIsDefault, string? InstagramUrl, IReadOnlyList Highlights, int MaxBackfillPerDay, IReadOnlyList? GeneralDownloadOrder = null); public sealed record HistoryItemDto(long Id, LocalTimeDto At, string Severity, string Code, string Message); public sealed record HistoryDto(IReadOnlyList Items, long? Before); public sealed record SwitchRequest(bool Value); public sealed record CheckNowRequest(string? Token); public sealed record CheckNowDto(string Status, string Message, string? Token); public sealed record RemoveAccountRequest(bool DeleteFiles); public sealed record RemoveAccountDto(string Outcome, int DeletedEntries, int Problems, string Message); public sealed record ParseRequest(string Text); public sealed record ParsedNameDto(int Line, string Username, bool Present, long? AccountId, bool Followed, string? DisplayName, bool? IsPrivate); public sealed record ParseProblemDto(int Line, string Text, string Reason); public sealed record ParseResultDto(IReadOnlyList Names, IReadOnlyList Problems); public sealed record AddAccountsRequest(IReadOnlyList Usernames, string Start, string? Depth, int? LastPosts); public sealed record AddAccountsDto(int Added, IReadOnlyList Skipped, string Message); /// A profile for the local suggestions: one Alberto follows, or an account in Febe he does not follow. /// The site's identifier, when known (to merge with the results of the search). /// Thumbnail key of the newest profile picture in the library (/api/thumbnails/{key}). /// Key of a photo of the search in memory (/api/ricerca/foto/{key}). /// True when Alberto follows the profile (from the list of followed profiles). public sealed record FollowingProfileDto(string Username, string? DisplayName, bool? IsPrivate, long? AccountId, string? InstagramId = null, string? Avatar = null, string? Photo = null, bool Followed = true); /// Default «Storico, massimo al giorno» of the caution profile, for the note of the dialog. public sealed record FollowingDto(long? ReadAt, string? ReadDay, bool InProgress, int ReadSoFar, int Total, IReadOnlyList Profiles, int BackfillPerDay); // ---------------------------------------------------------------- profile search (issue #37) /// The text of the search box of the dialog. is a random id of the window (16 hex). public sealed record ProfileSearchRequest(string Client, string? Text) { private bool PrintMembers(System.Text.StringBuilder builder) { builder.Append($"TextLength = {Text?.Length ?? 0}"); return true; } } /// The dialog closed. public sealed record ProfileSearchEndRequest(string Client); /// /// What the search shows. is one of /// idle|solo-locale|attesa|cerca|pronta|vuota|nessuna-risposta|non-possibile|fuori-fascia|ferma|non-pronto|da-configurare|rifiutata|errore; /// is true when the window that asks wrote the text. /// public sealed record ProfileSearchDto(long Version, bool Mine, string Text, string State, string? Message, long? RetryAfter, IReadOnlyList Hits) { private bool PrintMembers(System.Text.StringBuilder builder) { builder.Append($"Version = {Version}, State = {State}, Hits = {Hits.Count}"); return true; } } /// A profile found on the site, with what Febe knows of it (account, followed, private). /// Key of its photo in memory, once . /// Thumbnail key of the account's newest profile picture in the library, when it is in Febe. public sealed record ProfileSearchHitDto(string InstagramId, string Username, string? DisplayName, bool? IsVerified, string? Photo, bool PhotoReady, long? AccountId, bool Followed, bool? IsPrivate, string? Avatar) { private bool PrintMembers(System.Text.StringBuilder builder) { builder.Append($"PhotoReady = {PhotoReady}, InFebe = {AccountId is not null}, Followed = {Followed}"); return true; } } // ---------------------------------------------------------------- engine /// The connected account at the bottom of the sidebar. /// "connected", "notConnected", "verification", "disconnected". public sealed record ConnectionDto(string State, string? Username, string? DisplayName, string? Avatar); /// The engine for the sidebar, the stop strip and the Dashboard. public sealed record EngineDto(long Now, EngineSnapshot Snapshot, ConnectionDto Connection, bool CanResume); public sealed record ResumeDto(bool Resumed, string Message); // ---------------------------------------------------------------- access public sealed record LoginRequest(string? Password); public sealed record LoginDto(bool Ok, string Message, long? LockedUntil);