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

@bpmn-io/dmn-migrate

Package Overview
Dependencies
Maintainers
9
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bpmn-io/dmn-migrate - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

95

dist/index.esm.js

@@ -72,25 +72,19 @@ import DmnModdle from 'dmn-moddle';

*/
function migrateDiagram(xml) {
return new Promise((resolve, reject) => {
if (!isString(xml)) {
async function migrateDiagram(xml) {
if (!isString(xml)) {
// return XML without migrating
return resolve(xml);
}
// return XML without migrating
return xml;
}
try {
if (hasNamespace(DMN11URI, xml)) {
return resolve(migrateFrom11To13(xml));
} else if (hasNamespace(DMN12URI, xml)) {
return resolve(migrateFrom12To13(xml));
} else if (hasNamespace(DMN13URI, xml)) {
return resolve(xml);
}
} catch (err) {
return reject(err);
}
if (hasNamespace(DMN11URI, xml)) {
return migrateFrom11To13(xml);
} else if (hasNamespace(DMN12URI, xml)) {
return migrateFrom12To13(xml);
} else if (hasNamespace(DMN13URI, xml)) {
return xml;
}
// return XML without migrating
return resolve(xml);
});
// return XML without migrating
return xml;
}

@@ -115,13 +109,22 @@

*
* @returns {string}
* @returns {Promise<string>}
*/
function migrateFrom12To13(xml) {
return new Promise(resolve => resolve(
xml
.replace(DMN12URI, DMN13URI)
.replace('"http://www.omg.org/spec/DMN/20180521/DMNDI/"', '"https://www.omg.org/spec/DMN/20191111/DMNDI/"')
));
async function migrateFrom12To13(xml) {
return xml
.replace(DMN12URI, DMN13URI)
.replace('"http://www.omg.org/spec/DMN/20180521/DMNDI/"', '"https://www.omg.org/spec/DMN/20191111/DMNDI/"');
}
/**
* @param {string} xml
* @return {Promise<[ definitions: any, error: any | null ]>}
*/
async function parse13Defininitions(xml) {
return moddle.fromXML(xml, 'dmn:Definitions').then(
result => [ result.rootElement, null ],
error => [ null, error ]
);
}
/**
* Migrate DMN 1.1 XML to 1.3.

@@ -133,32 +136,22 @@ *

*/
function migrateFrom11To13(xml) {
return new Promise((resolve, reject) => {
const namespaceReplacedXML = xml.replace(DMN11URI, DMN13URI);
async function migrateFrom11To13(xml) {
moddle.fromXML(namespaceReplacedXML, 'dmn:Definitions', (parsingError, definitions) => {
if (parsingError) {
const namespaceReplacedXML = xml.replace(DMN11URI, DMN13URI);
// return XML without migrating
return resolve(xml);
}
const [ definitions, parsingError ] = await parse13Defininitions(namespaceReplacedXML);
try {
addIds(definitions);
// return XML without migrating
if (parsingError) {
return xml;
}
addNames(definitions);
addIds(definitions);
migrateDI(definitions, moddle);
} catch (migrationError) {
return reject(migrationError);
}
addNames(definitions);
moddle.toXML(definitions, { format: true }, (serializationError, migratedXML) => {
if (serializationError) {
return reject(serializationError);
} else {
return resolve(migratedXML);
}
});
});
});
migrateDI(definitions, moddle);
const { xml: migratedXML } = await moddle.toXML(definitions, { format: true });
return migratedXML;
}

@@ -165,0 +158,0 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var DmnModdle = _interopDefault(require('dmn-moddle'));
var Ids = _interopDefault(require('ids'));
var DmnModdle = require('dmn-moddle');
var Ids = require('ids');
var minDash = require('min-dash');

@@ -78,25 +74,19 @@

*/
function migrateDiagram(xml) {
return new Promise((resolve, reject) => {
if (!minDash.isString(xml)) {
async function migrateDiagram(xml) {
if (!minDash.isString(xml)) {
// return XML without migrating
return resolve(xml);
}
// return XML without migrating
return xml;
}
try {
if (hasNamespace(DMN11URI, xml)) {
return resolve(migrateFrom11To13(xml));
} else if (hasNamespace(DMN12URI, xml)) {
return resolve(migrateFrom12To13(xml));
} else if (hasNamespace(DMN13URI, xml)) {
return resolve(xml);
}
} catch (err) {
return reject(err);
}
if (hasNamespace(DMN11URI, xml)) {
return migrateFrom11To13(xml);
} else if (hasNamespace(DMN12URI, xml)) {
return migrateFrom12To13(xml);
} else if (hasNamespace(DMN13URI, xml)) {
return xml;
}
// return XML without migrating
return resolve(xml);
});
// return XML without migrating
return xml;
}

@@ -121,13 +111,22 @@

*
* @returns {string}
* @returns {Promise<string>}
*/
function migrateFrom12To13(xml) {
return new Promise(resolve => resolve(
xml
.replace(DMN12URI, DMN13URI)
.replace('"http://www.omg.org/spec/DMN/20180521/DMNDI/"', '"https://www.omg.org/spec/DMN/20191111/DMNDI/"')
));
async function migrateFrom12To13(xml) {
return xml
.replace(DMN12URI, DMN13URI)
.replace('"http://www.omg.org/spec/DMN/20180521/DMNDI/"', '"https://www.omg.org/spec/DMN/20191111/DMNDI/"');
}
/**
* @param {string} xml
* @return {Promise<[ definitions: any, error: any | null ]>}
*/
async function parse13Defininitions(xml) {
return moddle.fromXML(xml, 'dmn:Definitions').then(
result => [ result.rootElement, null ],
error => [ null, error ]
);
}
/**
* Migrate DMN 1.1 XML to 1.3.

@@ -139,32 +138,22 @@ *

*/
function migrateFrom11To13(xml) {
return new Promise((resolve, reject) => {
const namespaceReplacedXML = xml.replace(DMN11URI, DMN13URI);
async function migrateFrom11To13(xml) {
moddle.fromXML(namespaceReplacedXML, 'dmn:Definitions', (parsingError, definitions) => {
if (parsingError) {
const namespaceReplacedXML = xml.replace(DMN11URI, DMN13URI);
// return XML without migrating
return resolve(xml);
}
const [ definitions, parsingError ] = await parse13Defininitions(namespaceReplacedXML);
try {
addIds(definitions);
// return XML without migrating
if (parsingError) {
return xml;
}
addNames(definitions);
addIds(definitions);
migrateDI(definitions, moddle);
} catch (migrationError) {
return reject(migrationError);
}
addNames(definitions);
moddle.toXML(definitions, { format: true }, (serializationError, migratedXML) => {
if (serializationError) {
return reject(serializationError);
} else {
return resolve(migratedXML);
}
});
});
});
migrateDI(definitions, moddle);
const { xml: migratedXML } = await moddle.toXML(definitions, { format: true });
return migratedXML;
}

@@ -171,0 +160,0 @@

{
"name": "@bpmn-io/dmn-migrate",
"version": "0.4.3",
"version": "0.5.0",
"description": "Migrate DMN diagrams to the latest DMN standard.",

@@ -12,3 +12,3 @@ "main": "dist/index.js",

"scripts": {
"build": "rollup -c",
"build": "rollup -c --bundleConfigAsCjs",
"distro": "run-s build test:build",

@@ -38,12 +38,12 @@ "lint": "eslint .",

"dependencies": {
"dmn-moddle": "^8.0.0",
"ids": "^1.0.0",
"min-dash": "^3.5.2"
"dmn-moddle": "^10.0.0",
"ids": "^1.0.5",
"min-dash": "^4.1.1"
},
"devDependencies": {
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-json": "^6.1.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"eslint": "^6.8.0",
"eslint-plugin-bpmn-io": "^0.10.0",
"eslint": "^8.56.0",
"eslint-plugin-bpmn-io": "^1.0.0",
"esm": "^3.2.25",

@@ -53,5 +53,8 @@ "execa": "^4.0.0",

"npm-run-all": "^4.1.5",
"rollup": "^1.27.8",
"xsd-schema-validator": "^0.6.0"
}
"rollup": "^4.9.4",
"xsd-schema-validator": "^0.7.0"
},
"files": [
"dist"
]
}
# dmn-migrate
[![Build Status](https://travis-ci.com/bpmn-io/dmn-migrate.svg?branch=master)](https://travis-ci.com/bpmn-io/dmn-migrate)
[![CI](https://github.com/bpmn-io/dmn-migrate/workflows/CI/badge.svg)](https://github.com/bpmn-io/dmn-migrate/actions?query=workflow%3ACI)

@@ -5,0 +5,0 @@ Migrate your DMN diagrams to the latest DMN version (currently __DMN 1.3__).

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