preface

NodeJS as a back-end development language and runtime environment is known to have everything but a NodeJS workflow engine. CabloyJS 4.0 focuses on the development of NodeJS workflow engine, and as the built-in basic core module, further expands the application scenarios of NodeJS in the back end, and provides the basic support for in-depth research and development of various commercial business logic

NodeJS workflow engine features

  1. Easier configuration: adoptJSONConfigure process definitions without the clutter of XML configuration files
  2. Process definition: Historical version support, enable/disable support
  3. Clearer architecture: using three core modules to realize the architecture of workflow engine with layered mechanism, so that workflow is no longer mysterious, source code is no longer stacked
The name of the module instructions
a-flow Process definition, process instance
a-flownode Process node (Active node)
a-flowtask Process tasks
  1. supportThe business processandApproval process
  2. withAtom has lived three livesIn combination, there is a built-in set of Atom-basedApproval workflow. See also:Atomic Stage (Three Lives three Times)
  3. withForm validationCombined to support the configuration of different process nodesRead field permissionsandModifying field Permissions. See also:Form validation
  4. throughAOPMechanism custom workflow logic
  5. throughListenerMechanism custom workflow logic
  6. Open architecture with more supportProcess nodeCustom development of
  7. Contains a large number ofTest driveCode, can quickly get started using workflow

Workflow demo

  1. Create a new draft:The purchase order
  2. Choose what to useThe process definitionAnd then submit the draft into the correspondingApproval process
  3. Sign in and process tasks
  4. The process ends and the draft becomesThe archive

A minimal workflow definition

src/module/test-flow/backend/src/config/static/flowDef/set00_simple.js

  {
    listener: null.process: {
      nodes: [{id: 'startEvent_1'.name: 'Start'.type: 'startEventNone'}, {id: 'endEvent_1'.name: 'End'.type: 'endEventNone'],},edges: [{id: 'edge_1'.source: 'startEvent_1'.target: 'endEvent_1',},],},}Copy the code
The name of the instructions
listener Listener for flow/ Node /task events
process.nodes Process node
process.nodes.type Process node type
process.edges Flow transfer line
process.edges.source source
process.edges.target where

An approval process definition

src/module/test-flow/backend/src/config/static/flowDef/set01_atomUserTask.js

  {
    listener: null.process: {
      nodes: [{id: 'startEvent_1'.name: 'Drafting'.type: 'startEventAtom'.options: {
            atom: {
              module: moduleInfo.relativeName,
              atomClassName: 'purchaseOrder',},conditionExpression: 'atom._flowDefKey===\'set01_atomUserTask\'',}}, {id: 'activity_1'.name: 'Review'.type: 'activityUserTask'.options: {
            assignees: {
              / / users: '1, 2',
              / / roles: '1, 2',
              vars: 'flowUser',},confirmation: false.bidding: false.completionCondition: {
              // passed: 1,
              // rejected: '100%',
            },
            // rejectedNode:null,
            // allowRejectTask: true,
            // allowCancelFlow: false,
            schema: {
              write: [
                'atomName',
                {
                  name: 'description'.property: {
                    type: 'string'.ebType: 'text'.ebTitle: 'Description',},},],},},}, {id: 'endEvent_1'.name: 'End'.type: 'endEventNone'],},edges: [{id: 'edge_1'.source: 'startEvent_1'.target: 'activity_1'}, {id: 'edge_2'.source: 'activity_1'.target: 'endEvent_1',},],},}Copy the code
  • process.nodes.type
The name of the instructions
startEventAtom Start event node (draft): through the options. The atom and the options. ConditionExpression and specify the type of the atom binding. The matching workflow definition is automatically started when the specified Atom is submitted
activityUserTask User task node: You can specify the participant, whether to register, completion condition, read field permission, write field permission, and so on
endEventNone End Event node

A link to the

  • Website: https://cabloy.com/
  • GitHub: https://github.com/zhennann/cabloy