using System.Text.Json; using System.Text.Json.Serialization; using Chronos.Core.Imaging; using Chronos.Core.Model; namespace Chronos.Core.Archiving; /// /// .chronos/sequence.json, the canonical record of one sequence (BRIEF §7). The database is rebuilt from it, /// so it carries the ids of the sequence and of every frame. Fields this build does not know are kept in /// and written back unchanged. /// public sealed record SequenceManifest { public const int CurrentSchemaVersion = 1; public int SchemaVersion { get; init; } = CurrentSchemaVersion; public required Guid Id { get; init; } public string? Title { get; init; } public SidecarCamera? Camera { get; init; } public string? Lens { get; init; } /// Frames in capture order; equals the position. public IReadOnlyList Frames { get; init; } = []; public IReadOnlyList Tags { get; init; } = []; public int Rating { get; init; } public string? Notes { get; init; } /// bits, stored as a number so bits of newer builds survive. public SequenceStatus Status { get; init; } public ManifestVersions Versions { get; init; } = new(); /// User id or client name that created the sequence. public string? CreatedBy { get; init; } public DateTimeOffset Created { get; init; } public DateTimeOffset UpdatedAt { get; init; } public DateTimeOffset? VerifiedAt { get; init; } /// Session keys of automatic grouping (uploads, card imports) that resolve to this sequence. public IReadOnlyList SessionKeys { get; init; } = []; [JsonExtensionData] public Dictionary? Extra { get; set; } } public sealed record SidecarCamera { public string? Make { get; init; } public string? Model { get; init; } public string? Serial { get; init; } [JsonExtensionData] public Dictionary? Extra { get; set; } } /// Counters the sync protocol compares (BRIEF §14.5). public sealed record ManifestVersions { public int Settings { get; init; } public int Frames { get; init; } [JsonExtensionData] public Dictionary? Extra { get; set; } } /// One frame of ; property names follow BRIEF §7. public sealed record SidecarFrame { public required Guid Id { get; init; } /// Index in capture order, from 0. public int I { get; init; } /// Path relative to the sequence folder, forward slashes (originals/… for imported frames). public required string File { get; init; } /// Name the file had on the card or upload source. public string? Original { get; init; } public long Size { get; init; } /// Lower-case hex SHA-256; null until a verify hashes an adopted file. public string? Sha256 { get; init; } /// Camera wall-clock time with sub-seconds. public DateTime? CapturedAt { get; init; } public int? UtcOffset { get; init; } [JsonConverter(typeof(TolerantEnumConverter))] public TimestampSource TimeSource { get; init; } public double? Exposure { get; init; } public double? FNumber { get; init; } public int? Iso { get; init; } public double? Focal { get; init; } public double? Bias { get; init; } public int? Wb { get; init; } public int Orientation { get; init; } = 1; public int W { get; init; } public int H { get; init; } [JsonConverter(typeof(TolerantEnumConverter))] public ImageFileFormat Format { get; init; } public long? PreviewOffset { get; init; } public long? PreviewLength { get; init; } /// Size of the largest embedded preview (or GPR companion JPEG), stored like and /// before orientation; null when the file has none or it is not known yet. public int? PreviewW { get; init; } public int? PreviewH { get; init; } /// /// Decode tier of the file (BRIEF §8.2) as the host that indexed or decoded it last found it; omitted until it is /// known. (unless that host reads the frame from its proxy) and /// follow it. /// [JsonConverter(typeof(TolerantEnumConverter))] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public DecodeTier Tier { get; init; } /// bits, stored as a number so bits of newer builds survive. public FrameFlags Flags { get; init; } [JsonExtensionData] public Dictionary? Extra { get; set; } }