New page Stammdaten -> JSON-Editor edits the data files of the selected year
and mandator (default Transactions.json) as plain JSON in Monaco (BlazorMonaco
3.5.0, loaded on demand): highlighting, folding, live syntax errors, search
and replace with regex, format.
RawDataRepository saves only validated text: strict JSON (unknown properties
rejected with line/column), unique non-empty Ids, transactions referencing
existing accounts, accounts still used by transactions not removed. It refuses
if the file changed since loading, backs up the previous version to
backup/{mandator}/{year}/json-{timestamp}/, and saves through BaseRepository
so caches are refreshed.
- Hub MaximumReceiveMessageSize raised to 8 MB (files are several hundred KB)
- unsaved-guard.js asks before leaving with unsaved changes; NavigationLock
doesn't apply because routing between per-page interactive pages is static
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
#nullable enable
|
|
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Schaad.Accounting.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// The data files of the selected year and mandator as plain JSON text, for the JSON editor.
|
|
/// </summary>
|
|
public interface IRawDataRepository
|
|
{
|
|
/// <summary>Data file names, e.g. "Transactions.json".</summary>
|
|
IReadOnlyList<string> FileNames { get; }
|
|
|
|
Task<RawDataFile> LoadAsync(string fileName);
|
|
|
|
/// <summary>
|
|
/// Validates the text and, if it is valid and the file is still as loaded
|
|
/// (<paramref name="loadedHash"/>), backs up the current file and saves the text.
|
|
/// </summary>
|
|
Task<RawDataSaveResult> SaveAsync(string fileName, string text, string loadedHash);
|
|
}
|
|
|
|
/// <param name="Hash">Fingerprint of the file content, to detect changes made elsewhere.</param>
|
|
public record RawDataFile(string FileName, string Path, string Text, string Hash);
|
|
|
|
/// <param name="File">The saved file as now on disk (re-formatted); null if not saved.</param>
|
|
public record RawDataSaveResult(IReadOnlyList<string> Errors, RawDataFile? File, string? BackupPath)
|
|
{
|
|
public bool Saved => File != null;
|
|
}
|
|
}
|