eclipse-emfcloud / emfcloud-modelserver

Modelserver component
Other
40 stars 21 forks source link

GH-209: API V2: Return patches for each affected resource #215

Closed CamilleLetavernier closed 2 years ago

CamilleLetavernier commented 2 years ago

Change the return value of edit, undo and redo operations, to return one patch per modified resource, in addition to the main-resource patch.

Before:

{
    "type": "success",
    "data": {
        "message": "Model 'SuperBrewer3000.coffee' successfully updated",
        "patch": [
            {
                "op": "remove",
                "path": "/workflows/0/nodes"
            }
        ]
    }
}

After:

{
    "type": "success",
    "data": {
        "message": "Model 'SuperBrewer3000.coffee' successfully updated",
        "patch": [
            {
                "op": "remove",
                "path": "/workflows/0/nodes"
            }
        ],
        "allPatches": [
            {
                "modelUri": "file:/home/camille/Git/modelserver/examples/org.eclipse.emfcloud.modelserver.example/.temp/workspace/SuperBrewer3000.coffee",
                "patch": [
                    {
                        "op": "remove",
                        "path": "/workflows/0/nodes"
                    }
                ]
            }
        ]
    }
}

Note that for the main resource, the patches are redundant. We could keep "allPatches" exclusively, but it would make everything a bit more complicated: with a main patch, we don't have to worry about modelUri at all in case of single-resource edition. With multiple-resources, we can rely on allPatches exclusively and ignore the main patch. Keeping both also means we don't break existing clients (and single-resource implementations do not need to change), which is a lot easier.

Contributed on behalf of STMicroelectronics.