Skip to content

Some change operations need to fail? #46

@umesh-timalsina

Description

@umesh-timalsina

While working on webgme-diffsync, I realize that changeset's ChangeType.put or ChangeType.del will always succeed (case in point, setting a pointer to a removed node) when using NodeState as T2 for webgme-diffsync. While this might not be of concern for WJI, second guessing the change success/failure in the callee is also not ideal. I am opening this issue to start a discussion on formalizing these ChangeSet patch operations (for increased type correctness as well as ease of use).

MWE

const fco = await core.loadByPath(rootNode, '/1');
const parent = core.createNode({
    parent: rootNode,
    base: fco
});

const child1 = core.createNode({
    parent: parent,
    base: fco
});

const child2 = core.createNode({
    parent: parent,
    base: fco
});

const child3 = core.createNode({
    parent: parent,
    base: fco
});

core.setPointer(child1, 'sibling', child2);

const syncer = new JSONImporter(core, rootNode);
const state = await importer.toJSON(parent); 

const deletedPointerGuid = core.getGuid(child3);
core.deleteNode(child3);

state.children[1].pointers.sibling = deletedPointerGuid;
await importer.apply(parent, state); // Should this fail? Can we formalize this a bit better
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions