@bpmn-io/extract-process-variables

中文文档
2.2.1发布于 2026/02/27MITES Module近 30 天下载 24.5万

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

原始使用文档
文档目录8 节
  1. Installation
  2. Usage
  3. Camunda Platform 7
  4. Properties support
  5. Camunda Platform 7
  6. Camunda Platform 8
  7. See also
  8. License

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

版本与发布记录

@bpmn-io/extract-process-variables 共发布 26 个版本,首次发布于 2020/08/10;过去 12 个月发布了 9 个版本。

版本发布日期距今
2.2.1latest2026/02/278 个月前
2.2.02026/02/268 个月前
2.1.12026/02/238 个月前
2.2.0-rc.3preview2026/02/228 个月前
2.2.0-rc.22026/02/228 个月前
2.2.0-rc.12026/02/218 个月前

关于 @bpmn-io/extract-process-variables 的常见问题

@bpmn-io/extract-process-variables 是什么?

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

如何安装 @bpmn-io/extract-process-variables?

在项目目录运行 npm install @bpmn-io/extract-process-variables,或使用 pnpm add / yarn add / bun add。

@bpmn-io/extract-process-variables 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bpmn-io__extract-process-variables 是否存在。

@bpmn-io/extract-process-variables 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bpmn-io/extract-process-variables 可以商用吗?

@bpmn-io/extract-process-variables 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bpmn-io/extract-process-variables 的下载量有多少?

根据 npm 官方下载统计,@bpmn-io/extract-process-variables 在 2026/10/09 – 2026/11/07 这 30 天内被下载 244,545 次,日均约 8,152 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bpmn-io/extract-process-variables 还在维护吗?

最新版本 2.2.1 发布于 2026/02/27(8 个月前);至今共发布 26 个版本,其中过去 12 个月发布了 9 个;首次发布于 2020/08/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。