包详细信息

@bpmn-io/extract-process-variables

bpmn-io102.7kMIT1.0.1

A util for bpmn-js to extract Camunda BPM process variables from a BPMN 2.0 diagram.

自述文件

extract-process-variables

CI

An util for bpmn-js to extract Camunda BPM process variables from a BPMN 2.0 diagram.

Installation

$ npm i --save @bpmn-io/extract-process-variables

Usage

Camunda Platform 7

Given this example diagram

import {
  getProcessVariables,
  getVariablesForScope,
} from '@bpmn-io/extract-process-variables';

// For Camunda Platform 8 diagrams, use the /zeebe submodule
// import {
//   getProcessVariables,
//   getVariablesForScope,
// } from '@bpmn-io/extract-process-variables/zeebe';

const canvas = modeler.get('canvas');

const rootElement = canvas.getRootElement();

const allVariables = getProcessVariables(rootElement.businessObject);
/*
  [
    {
      "name": "variable1",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable2",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable3",
      "origin": [ "Task_2" ],
      "scope": "SubProcess_1"
    }
  ]
*/

const scopeVariables = getVariablesForScope('Process_1', rootElement.businessObject);
/*
  [
    {
      "name": "variable1",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable2",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    }
  ]
*/

Note that origin and scope retrieves the full moddle element. The example outputs are reduced due to better readibility.

Note that camunda-bpmn-moddle or zeebe-bpmn-moddle descriptors have to be installed.

Properties support

Camunda Platform 7

We are currently extracting process variables from the following diagram properties

  • camunda:formField
  • camunda:outputParameter
  • camunda:out
  • camunda:resultVariable
  • camunda:errorCodeVariable
  • camunda:errorMessageVariable
  • camunda:escalationCodeVariable

Camunda Platform 8

We are currently extracting process variables from the following diagram properties

  • zeebe:input
  • zeebe:output
  • zeebe:loopCharacteristics > inputElement
  • zeebe:loopCharacteristics > outputCollection
  • zeebe:calledDecision > resultVariable
  • zeebe:script > resultVariable

See also

License

MIT

更新日志

Changelog

All notable changes to @bpmn-io/extract-process-variables are documented here. We use semantic versioning for releases.

Unreleased

_Note: Yet to be released changes appear here._

1.0.1

  • FIX: correct script task output mapping (#30)

1.0.0

Major release for stable versioning.

0.9.0

  • FEAT: publish ES module version of this library (#27)

0.8.0

  • FEAT: add support for zeebe:script (#25)

0.7.0

  • FEAT: allow additional extractors (#23)
  • FEAT: make extraction asynchronous (#24)

BREAKING CHANGES

The extractVariables API is now asynchronous and returns a Promise.

0.6.0

  • deps: update to min-dash@4

0.5.1

Republish of 0.5.0 with backwards compatible folder structure

0.5.0

  • FEAT: add support for Camunda Platform 8 diagrams (#20)

0.4.5

  • DEPS: drop unnecessary peer dependency entirely (2f225d33)
  • DEPS: update to min-dash@3.8.1

0.4.4

  • DEPS: update camunda-bpmn-moddle peer dependency (7c5d8e42)

0.4.3

0.4.2

  • CHORE: bump camunda-bpmn-moddle peer dependency (2759f174)

0.4.1

  • CHORE: retrieve event definitions directly without getter (90a5f6b9)

0.4.0

  • FEAT: add support for event definition variables (#9)
  • CHORE: migrate to GitHub actions

0.3.0

  • FEAT: add support for camunda:resultVariable, camunda:formField & camunda:out (#3)

0.2.0

  • FEAT: return full moddle elements instead of only ids (#2)
  • CHORE: avoid using const and let

0.1.0

  • FEAT: initial version