Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,22 @@ public async Task<UploadFileResponse> SaveFile(Stream stream, LcmFileMetadata me
}
}

#region Submit (result-less write variants)
// Nothing to skip here: liblcm holds the object already, and a genuinely missing one should still throw.
public async Task SubmitUpdateEntry(Guid id, UpdateObjectInput<Entry> update) => await UpdateEntry(id, update);
public async Task SubmitCreateComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent>? position = null) => await CreateComplexFormComponent(complexFormComponent, position);
public async Task SubmitMoveComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent> between) => await MoveComplexFormComponent(complexFormComponent, between);
public async Task SubmitCreateSense(Guid entryId, Sense sense, BetweenPosition? position = null) => await CreateSense(entryId, sense, position);
public async Task SubmitUpdateSense(Guid entryId, Guid senseId, UpdateObjectInput<Sense> update) => await UpdateSense(entryId, senseId, update);
public async Task SubmitCreateExampleSentence(Guid entryId, Guid senseId, ExampleSentence exampleSentence, BetweenPosition? position = null) => await CreateExampleSentence(entryId, senseId, exampleSentence, position);
public async Task SubmitUpdateExampleSentence(Guid entryId, Guid senseId, Guid exampleSentenceId, UpdateObjectInput<ExampleSentence> update) => await UpdateExampleSentence(entryId, senseId, exampleSentenceId, update);
public async Task SubmitUpdatePartOfSpeech(Guid id, UpdateObjectInput<PartOfSpeech> update) => await UpdatePartOfSpeech(id, update);
public async Task SubmitUpdatePicture(Guid entryId, Guid senseId, Guid pictureId, UpdateObjectInput<Picture> update) => await UpdatePicture(entryId, senseId, pictureId, update);
public async Task SubmitUpdatePublication(Guid id, UpdateObjectInput<Publication> update) => await UpdatePublication(id, update);
public async Task SubmitUpdateSemanticDomain(Guid id, UpdateObjectInput<SemanticDomain> update) => await UpdateSemanticDomain(id, update);
public async Task SubmitUpdateComplexFormType(Guid id, UpdateObjectInput<ComplexFormType> update) => await UpdateComplexFormType(id, update);
#endregion

private string TypeToLinkedFolder(string mimeType)
{
return mimeType switch
Expand Down
187 changes: 120 additions & 67 deletions backend/FwLite/FwLiteProjectSync/RecordingMiniLcmApi.cs

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions backend/FwLite/FwLiteProjectSync/WriteIgnoringMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,6 @@ public Task RemovePublication(Guid entryId, Guid publicationId)
}

#region Submit (sync's result-less write variants)
// Explicit, not the interface default: that routes to the returning Update* and re-reads the object, which
// throws when a dry run hits an object the other side already deleted.
public Task SubmitUpdateEntry(Guid id, UpdateObjectInput<Entry> update)
{
return Task.CompletedTask;
Expand Down Expand Up @@ -359,6 +357,16 @@ public Task SubmitCreateComplexFormComponent(ComplexFormComponent complexFormCom
return Task.CompletedTask;
}

public Task SubmitMoveComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent> between)
{
return Task.CompletedTask;
}

public Task SubmitUpdatePicture(Guid entryId, Guid senseId, Guid pictureId, UpdateObjectInput<Picture> update)
{
return Task.CompletedTask;
}

public Task SubmitUpdatePartOfSpeech(Guid id, UpdateObjectInput<PartOfSpeech> update)
{
return Task.CompletedTask;
Expand Down
30 changes: 15 additions & 15 deletions backend/FwLite/MiniLcm/IMiniLcmWriteApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,23 @@ Task<Picture> UpdatePicture(Guid entryId,

#region Submit (fire-and-forget write variants for sync)
// Result-less write variants the sync uses instead of the returning Update/Create methods above. The CRDT
// overrides them to submit the change without fetching the result, so applying to an object the other side
// deleted leaves it deleted (delete wins) rather than throwing. The defaults forward to the returning
// method (correct for FwData, which still surfaces a genuinely-missing object).
Task SubmitUpdateEntry(Guid id, UpdateObjectInput<Entry> update) => UpdateEntry(id, update);
Task SubmitCreateComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent>? position = null) => CreateComplexFormComponent(complexFormComponent, position);
Task SubmitMoveComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent> between) => MoveComplexFormComponent(complexFormComponent, between);
Task SubmitCreateSense(Guid entryId, Sense sense, BetweenPosition? position = null) => CreateSense(entryId, sense, position);
Task SubmitUpdateSense(Guid entryId, Guid senseId, UpdateObjectInput<Sense> update) => UpdateSense(entryId, senseId, update);
Task SubmitCreateExampleSentence(Guid entryId, Guid senseId, ExampleSentence exampleSentence, BetweenPosition? position = null) => CreateExampleSentence(entryId, senseId, exampleSentence, position);
Task SubmitUpdateExampleSentence(Guid entryId, Guid senseId, Guid exampleSentenceId, UpdateObjectInput<ExampleSentence> update) => UpdateExampleSentence(entryId, senseId, exampleSentenceId, update);
// implements them to submit the change without fetching the result, so applying to an object the other side
// deleted leaves it deleted (delete wins) rather than throwing.
// No defaults on purpose: a wrapper that has to see every write can't then inherit one silently.
Task SubmitUpdateEntry(Guid id, UpdateObjectInput<Entry> update);
Task SubmitCreateComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent>? position = null);
Task SubmitMoveComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent> between);
Task SubmitCreateSense(Guid entryId, Sense sense, BetweenPosition? position = null);
Task SubmitUpdateSense(Guid entryId, Guid senseId, UpdateObjectInput<Sense> update);
Task SubmitCreateExampleSentence(Guid entryId, Guid senseId, ExampleSentence exampleSentence, BetweenPosition? position = null);
Task SubmitUpdateExampleSentence(Guid entryId, Guid senseId, Guid exampleSentenceId, UpdateObjectInput<ExampleSentence> update);
// Dependency types too (they sync before entries, outside EntrySync's try/catch). WritingSystem is omitted
// (its update resolves the entity id, so it can't be a blind submit); MorphType is omitted (not deletable).
Task SubmitUpdatePartOfSpeech(Guid id, UpdateObjectInput<PartOfSpeech> update) => UpdatePartOfSpeech(id, update);
Task SubmitUpdatePicture(Guid entryId, Guid senseId, Guid pictureId, UpdateObjectInput<Picture> update) => UpdatePicture(entryId, senseId, pictureId, update);
Task SubmitUpdatePublication(Guid id, UpdateObjectInput<Publication> update) => UpdatePublication(id, update);
Task SubmitUpdateSemanticDomain(Guid id, UpdateObjectInput<SemanticDomain> update) => UpdateSemanticDomain(id, update);
Task SubmitUpdateComplexFormType(Guid id, UpdateObjectInput<ComplexFormType> update) => UpdateComplexFormType(id, update);
Task SubmitUpdatePartOfSpeech(Guid id, UpdateObjectInput<PartOfSpeech> update);
Task SubmitUpdatePicture(Guid entryId, Guid senseId, Guid pictureId, UpdateObjectInput<Picture> update);
Task SubmitUpdatePublication(Guid id, UpdateObjectInput<Publication> update);
Task SubmitUpdateSemanticDomain(Guid id, UpdateObjectInput<SemanticDomain> update);
Task SubmitUpdateComplexFormType(Guid id, UpdateObjectInput<ComplexFormType> update);
#endregion

#region CustomView
Expand Down
10 changes: 2 additions & 8 deletions backend/FwLite/MiniLcm/JsonPatchExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Text;
using SystemTextJsonPatch;

