diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c17137..5027d60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ All notable changes to [bpmn-moddle](https://github.com/bpmn-io/bpmn-moddle) are ___Note:__ Yet to be released changes appear here._ +## 7.0.2 + +* `FIX`: recursively log nested namespaces as used ([#78](https://github.com/bpmn-io/bpmn-moddle/pull/78)) +* `CHORE`: update to `moddle-xml@9.0.2` + +## 6.0.6 + +* `FIX`: recursively log nested namespaces as used ([#78](https://github.com/bpmn-io/bpmn-moddle/pull/78)) +* `CHORE`: update to `moddle-xml@8.0.7` + ## 6.0.5 * `FIX`: account for local namespace declaration overrides ([#76](https://github.com/bpmn-io/bpmn-moddle/pull/76)) diff --git a/package-lock.json b/package-lock.json index abdbbd6..0a4c182 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1310,9 +1310,9 @@ } }, "moddle-xml": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/moddle-xml/-/moddle-xml-9.0.1.tgz", - "integrity": "sha512-AXT3C1XGxo2h2ckk9hz62MY/spDobyhR+A2o30it0ZAO/NFDWpzYm+y/WeC52XrWi/MzUrVz8JVtfJu+W2DESA==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/moddle-xml/-/moddle-xml-9.0.2.tgz", + "integrity": "sha512-SRDEAoypv1lXIx2vGpbCb/HEO8fnEMFIDSCpiW4D/tlLeJbKlNGCusJkj8FSXh8+tyQS5xMKWlT6RNJda7vvsA==", "requires": { "min-dash": "^3.0.0", "moddle": "^5.0.1", diff --git a/package.json b/package.json index edbf398..060ba05 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,6 @@ "dependencies": { "min-dash": "^3.0.0", "moddle": "^5.0.1", - "moddle-xml": "^9.0.1" + "moddle-xml": "^9.0.2" } } diff --git a/test/fixtures/bpmn/local-ns-no-di.bpmn b/test/fixtures/bpmn/local-ns-no-di.bpmn new file mode 100644 index 0000000..1372b8a --- /dev/null +++ b/test/fixtures/bpmn/local-ns-no-di.bpmn @@ -0,0 +1,16 @@ + + + + + SequenceFlow + + + SequenceFlow + + + + + + + + \ No newline at end of file diff --git a/test/spec/xml/edit.js b/test/spec/xml/edit.js index 299d2cd..30fd761 100644 --- a/test/spec/xml/edit.js +++ b/test/spec/xml/edit.js @@ -6,6 +6,7 @@ import { import { fromFile as readFromFile, + validate, toXML } from '../../xml-helper'; @@ -73,4 +74,113 @@ describe('bpmn-moddle - edit', function() { expect(xml).to.contain(''); }); }); + + + describe('generate DI', function() { + + async function readAndGenerateDI(file) { + + var { + rootElement: definitions + } = await fromFile(file); + + var process = definitions.rootElements[0]; + + var flowElements = process.flowElements; + + var [ + start, + task, + flow + ] = flowElements; + + var plane = definitions.diagrams[0].plane; + + var model = definitions.$model; + + var planeElements = plane.get('planeElement'); + + // when + planeElements.push( + model.create('bpmndi:BPMNEdge', { + id: 'Flow_di', + bpmnElement: flow, + waypoint: [ + model.create('dc:Point', { x: 100, y: 100 }), + model.create('dc:Point', { x: 150, y: 150 }) + ] + }), + model.create('bpmndi:BPMNShape', { + id: 'Start_di', + bpmnElement: start, + bounds: model.create('dc:Bounds', { x: 50, y: 50, width: 100, height: 100 }) + }), + model.create('bpmndi:BPMNShape', { + id: 'Task_di', + bpmnElement: task, + bounds: model.create('dc:Bounds', { x: 100, y: 100, width: 100, height: 100 }) + }) + ); + + return { + definitions + }; + } + + + it('should auto-add wellknown', async function() { + + // given + var { + definitions + } = await readAndGenerateDI('test/fixtures/bpmn/local-ns-no-di.bpmn'); + + // when + var { + xml + } = await toXML(definitions, { format: true }); + + // then + expect(xml).to.contain( + 'xmlns:di="http://www.omg.org/spec/DD/20100524/DI"' + ); + + expect(xml).to.contain( + 'xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"' + ); + + await validate(xml); + }); + + + it('should reuse global namespace', async function() { + + // given + var { + definitions + } = await readAndGenerateDI('test/fixtures/bpmn/local-ns-no-di.bpmn'); + + // when + // set global namespace information + definitions.$attrs['xmlns:di'] = 'http://www.omg.org/spec/DD/20100524/DI'; + definitions.$attrs['xmlns:dc'] = 'http://www.omg.org/spec/DD/20100524/DC'; + + var { + xml + } = await toXML(definitions, { format: true }); + + // then + expect(xml).to.contain( + 'xmlns:di="http://www.omg.org/spec/DD/20100524/DI"' + ); + + expect(xml).to.contain( + 'xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"' + ); + + await validate(xml); + }); + + }); + }); diff --git a/test/spec/xml/write.js b/test/spec/xml/write.js index 4364aac..6b1772d 100644 --- a/test/spec/xml/write.js +++ b/test/spec/xml/write.js @@ -677,6 +677,7 @@ describe('bpmn-moddle - write', function() { expect(xml).to.eql(expectedXML); }); + it('BPMNShape (colored)', async function() { // given @@ -697,6 +698,7 @@ describe('bpmn-moddle - write', function() { expect(xml).to.eql(expectedXML); }); + it('BPMNEdge (colored)', async function() { // given