Skip to content
A diffing utility for BPMN 2.0 documents.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib fix(differ): swap new/old value in collection properties Jul 20, 2018
test
.eslintignore feat(project): provide pre-built distribution Apr 23, 2018
.eslintrc feat(project): update to ES modules Apr 23, 2018
.gitignore
.npmignore feat(project): provide pre-built distribution Apr 23, 2018
.npmrc
.travis.yml chore(project): bump dev dependencies Nov 28, 2017
CHANGELOG.md chore(CHANGELOG): update to v2.0.2 Jul 20, 2018
README.md docs(README): fix example typo May 16, 2019
package.json
rollup.config.js chore(project): drop jsondiffpatch in favor of diffpatch Apr 25, 2018

README.md

bpmn-js-differ

Build Status

A semantic diffing utility for BPMN 2.0 files. To be used together with bpmn-moddle.

Usage

Get the project via npm:

npm install --save bpmn-js-differ

Use the differ to compare two BPMN 2.0 documents:

import { diff } from 'bpmn-js-differ';

var oldDefinitions, newDefinitions; // read with bpmn-moddle

var changes = diff(oldDefinitions, newDefinitions);

The diff returns an object with the _changed, _added, _removed, _layoutChanged keys containing all differences between the models.

console.log(changes._changed);
// {
//   ServiceTask_1: {
//     model: { $type: 'bpmn:ServiceTask', id: 'ServiceTask_1', ... },
//     attrs: { name: { oldValue: '', newValue: 'T' } }
//   }
// }

console.log(changes._removed);
// {
//   SequenceFlow_1: { $type: 'bpmn:SequenceFlow', id: 'SequenceFlow_1' }
// }

console.log(changes._layoutChanged);
// {
//   StartEvent_1: { $type: 'bpmn:StartEvent', id: 'StartEvent_1' }
// }

console.log(changes._added);
// {
//   Participant_1: { $type: 'bpmn:Participant', id: 'Participant_1' }
// }

Reading BPMN 2.0 documents

Get bpmn-moddle via npm:

npm install --save bpmn-moddle

Load two diagrams:

import BpmnModdle from 'bpmn-moddle';

function loadModels(a, b) {

  new BpmnModdle().fromXML(a, function(err, adefs) {

    if (err) {
      return done(err);
    }

    new BpmnModdle().fromXML(b, function(err, bdefs) {
      if (err) {
        return done(err);
      } else {
        return done(null, adefs, bdefs);
      }
    });
  });
}


loadModels(aXML, bXML, function(err, aDefinitions, bDefinitions) {

  // go ahead and use the models
});

Visual Diffing

Use bpmn-js along with element coloring to build your visual diff tool on top of this utility.

License

MIT

You can’t perform that action at this time.