namespace MiniLcm;
Expand Down Expand Up @@ -31,14 +30,9 @@ public static bool TryGetPropertyChange<T, TValue>(this UpdateObjectInput<T> upd
}
return false;
}
/// <summary>One line: a multi-line summary breaks per-line grep of the logs it ends up in.</summary>
public static string Summarize<T>(this JsonPatchDocument<T> document) where T : class
{
var sb = new StringBuilder();
sb.AppendLine($"Update: {typeof(T).Name}");
foreach (var op in document.Operations)
{
sb.AppendLine($"{op.OperationType} {op.Path}: {op.Value}");
}
return sb.ToString();
return string.Join(", ", document.Operations.Select(op => $"{op.OperationType} {op.Path}: {op.Value}"));
}
}
2 changes: 2 additions & 0 deletions backend/FwLite/MiniLcm/Models/RichString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public string GetPlainText()
return string.Join("", Spans.Select(s => s.Text));
}

public override string ToString() => GetPlainText();

public void EnsureWs(WritingSystemId ws)
{
foreach (var span in Spans)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public Task<PartOfSpeech> UpdatePartOfSpeech(Guid id, UpdateObjectInput<PartOfSp
return _api.UpdatePartOfSpeech(id, NormalizePatch(update));
}

public async Task SubmitUpdatePartOfSpeech(Guid id, UpdateObjectInput<PartOfSpeech> update)
{
await _api.SubmitUpdatePartOfSpeech(id, NormalizePatch(update));
}


public async Task<PartOfSpeech> UpdatePartOfSpeech(PartOfSpeech before, PartOfSpeech after, IMiniLcmApi? api = null)
{
Expand Down Expand Up @@ -121,6 +126,11 @@ public Task<Publication> UpdatePublication(Guid id, UpdateObjectInput<Publicatio
return _api.UpdatePublication(id, NormalizePatch(update));
}

public async Task SubmitUpdatePublication(Guid id, UpdateObjectInput<Publication> update)
{
await _api.SubmitUpdatePublication(id, NormalizePatch(update));
}


public async Task<Publication> UpdatePublication(Publication before, Publication after, IMiniLcmApi? api = null)
{
Expand Down Expand Up @@ -153,6 +163,11 @@ public Task<SemanticDomain> UpdateSemanticDomain(Guid id, UpdateObjectInput<Sema
return _api.UpdateSemanticDomain(id, NormalizePatch(update));
}

public async Task SubmitUpdateSemanticDomain(Guid id, UpdateObjectInput<SemanticDomain> update)
{
await _api.SubmitUpdateSemanticDomain(id, NormalizePatch(update));
}


public async Task<SemanticDomain> UpdateSemanticDomain(SemanticDomain before, SemanticDomain after, IMiniLcmApi? api = null)
{
Expand Down Expand Up @@ -186,6 +201,11 @@ public Task<ComplexFormType> UpdateComplexFormType(Guid id, UpdateObjectInput<Co
return _api.UpdateComplexFormType(id, NormalizePatch(update));
}

public async Task SubmitUpdateComplexFormType(Guid id, UpdateObjectInput<ComplexFormType> update)
{
await _api.SubmitUpdateComplexFormType(id, NormalizePatch(update));
}


public async Task<ComplexFormType> UpdateComplexFormType(ComplexFormType before, ComplexFormType after, IMiniLcmApi? api = null)
{
Expand Down Expand Up @@ -250,6 +270,11 @@ public Task<Entry> UpdateEntry(Guid id, UpdateObjectInput<Entry> update)
return _api.UpdateEntry(id, NormalizePatch(update));
}

public async Task SubmitUpdateEntry(Guid id, UpdateObjectInput<Entry> update)
{
await _api.SubmitUpdateEntry(id, NormalizePatch(update));
}


public async Task<Entry> UpdateEntry(Entry before, Entry after, IMiniLcmApi? api = null)
{
Expand All @@ -266,11 +291,21 @@ public async Task<ComplexFormComponent> CreateComplexFormComponent(ComplexFormCo
return await _api.CreateComplexFormComponent(NormalizeComplexFormComponent(complexFormComponent), position);
}

public async Task SubmitCreateComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent>? position = null)
{
await _api.SubmitCreateComplexFormComponent(NormalizeComplexFormComponent(complexFormComponent), position);
}

public Task MoveComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent> between)
{
return _api.MoveComplexFormComponent(complexFormComponent, between);
}

public async Task SubmitMoveComplexFormComponent(ComplexFormComponent complexFormComponent, BetweenPosition<ComplexFormComponent> between)
{
await _api.SubmitMoveComplexFormComponent(complexFormComponent, between);
}

public Task DeleteComplexFormComponent(ComplexFormComponent complexFormComponent)
{
return _api.DeleteComplexFormComponent(complexFormComponent);
Expand Down Expand Up @@ -328,11 +363,21 @@ public async Task<Sense> CreateSense(Guid entryId, Sense sense, BetweenPosition?
return await _api.CreateSense(entryId, NormalizeSense(sense), position);
}

public async Task SubmitCreateSense(Guid entryId, Sense sense, BetweenPosition? position = null)
{
await _api.SubmitCreateSense(entryId, NormalizeSense(sense), position);
}

public Task<Sense> UpdateSense(Guid entryId, Guid senseId, UpdateObjectInput<Sense> update)
{
return _api.UpdateSense(entryId, senseId, NormalizePatch(update));
}

public async Task SubmitUpdateSense(Guid entryId, Guid senseId, UpdateObjectInput<Sense> update)
{
await _api.SubmitUpdateSense(entryId, senseId, NormalizePatch(update));
}


public async Task<Sense> UpdateSense(Guid entryId, Sense before, Sense after, IMiniLcmApi? api = null)
{
Expand Down Expand Up @@ -385,11 +430,21 @@ public async Task<ExampleSentence> CreateExampleSentence(Guid entryId, Guid sens
return await _api.CreateExampleSentence(entryId, senseId, NormalizeExampleSentence(exampleSentence), position);
}

public async Task SubmitCreateExampleSentence(Guid entryId, Guid senseId, ExampleSentence exampleSentence, BetweenPosition? position = null)
{
await _api.SubmitCreateExampleSentence(entryId, senseId, NormalizeExampleSentence(exampleSentence), position);
}

public Task<ExampleSentence> UpdateExampleSentence(Guid entryId, Guid senseId, Guid exampleSentenceId, UpdateObjectInput<ExampleSentence> update)
{
return _api.UpdateExampleSentence(entryId, senseId, exampleSentenceId, NormalizePatch(update));
}

public async Task SubmitUpdateExampleSentence(Guid entryId, Guid senseId, Guid exampleSentenceId, UpdateObjectInput<ExampleSentence> update)
{
await _api.SubmitUpdateExampleSentence(entryId, senseId, exampleSentenceId, NormalizePatch(update));
}


public async Task<ExampleSentence> UpdateExampleSentence(Guid entryId, Guid senseId, ExampleSentence before, ExampleSentence after, IMiniLcmApi? api = null)
{
Expand Down Expand Up @@ -461,9 +516,9 @@ public Task<Picture> UpdatePicture(Guid entryId, Guid senseId, Guid pictureId, U
return _api.UpdatePicture(entryId, senseId, pictureId, NormalizePatch(update));
}

public Task SubmitUpdatePicture(Guid entryId, Guid senseId, Guid pictureId, UpdateObjectInput<Picture> update)
public async Task SubmitUpdatePicture(Guid entryId, Guid senseId, Guid pictureId, UpdateObjectInput<Picture> update)
{
return _api.SubmitUpdatePicture(entryId, senseId, pictureId, NormalizePatch(update));
await _api.SubmitUpdatePicture(entryId, senseId, pictureId, NormalizePatch(update));
}

public async Task<Picture> UpdatePicture(Guid entryId, Guid senseId, Picture before, Picture after, IMiniLcmApi? api = null)
Expand Down
Loading