#nullable enable using System.Collections.Generic; using System.Threading.Tasks; using Schaad.Accounting.Models; namespace Schaad.Accounting.Interfaces { /// /// The data files of the selected year and mandator as plain JSON text, for the JSON editor. /// public interface IRawDataRepository { /// Data file names, e.g. "Transactions.json". IReadOnlyList FileNames { get; } Task LoadAsync(string fileName); /// /// Validates the text and, if it is valid and the file is still as loaded /// (), backs up the current file and saves the text. /// Task SaveAsync(string fileName, string text, string loadedHash); /// /// The transactions of the selected year as they are on disk, with the file's fingerprint /// for . /// Task LoadTransactionsAsync(); /// /// Changes only the Text of the given transactions (by Id), with the same safeguards as /// : refused if the file changed since , /// previous version backed up. /// Task SaveTransactionTextsAsync(IReadOnlyDictionary textById, string loadedHash); } public record TransactionSnapshot(IReadOnlyList Transactions, string Hash); /// Fingerprint of the file content, to detect changes made elsewhere. public record RawDataFile(string FileName, string Path, string Text, string Hash); /// The saved file as now on disk (re-formatted); null if not saved. public record RawDataSaveResult(IReadOnlyList Errors, RawDataFile? File, string? BackupPath) { public bool Saved => File != null; } }