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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bpm-engine

v1.1.13

Published

Business Process Management Engine for JavaScript

Downloads

10

Readme

BPM Engine

Build Status Test Coverage Maintainability

BPM Engine is a BPMN workflow execution engine written in JavaScript.

Install and use

$ npm install bpm-engine --save

Use the BPM Engine with Node.JS or in your favourite Browser.

Start a processInstance

const BPMEngine = require('bpm-engine');

// Instantiate an engine
const bpm = new BPMEngine();

// Create a new process instance, specify a valid bpmn definition (returns a token)
const token = await bpm
  .createProcessInstance({
    workflowDefinition: 'valid bpmn'
  })
  .catch(console.error);

// Tell the initial token to continue execution
await token.execute().catch(console.error);

Continue execution of a processInstance (by token)

// At some later point in time, in a different part of
// your app (e.g. when a User task is handled as complete by your own app)
const token = await bpm.continueTokenInstance({
  tokenId: '<id of the token you want to execute>',
  // set the payload you want to merge into the existing payload
  payload: {}
});

await token.execute().catch(console.error);

Currently supported flow objects

Events:

  • [x] Start
  • [x] End
  • [ ] IntermediateThrow
  • [ ] MessageIntermediateThrow
  • [ ] MessageIntermediateCatch
  • [ ] MessageEnd
  • [x] TimerIntermediateCatch
  • [ ] EscalationIntermediateThrow
  • [ ] EscalationEnd
  • [ ] ErrorEnd
  • [ ] ConditionalIntermediateThrow
  • [ ] LinkIntermediateCatch
  • [ ] LinkIntermediateThrow
  • [ ] CompensationIntermediateThrow
  • [ ] CompensationEnd
  • [ ] SignalIntermediateThrow
  • [ ] SignalIntermediateCatch
  • [ ] MessageStart
  • [x] TimerStart
  • [ ] ConditionalStart
  • [ ] SignalStart
  • [ ] SignalEnd
  • [ ] TerminateEnd

Activities:

  • [x] Task
  • [x] Service
  • [x] User
  • [x] Manual
  • [ ] Send
  • [ ] Receive
  • [ ] BusinessRule
  • [x] Script

Gateways:

  • [x] Exclusive
  • [x] Inclusive
  • [x] Parallel
  • [ ] EventBased
  • [ ] Complex

Other:

  • [x] Swimlanes
  • [ ] CallActivity
  • [x] SubProcess
  • [x] Loop
  • [x] ParallelMultiInstance
  • [ ] SequentialMultiInstance

Persistency layer

You can install the following package to add a persistency layer to the state of your processes.

  • bpm-engine-persist-mongoose

Use one of the persistency plugins in the BPM Engine:

const BPMEngine = require('bpm-engine');
const PersistMongoose = require('bpm-engine-persist-mongoose');

const persistMongoose = new PersistMongoose(
  '<mongodb:url>',
  mongooseConnectionOptions
);

const engine = new BPMEngine({
  persist: persistMongoose
});

Develop your own plugins

Currently you can develop plugins for the following elements:

  • Element
  • UserTask
  • ServiceTask

You create plugins by extending from one of the above classes and instantiating a class into the plugins array when instantiating the engine.

const BPMEngine = require('bpm-engine');

class History extends BPMEngine.Plugins.Element {
  constructor({ store = [] } = {}) {
    super();
    this.store = store;
  }

  onReady = definition => {
    this.store.push({ state: 'ready', elementId: definition.id });
  };
  onActive = definition => {
    this.store.push({ state: 'active', elementId: definition.id });
  };
  onComplete = definition => {
    this.store.push({ state: 'complete', elementId: definition.id });
  };
}

const history = new History();

const engine = new BPMEngine({ plugins: [history] });

The above plugin will push executed element's id's into an array, which serves as some kind of log.

Plugin methods

Every plugin can make use of three methods which will be called in order of execution, onReady, onActive and onComplete.

Method arguments

Methods receive the definition (as a moddle reference) of the current activity and the processInstance (including its .payload) as arguments. Read more about creating plugins here (... link missing...).