npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bpmn-io/variable-resolver

v3.0.0

Published

bpmn-js plugin for handling external variable providers

Downloads

48,066

Readme

@bpmn-io/variable-resolver

CI

An extension for bpmn-js that makes the data model of the diagram available to other components.

[!NOTE] As of version v3 this library exposes both written and consumed variables, you can filter them via options.

Usage

To add the variable resolver to you application, add it to your bpmn-js configuration:

import BpmnModeler from 'bpmn-js/lib/Modeler';
import ZeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe';

import {
  ZeebeVariableResolverModule,     // For Camunda 8 diagrams
  // CamundaVariableResolverModule // for Camunda 7 diagrams
} from '@bpmn-io/variable-resolver';

const modeler = new BpmnModeler({
  container: '#canvas',
  additionalModules: [
    ZeebeVariableResolverModule
  ],
  moddleExtensions = {
    zeebe: ZeebeModdle
  }
});

Retrieving variables

Retrieve the variables from a diagram using the variableResolver service:

const variableResolver = modeler.get('variableResolver');
const elementRegistry = modeler.get('elementRegistry');

// retrieve variables relevant to an element
const task = elementRegistry.get('Task_1');

// default: variables relevant to <task> in its visible scopes
await variableResolver.getVariablesForElement(task);

// variables read by <task> only
await variableResolver.getVariablesForElement(task, {
  read: true,
  written: false
});

// all variables written by <task>
await variableResolver.getVariablesForElement(task, { written: true, read: false });

// local variables only (scope === queried element)
await variableResolver.getVariablesForElement(task, {
  local: true,
  external: false
});

// non-local variables only (scope !== queried element)
await variableResolver.getVariablesForElement(task, {
  local: false,
  external: true
});

// retrieve all variables defined in a process
const processElement = elementRegistry.get('Process_1');

// returns all variables for the process (unfiltered), for local processing
await variableResolver.getProcessVariables(processElement);

getVariablesForElement(element, options) supports five filter switches:

| Option | Default | Description | | --- | --- | --- | | read | true | Include variables consumed by the queried element | | written | true | Include variables written/created by the queried element | | local | true | Include variables local to the queried element scope | | external | true | Include variables outside the queried element scope | | outputMappings | true | Count output-mapping reads as reads |

Adding a variable extractor

To add your own variables, extend the variableProvider class in your extension. It only needs to implement the getVariables method, which takes an element as an argument and returns an array of variables you want to add to the scope of the element. The function can be asynchronous.

// MyExtension.js
import VariableProvider from '@bpmn-io/variable-resolver/lib/VariableProvider';

class MyCustomProvider extends VariableProvider {
  getVariables(element) {
    const variables = [
      {
        name: 'myVariable',
        type: 'String',
        info: 'This is a global variable'
      }
    ];
      if (is(element, 'bpmn:Process')) {
      return variables;
    }
  }
}

export const MyExtension = {
  __init__: [
    'myCustomProvider',
  ],
  myCustomProvider: [ 'type', MyCustomProvider ],
};

Advanced use-cases

By default, getVariablesForElement and getProcessVariables merge variables with the same name and scope into one - entry structure and types are mixed in the merged representation.

In some cases, you might want access to the raw data, e.g. to run lint rules to detect potential schema mismatches between providers. For this, you can use getRawVariables:

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

const raw = await variableResolver.getRawVariables();

/**
 * raw = {
 *  'Process_1': [
 *    {
 *     name: 'myVariable',
 *     type: 'String',
 *     scope: 'Process_1',
 *     origin: [ 'Task_1' ]
 *    },
 *    {
 *     name: 'myVariable',
 *     type: 'Number',  // Same Variable with different types
 *     scope: 'Process_1',
 *     origin: [ 'Task_2' ]
 *    }
 *  ]
 * }
 */

Development

Prepare the project by installing all dependencies:

npm install

Then, start the example with:

npm start

License

MIT