1.1.13 • Published 5 years ago

bpm-engine v1.1.13

Weekly downloads
105
License
-
Repository
-
Last release
5 years ago

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:

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

Activities:

  • Task
  • Service
  • User
  • Manual
  • Send
  • Receive
  • BusinessRule
  • Script

Gateways:

  • Exclusive
  • Inclusive
  • Parallel
  • EventBased
  • Complex

Other:

  • Swimlanes
  • CallActivity
  • SubProcess
  • Loop
  • 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...).

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.0

6 years ago