ls1intum / Apollon

UML Modeling Editor written in React
https://apollon-library.readthedocs.io
MIT License
65 stars 22 forks source link

Diagram schema migration #306

Closed loreanvictor closed 10 months ago

loreanvictor commented 10 months ago

Checklist

Motivation and Context

Following up on this discussion: Current model schema of Apollon results in unnecessary conflicts when patching / merging two replicas (e.g. in realtime collaboration) using JSONPatch and JSONPointer standards.

Description

The proposed change will use id -> element maps instead of arrays for element, relationships, assessments and interactive fields of the model schema, causing standard patch operations on these collections to become idempotent, and if not directly targeting the same element, commutative, effectively resolving most conflicts that could arise while merging two replicas of the model. It results in a major bump in model version to v3, with import support for v2 models (no export support added atm).

IMPORTANT

This requires a follow up PR for simplifying and optimising the serialisation/deserialisation code. This change is excluded from the current PR as the existing code has issues that need to be fixed beforehand (as otherwise, it is almost impossible to ensure the refactoring yields correct results).

Steps for Testing

  1. Run the editor
  2. Create a diagram and export it as JSON

Test Coverage

File Branch Line
main/apollon-editor.ts 79.16% 83.47%
main/typings.ts 100% 100%
main/compat 100% 100%
main/compat/v2 100% 100%
main/components/store 97.72% 93.82%
main/packages/uml-communication-diagram/uml-communication-link/uml-communication-link.ts 72.72% 90.47%
main/scenes/svg.tsx 73.46% 81.56%

There are some other files that are changed by prettier, I have not included them since their coverage is unchanged.

matthiaslehnertum commented 10 months ago

Looks good to me! Nicely done! Apollon itself as well as the deserialization of v2 diagrams operate as expected.

matthiaslehnertum commented 10 months ago

Can you merge this one @loreanvictor ? :)

loreanvictor commented 10 months ago

Can you merge this one @loreanvictor ? :)

Unfortunately, I do not seem to have the permission 😅

krusche commented 10 months ago

I will merge the PR