What’s NodeJS Workflow Engine
As we all know, as a backend development language and runtime environment, NodeJS is good in everything, but only missing a NodeJS workflow engine
. CabloyJS 4.0 focuses on the development of NodeJS Workflow Engine
, and as a built-in basic core module, it further expands the application scenarios of NodeJS in the backend and provides basic support for the in-depth research and development of various business business logic
Features of NodeJS workflow engine
- Easier configuration: Use
JSON
to configure the process definition, bid farewell to the complexity of XML configuration files - Workflow Definition: Support historical revision, support enable/disable
- Clearer architecture: Three core modules are used to implement the architecture of the workflow engine with a layered mechanism, so that the workflow is no longer mysterious
Module Name | Description |
---|---|
a-flow | Flow Definition, Flow Instance |
a-flownode | Flow Node(Activity Node) |
a-flowtask | Flow Task |
- Support
Business Process
andApproval Process
- Combined with
Atom Stages
, a set of Atom-basedapproval workflow
is built in. See also: Atom Stages - Combined with
Form Validation
, it supports configuringread field permissions
andwrite field permissions
of different flow nodes. See also: Form Validation - The workflow logic can be customized through the
AOP
mechanism - The workflow logic can be customized through the
Listener
mechanism - Open architecture supports more customized development of
flow nodes
- Contains a lot of
test-driven
code, you can quickly use the workflow
Demo
- Create a new draft:
Purchase Order
- Select
Flow Definition
, thenSubmit
, while the draft will enter the correspondingflow process
- Claim and Handle the
Review
task - The flow process ends and the draft is converted to
Formal
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',
},
],
},
}
Name | Description |
---|---|
listener | Monitor various events of flow/node/task |
process.nodes | Flow Nodes |
process.nodes.type | Type of flow node |
process.edges | Transitions |
process.edges.source | Incoming Transitions |
process.edges.target | Outgoing Transitions |
An approval flow 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: 'endEventAtom',
},
],
edges: [
{
id: 'edge_1',
source: 'startEvent_1',
target: 'activity_1',
},
{
id: 'edge_2',
source: 'activity_1',
target: 'endEvent_1',
},
],
},
}
- process.nodes.type
Name | Description |
---|---|
startEventAtom | Start Event (Draft) : Binding to the specified Atom Class through options.atom and options.conditionExpression . Automatically start the matching workflow definition when the specified Atom is submitted |
activityUserTask | User Task : Can specify participants, whether to bid, completion conditions, read field permissions, write field permissions, etc. |
endEventAtom | End Event: Atom Submit |
Comments: