@bpmn-io/extract-process-variables
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -624,2 +624,12 @@ import { filter, find, isArray, forEach, findIndex } from 'min-dash'; | ||
/** | ||
* Extractors add ProcessVariables to the `options.processVariables` parameter. | ||
* @callback extractor | ||
* @param {Object} options | ||
* @param {Array<ModdleElement>} options.elements | ||
* @param {ModdleElement} options.containerElement | ||
* @param {Array<ProcessVariable>} options.processVariables | ||
*/ | ||
// api ///////////////////////// | ||
@@ -630,6 +640,9 @@ | ||
* @param {ModdleElement} containerElement | ||
* @param {Array<extractor>} additionalExtractors | ||
* | ||
* @returns {Array<ProcessVariable>} | ||
* @returns {Promise<Array<ProcessVariable>>} | ||
*/ | ||
function getProcessVariables(containerElement) { | ||
function getProcessVariables(containerElement, additionalExtractors = []) { | ||
const allPromises = []; | ||
var processVariables = []; | ||
@@ -641,11 +654,14 @@ | ||
// (2) extract all variables from the extractors | ||
forEach(extractors, function(extractor) { | ||
extractor({ | ||
elements: elements, | ||
containerElement: containerElement, | ||
processVariables: processVariables | ||
}); | ||
forEach([ ...extractors, ...additionalExtractors ], function(extractor) { | ||
allPromises.push( | ||
extractor({ | ||
elements: elements, | ||
containerElement: containerElement, | ||
processVariables: processVariables | ||
}) | ||
); | ||
}); | ||
return processVariables; | ||
return Promise.all(allPromises) | ||
.then(() => processVariables); | ||
} | ||
@@ -662,8 +678,9 @@ | ||
* @param {ModdleElement} rootElement element from where to extract all variables | ||
* @param {Array<extractor>} additionalExtractors | ||
* | ||
* @returns {Array<ProcessVariable>} | ||
* @returns {Promise<Array<ProcessVariable>>} | ||
*/ | ||
function getVariablesForScope(scope, rootElement) { | ||
async function getVariablesForScope(scope, rootElement, additionalExtractors = []) { | ||
var allVariables = getProcessVariables(rootElement); | ||
var allVariables = await getProcessVariables(rootElement, additionalExtractors); | ||
@@ -670,0 +687,0 @@ var scopeElement = getElement(scope, rootElement); |
@@ -628,2 +628,12 @@ 'use strict'; | ||
/** | ||
* Extractors add ProcessVariables to the `options.processVariables` parameter. | ||
* @callback extractor | ||
* @param {Object} options | ||
* @param {Array<ModdleElement>} options.elements | ||
* @param {ModdleElement} options.containerElement | ||
* @param {Array<ProcessVariable>} options.processVariables | ||
*/ | ||
// api ///////////////////////// | ||
@@ -634,6 +644,9 @@ | ||
* @param {ModdleElement} containerElement | ||
* @param {Array<extractor>} additionalExtractors | ||
* | ||
* @returns {Array<ProcessVariable>} | ||
* @returns {Promise<Array<ProcessVariable>>} | ||
*/ | ||
function getProcessVariables(containerElement) { | ||
function getProcessVariables(containerElement, additionalExtractors = []) { | ||
const allPromises = []; | ||
var processVariables = []; | ||
@@ -645,11 +658,14 @@ | ||
// (2) extract all variables from the extractors | ||
minDash.forEach(extractors, function(extractor) { | ||
extractor({ | ||
elements: elements, | ||
containerElement: containerElement, | ||
processVariables: processVariables | ||
}); | ||
minDash.forEach([ ...extractors, ...additionalExtractors ], function(extractor) { | ||
allPromises.push( | ||
extractor({ | ||
elements: elements, | ||
containerElement: containerElement, | ||
processVariables: processVariables | ||
}) | ||
); | ||
}); | ||
return processVariables; | ||
return Promise.all(allPromises) | ||
.then(() => processVariables); | ||
} | ||
@@ -666,8 +682,9 @@ | ||
* @param {ModdleElement} rootElement element from where to extract all variables | ||
* @param {Array<extractor>} additionalExtractors | ||
* | ||
* @returns {Array<ProcessVariable>} | ||
* @returns {Promise<Array<ProcessVariable>>} | ||
*/ | ||
function getVariablesForScope(scope, rootElement) { | ||
async function getVariablesForScope(scope, rootElement, additionalExtractors = []) { | ||
var allVariables = getProcessVariables(rootElement); | ||
var allVariables = await getProcessVariables(rootElement, additionalExtractors); | ||
@@ -674,0 +691,0 @@ var scopeElement = getElement(scope, rootElement); |
{ | ||
"name": "@bpmn-io/extract-process-variables", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "A util for bpmn-js to extract Camunda BPM process variables from a BPMN 2.0 diagram.", | ||
@@ -16,3 +16,3 @@ "main": "dist/index.js", | ||
"lint": "eslint .", | ||
"prepublishOnly": "run-s distro", | ||
"prepare": "run-s distro", | ||
"dev": "mocha -r esm --reporter=spec --recursive --watch test/**/*Spec.js", | ||
@@ -19,0 +19,0 @@ "test": "nyc --reporter=lcov mocha -r esm --reporter=spec --recursive test/**/*Spec.js", |
@@ -550,8 +550,18 @@ import { filter, find, isArray, forEach, findIndex } from 'min-dash'; | ||
/** | ||
* Extractors add ProcessVariables to the `options.processVariables` parameter. | ||
* @callback extractor | ||
* @param {Object} options | ||
* @param {Array<ModdleElement>} options.elements | ||
* @param {ModdleElement} options.containerElement | ||
* @param {Array<ProcessVariable>} options.processVariables | ||
*/ | ||
/** | ||
* Retrieves all process variables for a given container element. | ||
* @param {ModdleElement} containerElement | ||
* @param {Array<extractor>} [additionalExtractors] | ||
* | ||
* @returns {Array<ProcessVariable>} | ||
* @returns {Promise<Array<ProcessVariable>>} | ||
*/ | ||
function getProcessVariables(containerElement) { | ||
function getProcessVariables(containerElement, additionalExtractors = []) { | ||
var processVariables = []; | ||
@@ -562,12 +572,15 @@ | ||
const allPromises = []; | ||
// (2) extract all variables from the extractors | ||
forEach(extractors, function(extractor) { | ||
extractor({ | ||
forEach([ ...extractors, ...additionalExtractors ], function(extractor) { | ||
allPromises.push(extractor({ | ||
elements: elements, | ||
containerElement: containerElement, | ||
processVariables: processVariables | ||
}); | ||
})); | ||
}); | ||
return processVariables; | ||
return Promise.all(allPromises) | ||
.then(() => processVariables); | ||
} | ||
@@ -584,8 +597,9 @@ | ||
* @param {ModdleElement} rootElement element from where to extract all variables | ||
* @param {Array<extractor>} [additionalExtractors] | ||
* | ||
* @returns {Array<ProcessVariable>} | ||
* @returns {Promise<Array<ProcessVariable>>} | ||
*/ | ||
function getVariablesForScope(scope, rootElement) { | ||
async function getVariablesForScope(scope, rootElement, additionalExtractors = []) { | ||
var allVariables = getProcessVariables(rootElement); | ||
var allVariables = await getProcessVariables(rootElement, additionalExtractors); | ||
@@ -612,4 +626,4 @@ var scopeElement = getElement(scope, rootElement); | ||
function getVariablesForElement(element) { | ||
return getVariablesForScope(getScope(element), getRootElement(element)); | ||
function getVariablesForElement(element, additionalExtractors = []) { | ||
return getVariablesForScope(getScope(element), getRootElement(element), additionalExtractors); | ||
} | ||
@@ -616,0 +630,0 @@ |
@@ -554,8 +554,18 @@ 'use strict'; | ||
/** | ||
* Extractors add ProcessVariables to the `options.processVariables` parameter. | ||
* @callback extractor | ||
* @param {Object} options | ||
* @param {Array<ModdleElement>} options.elements | ||
* @param {ModdleElement} options.containerElement | ||
* @param {Array<ProcessVariable>} options.processVariables | ||
*/ | ||
/** | ||
* Retrieves all process variables for a given container element. | ||
* @param {ModdleElement} containerElement | ||
* @param {Array<extractor>} [additionalExtractors] | ||
* | ||
* @returns {Array<ProcessVariable>} | ||
* @returns {Promise<Array<ProcessVariable>>} | ||
*/ | ||
function getProcessVariables(containerElement) { | ||
function getProcessVariables(containerElement, additionalExtractors = []) { | ||
var processVariables = []; | ||
@@ -566,12 +576,15 @@ | ||
const allPromises = []; | ||
// (2) extract all variables from the extractors | ||
minDash.forEach(extractors, function(extractor) { | ||
extractor({ | ||
minDash.forEach([ ...extractors, ...additionalExtractors ], function(extractor) { | ||
allPromises.push(extractor({ | ||
elements: elements, | ||
containerElement: containerElement, | ||
processVariables: processVariables | ||
}); | ||
})); | ||
}); | ||
return processVariables; | ||
return Promise.all(allPromises) | ||
.then(() => processVariables); | ||
} | ||
@@ -588,8 +601,9 @@ | ||
* @param {ModdleElement} rootElement element from where to extract all variables | ||
* @param {Array<extractor>} [additionalExtractors] | ||
* | ||
* @returns {Array<ProcessVariable>} | ||
* @returns {Promise<Array<ProcessVariable>>} | ||
*/ | ||
function getVariablesForScope(scope, rootElement) { | ||
async function getVariablesForScope(scope, rootElement, additionalExtractors = []) { | ||
var allVariables = getProcessVariables(rootElement); | ||
var allVariables = await getProcessVariables(rootElement, additionalExtractors); | ||
@@ -616,4 +630,4 @@ var scopeElement = getElement(scope, rootElement); | ||
function getVariablesForElement(element) { | ||
return getVariablesForScope(getScope(element), getRootElement(element)); | ||
function getVariablesForElement(element, additionalExtractors = []) { | ||
return getVariablesForScope(getScope(element), getRootElement(element), additionalExtractors); | ||
} | ||
@@ -620,0 +634,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
75231
2273
0