🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@opuscapita/fsm-workflow-transition-history

Package Overview
Dependencies
Maintainers
21
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opuscapita/fsm-workflow-transition-history

Business-object history for FSM workflow

latest
npmnpm
Version
0.0.4
Version published
Maintainers
21
Created
Source

Workflow Transition History

badge-npm-version NPM Downloads

Workflow Transition History is an extension to FSM Core. It provies server-side API for storing and extracting Business Object lifecycle history.

Installation

Install package

npm install --save @opuscapita/fsm-workflow-transition-history

Basic Usage

const Sequelize = require('sequelize');
const workflowTransitionHistory = require('@opuscapita/fsm-workflow-transition-history');
const dbConfig = require('./config/db.js');

const sequelize = new Sequelize(dbConfig);

workflowTransitionHistory.runMigrations(sequelize).
  then(_ => workflowTransitionHistory.createModel(sequelize)).
  then(handlers => {
    const { add, search } = handlers;

    add({
      from: 'from-state',
      to: 'to-state',
      event: 'transition-event',
      businessObjType: 'invoice',
      businessObjId: 'ew153-7210',
      user: 'user-id-46270e',
      description: 'Optional business object transition description text'
    }).
      then(obj => console.log('The following obj has been added to history:', obj)).
      catch(err => console.error('Error adding obj to histofy:', err));

    search({

      // Optional.
      // Its format is the same as "where" in sequelize.model().findAll
      where: {
        from: 'from-state',
        to: 'to-state'
      },

      // Optional.
      // Its format is the same as "order" in sequelize.model().findAll
      order: [["createdOn","ASC"]]

    }).
      then(objList => console.log(objList.map(obj => JSON.stringify({
        id: obj.id,
        from: obj.from,
        to: obj.to,
        event: obj.event,
        businessObjType: obj.businessObjType,
        businessObjId: obj.businessObjId,
        user: obj.user,
        description: obj.description,
        createdOn: obj.createdOn
      })))).
      catch(err => console.error('Error extracting objects from history:', err));
  });

See Express Server Demo for an example of using Workflow Transition History.

FAQs

Package last updated on 05 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts