3.0.1 • Published 3 years ago

@opuscapita/fsm-workflow-history v3.0.1

Weekly downloads
16
License
Apache-2.0
Repository
github
Last release
3 years ago

Workflow History

badge-npm-version NPM Downloads

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

Installation

Install package

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

Basic Usage

// Run migrations and initiate an instance of FSM Workflow History.
const history = await require('@opuscapita/fsm-workflow-history')(sequelize);

history is JavaScript object with the following structure/interface:

{
  // add history record
  async add({
    from: <string>,
    to: <string>,
    event: <string>,
    businessObjType: <string>,
    businessObjId: <string>,
    user: <string>,
    workflowName: <string>,
    ?description: <string>
  }) {
    ...
    return <History Record>;
  },

  // search for history record
  async search({
      ?object: {
        ?businessObjType: <string>, // example: 'invoice'
        ?businessObjId: <string> // example: 'john.miller'
      },
      ?user: <string>,
      ?workflowName: <string>,
      ?finishedOn: {
        ?gt: <date>, // example: new Date("2018-03-05T21:00:00.000Z")
        ?gte: <date>,
        ?lt: <date>,
        ?lte: <date>
      }
  }, {
      ?max: <number, 100 by default>,
      ?offset: <number, 0 by default>
  }, {
      ?by: <string, History Record field name, "finishedOn" by default>, // example: 'user'
      ?order: <string, "desc" (default) or "asc">
  }) {
    ...
    return [<History Record>, ... ];
  }

  // delete history record
  async delete({
    businessObjType: <string>,
    businessObjId: <string>,
  }) {
    ...
    return <deleted records number>;
  },

}

History Record is JavaScript object with values from DB:

ColumnTypeRequiredNotes
idintegertrueautogenerated id
fromstringtrue
tostringtrue
eventstringtrue
businessObjTypestringtrueexample: 'invoice'
businessObjIdstringtrueexample: '123456789'
userstringtrueuser initiated a transition
workflowNamestringtrueunique workflow name, known by workflow machine
descriptionstringfalseevent/object/trsnaition information
finishedOntimestamptruelike in Grailsflow, object finished the transition in 'to' state

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

3.0.1

3 years ago

3.0.0

3 years ago

2.2.10

4 years ago

2.2.9

4 years ago

2.2.8

5 years ago

2.2.7

5 years ago

2.2.6

5 years ago

2.2.5

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.5

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago

1.0.1

6 years ago