Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bpmn-moddle

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bpmn-moddle - npm Package Compare versions

Comparing version 6.0.4 to 7.0.0

10

CHANGELOG.md

@@ -9,2 +9,10 @@ # Changelog

## 7.0.0
* `FEAT`: promisify `fromXML` and `toXML` APIs. ([#73](https://github.com/bpmn-io/bpmn-moddle/pull/73))
### Breaking Changes
* `fromXML` and `toXML` APIs now return a Promise. Support for callbacks is dropped. Refer to the [documentation](https://github.com/bpmn-io/bpmn-moddle#usage) for updated usage information.
## 6.0.4

@@ -86,2 +94,2 @@

Check `git log` for earlier history.
Check `git log` for earlier history.

71

dist/index.esm.js

@@ -1,2 +0,2 @@

import { isString, isFunction, assign } from 'min-dash';
import { isString, assign } from 'min-dash';
import { Moddle } from 'moddle';

@@ -20,4 +20,22 @@ import { Reader, Writer } from 'moddle-xml';

/**
* The fromXML result.
*
* @typedef {Object} ParseResult
*
* @property {ModdleElement} rootElement
* @property {Array<Object>} references
* @property {Array<Error>} warnings
* @property {Object} elementsById - a mapping containing each ID -> ModdleElement
*/
/**
* The fromXML error.
*
* @typedef {Error} ParseError
*
* @property {Array<Error>} warnings
*/
/**
* Instantiates a BPMN model tree from a given xml string.

@@ -28,9 +46,8 @@ *

* @param {Object} [options] options to pass to the underlying reader
* @param {Function} done callback that is invoked with (err, result, parseContext)
* once the import completes
*
* @returns {Promise<ParseResult, ParseError>}
*/
BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) {
BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options) {
if (!isString(typeName)) {
done = options;
options = typeName;

@@ -40,11 +57,6 @@ typeName = 'bpmn:Definitions';

if (isFunction(options)) {
done = options;
options = {};
}
var reader = new Reader(assign({ model: this, lax: true }, options));
var rootHandler = reader.handler(typeName);
reader.fromXML(xmlStr, rootHandler, done);
return reader.fromXML(xmlStr, rootHandler);
};

@@ -54,2 +66,10 @@

/**
* The toXML result.
*
* @typedef {Object} SerializationResult
*
* @property {String} xml
*/
/**
* Serializes a BPMN 2.0 object tree to XML.

@@ -59,23 +79,20 @@ *

* @param {Object} [options] to pass to the underlying writer
* @param {Function} done callback invoked with (err, xmlStr) once the import completes
*
* @returns {Promise<SerializationResult, Error>}
*/
BpmnModdle.prototype.toXML = function(element, options, done) {
BpmnModdle.prototype.toXML = function(element, options) {
if (isFunction(options)) {
done = options;
options = {};
}
var writer = new Writer(options);
var result;
var err;
return new Promise(function(resolve, reject) {
try {
var result = writer.toXML(element);
try {
result = writer.toXML(element);
} catch (e) {
err = e;
}
return done(err, result);
return resolve({
xml: result
});
} catch (err) {
return reject(err);
}
});
};

@@ -82,0 +99,0 @@

@@ -22,4 +22,22 @@ 'use strict';

/**
* The fromXML result.
*
* @typedef {Object} ParseResult
*
* @property {ModdleElement} rootElement
* @property {Array<Object>} references
* @property {Array<Error>} warnings
* @property {Object} elementsById - a mapping containing each ID -> ModdleElement
*/
/**
* The fromXML error.
*
* @typedef {Error} ParseError
*
* @property {Array<Error>} warnings
*/
/**
* Instantiates a BPMN model tree from a given xml string.

@@ -30,9 +48,8 @@ *

* @param {Object} [options] options to pass to the underlying reader
* @param {Function} done callback that is invoked with (err, result, parseContext)
* once the import completes
*
* @returns {Promise<ParseResult, ParseError>}
*/
BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) {
BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options) {
if (!minDash.isString(typeName)) {
done = options;
options = typeName;

@@ -42,11 +59,6 @@ typeName = 'bpmn:Definitions';

if (minDash.isFunction(options)) {
done = options;
options = {};
}
var reader = new moddleXml.Reader(minDash.assign({ model: this, lax: true }, options));
var rootHandler = reader.handler(typeName);
reader.fromXML(xmlStr, rootHandler, done);
return reader.fromXML(xmlStr, rootHandler);
};

@@ -56,2 +68,10 @@

/**
* The toXML result.
*
* @typedef {Object} SerializationResult
*
* @property {String} xml
*/
/**
* Serializes a BPMN 2.0 object tree to XML.

@@ -61,23 +81,20 @@ *

* @param {Object} [options] to pass to the underlying writer
* @param {Function} done callback invoked with (err, xmlStr) once the import completes
*
* @returns {Promise<SerializationResult, Error>}
*/
BpmnModdle.prototype.toXML = function(element, options, done) {
BpmnModdle.prototype.toXML = function(element, options) {
if (minDash.isFunction(options)) {
done = options;
options = {};
}
var writer = new moddleXml.Writer(options);
var result;
var err;
return new Promise(function(resolve, reject) {
try {
var result = writer.toXML(element);
try {
result = writer.toXML(element);
} catch (e) {
err = e;
}
return done(err, result);
return resolve({
xml: result
});
} catch (err) {
return reject(err);
}
});
};

@@ -84,0 +101,0 @@

{
"name": "bpmn-moddle",
"version": "6.0.4",
"version": "7.0.0",
"description": "A moddle wrapper for BPMN 2.0",

@@ -60,4 +60,4 @@ "scripts": {

"moddle": "^5.0.1",
"moddle-xml": "^8.0.5"
"moddle-xml": "^9.0.0"
}
}

@@ -7,3 +7,3 @@ # bpmn-moddle

__bpmn-moddle__ uses the [BPMN 2.0 meta-model](http://www.omg.org/spec/BPMN/2.0/) to validate the input and produce correct BPMN 2.0 XML.
__bpmn-moddle__ uses the [BPMN 2.0 meta-model](http://www.omg.org/spec/BPMN/2.0/) to validate the input and produce correct BPMN 2.0 XML.

@@ -18,5 +18,5 @@

var moddle = new BpmnModdle();
const moddle = new BpmnModdle();
var xmlStr =
const xmlStr =
'<?xml version="1.0" encoding="UTF-8"?>' +

@@ -29,18 +29,17 @@ '<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +

moddle.fromXML(xmlStr, function(err, definitions) {
const {
rootElement: definitions
} = await moddle.fromXML(xmlStr);
// update id attribute
definitions.set('id', 'NEW ID');
// update id attribute
definitions.set('id', 'NEW ID');
// add a root element
var bpmnProcess = moddle.create('bpmn:Process', { id: 'MyProcess_1' });
definitions.get('rootElements').push(bpmnProcess);
// add a root element
const bpmnProcess = moddle.create('bpmn:Process', { id: 'MyProcess_1' });
definitions.get('rootElements').push(bpmnProcess);
moddle.toXML(definitions, function(err, xmlStrUpdated) {
// xmlStrUpdated contains new id and the added process
});
});
// xmlStrUpdated contains new id and the added process
const {
xml: xmlStrUpdated
} = await moddle.toXML(definitions);
```

@@ -47,0 +46,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc