Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

bpmn-moddle

bpmn-io377.6kMIT9.0.1TypeScript support: definitely-typed

A moddle wrapper for BPMN 2.0

bpmn, moddle, bpmn20, meta-model

readme

bpmn-moddle

CI

Read and write BPMN 2.0 diagram files in NodeJS and the browser.

bpmn-moddle uses the BPMN 2.0 meta-model to validate the input and produce correct BPMN 2.0 XML.

Usage

Get the library via npm package. Consume it in NodeJS, via UMD or bundle it using your favorite build tool.

import BpmnModdle from 'bpmn-moddle';

const moddle = new BpmnModdle();

const xmlStr =
  '<?xml version="1.0" encoding="UTF-8"?>' +
  '<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
                     'id="empty-definitions" ' +
                     'targetNamespace="http://bpmn.io/schema/bpmn">' +
  '</bpmn2:definitions>';


const {
  rootElement: definitions
} = await moddle.fromXML(xmlStr);

// update id attribute
definitions.set('id', 'NEW ID');

// add a root element
const bpmnProcess = moddle.create('bpmn:Process', { id: 'MyProcess_1' });
definitions.get('rootElements').push(bpmnProcess);

// xmlStrUpdated contains new id and the added process
const {
  xml: xmlStrUpdated
} = await moddle.toXML(definitions);

Resources

Building the Project

The tests include XSD schema validation. They required you to have a Java SDK installed and exposed through the JAVA_HOME variable.

# execute the test
npm test

# perform a full build
npm run all

The library is built on top of moddle and moddle-xml.

License

Use under the terms of the MIT license.

changelog

Changelog

All notable changes to bpmn-moddle are documented here. We use semantic versioning for releases.

Unreleased

_Note: Yet to be released changes appear here._

9.0.1

  • FIX: correct the engine field to require Node 18 (#113)

9.0.0

Breaking Changes

  • Require Node >= 18
  • Drop UMD distribution. Use ES module export in modern JavaScript run-times

8.1.0

8.0.1

  • FIX: correct serialization of LinkEventDefinition#target (#96)

8.0.0

  • DEPS: update to moddle@6
  • DEPS: update to moddle-xml@10
  • DEPS: update to min-dash@4
  • CHORE: turn into ES module

7.1.3

7.1.2

  • FIX: make bpmn:InteractionNode include bpmn:CallActivity

7.1.1

  • FIX: properly inline BPMN in Color schema (#88)

7.1.0

  • FEAT: add BPMN in Color schema (#87)
  • CHORE: update dependencies

7.0.5

  • FIX: correct serialization of xml prefixed attributes on Any elements
  • CHORE: update to `moddle-xml@9.0.5`

7.0.4

7.0.3

6.0.7

7.0.2

6.0.6

6.0.5

7.0.1

7.0.0

  • FEAT: promisify fromXML and toXML APIs. (#73)

Breaking Changes

  • fromXML and toXML APIs now return a Promise. Support for callbacks is dropped. Refer to the documentation for updated usage information.

6.0.4

6.0.3

6.0.2

  • FIX: correct DataAssociation#assignment serialization (#68)

6.0.1

6.0.0

5.2.0

  • FEAT: validate ID attributes as QNames

5.1.6

  • FIX: correct Choreography model definitions (#59)

5.1.5

  • FIX: correct StandardLoopCharacteristics#loopMaximum type (#56)

5.1.4

  • FIX: correct extension attributes not being serialized on bpmn:Expression elements (#55)

5.1.3

  • FIX: correct missing resourceParameterBinding parent

5.1.2

  • CHORE: warn on unknown attribute in well-known namespace
  • FIX: correct missing participantMultiplicity parent

5.1.0

  • CHORE: bump dependency versions

5.0.0

Breaking Changes

  • FEAT: migrate to ES modules. Use esm or a ES module aware transpiler to consume this library.

4.0.0

  • FEAT: encode entities in body properties (rather than using CDATA escaping)

3.0.2

  • FIX: properly handle . in attribute names

3.0.1

  • FIX: properly decode text entities

3.0.0

  • CHORE: improve error handling on invalid attributes
  • CHORE: drop lodash in favor of min-dash

...

Check git log for earlier history.