@5minds/node-red-contrib-processcube 0.15.0 → 1.0.0-develop-243715-lz1qpiwj
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +2 -0
- package/endevent-finished-listener.html +50 -0
- package/endevent-finished-listener.js +52 -0
- package/examples/Definition-Query-Sample.json +215 -0
- package/examples/External-Task-Sample.json +142 -1
- package/examples/Instance-Query-Sample.json +110 -0
- package/examples/User-Task-Sample.json +231 -0
- package/externaltask-error.html +11 -11
- package/externaltask-input.html +12 -12
- package/externaltask-input.js +10 -5
- package/externaltask-output.html +7 -7
- package/message-event-trigger.html +14 -2
- package/message-event-trigger.js +10 -9
- package/nodered/node-red-contrib-processcube-flows.json +364 -20
- package/nodered/settings.js +2 -1
- package/nodered/static/ProcessCube_Logo.svg +53 -0
- package/package.json +2 -1
- package/process-start.html +16 -13
- package/process-start.js +13 -8
- package/processcube-engine-config.html +16 -0
- package/processcube-engine-config.js +9 -13
- package/processdefinition-query.html +16 -2
- package/processdefinition-query.js +10 -21
- package/processes/User-Task-Sample.bpmn +57 -0
- package/processinstance-query.html +13 -2
- package/processinstance-query.js +9 -23
- package/signal-event-trigger.html +14 -2
- package/signal-event-trigger.js +9 -8
- package/usertask-finished-listener.html +15 -14
- package/usertask-finished-listener.js +16 -22
- package/usertask-input.html +15 -2
- package/usertask-input.js +18 -41
- package/usertask-new-listener.html +15 -14
- package/usertask-new-listener.js +18 -24
- package/usertask-output.html +13 -2
- package/usertask-output.js +10 -19
- package/processes/GetProcessModels.bpmn +0 -58
- package/processes/HelloWorld.bpmn +0 -124
@@ -11,6 +11,7 @@ module.exports = function (RED) {
|
|
11
11
|
const identityChangedCallbacks = [];
|
12
12
|
this.url = n.url;
|
13
13
|
this.identity = null;
|
14
|
+
|
14
15
|
this.registerOnIdentityChanged = function (callback) {
|
15
16
|
identityChangedCallbacks.push(callback);
|
16
17
|
};
|
@@ -23,22 +24,15 @@ module.exports = function (RED) {
|
|
23
24
|
}
|
24
25
|
};
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
let client = nodeContext.get('client');
|
31
|
-
|
32
|
-
if (!client) {
|
33
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
34
|
-
client = nodeContext.get('client');
|
27
|
+
node.on('close', async () => {
|
28
|
+
if (this.engineClient) {
|
29
|
+
this.engineClient.dispose();
|
30
|
+
this.engineClient = null;
|
35
31
|
}
|
36
|
-
|
37
|
-
return client;
|
38
|
-
};
|
32
|
+
});
|
39
33
|
|
40
34
|
if (this.credentials.clientId && this.credentials.clientSecret) {
|
41
|
-
|
35
|
+
this.engineClient = new engine_client.EngineClient(this.url);
|
42
36
|
|
43
37
|
engineClient.applicationInfo
|
44
38
|
.getAuthorityAddress()
|
@@ -57,6 +51,8 @@ module.exports = function (RED) {
|
|
57
51
|
console.error(reason);
|
58
52
|
node.error(reason);
|
59
53
|
});
|
54
|
+
} else {
|
55
|
+
this.engineClient = new engine_client.EngineClient(this.url);
|
60
56
|
}
|
61
57
|
}
|
62
58
|
RED.nodes.registerType('processcube-engine-config', ProcessCubeEngineNode, {
|
@@ -60,6 +60,20 @@
|
|
60
60
|
</div>
|
61
61
|
</script>
|
62
62
|
|
63
|
-
<script type="text/
|
64
|
-
|
63
|
+
<script type="text/markdown" data-help-name="processdefinition-query">
|
64
|
+
Query process definitions or process models from the ProcessCube engine.
|
65
|
+
|
66
|
+
The `query` can be given a direkt query field from the configutation or a message property.
|
67
|
+
|
68
|
+
Only models can be queried by setting the `models_only` flag.
|
69
|
+
|
70
|
+
## Inputs
|
71
|
+
|
72
|
+
: payload (Object | JSON) : Will be used as the input for the query or can be directly set as JSON.
|
73
|
+
|
74
|
+
### References
|
75
|
+
|
76
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
77
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
78
|
+
|
65
79
|
</script>
|
@@ -1,38 +1,27 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
const EventEmitter = require('node:events');
|
3
|
-
|
4
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
5
|
-
|
6
1
|
module.exports = function (RED) {
|
7
2
|
function ProcessdefinitionQuery(config) {
|
8
3
|
RED.nodes.createNode(this, config);
|
9
4
|
var node = this;
|
10
|
-
var flowContext = node.context().flow;
|
11
|
-
|
12
|
-
this.engine = this.server = RED.nodes.getNode(config.engine);
|
13
|
-
|
14
|
-
const client = this.engine.getEngineClient();
|
15
5
|
|
16
|
-
|
6
|
+
node.on('input', function (msg) {
|
17
7
|
|
18
|
-
|
19
|
-
|
20
|
-
eventEmitter = flowContext.get('emitter');
|
21
|
-
}
|
8
|
+
const engine = RED.nodes.getNode(config.engine);
|
9
|
+
const client = engine.engineClient;
|
22
10
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
11
|
+
if (!client) {
|
12
|
+
node.error('No engine configured.');
|
13
|
+
return;
|
14
|
+
}
|
27
15
|
|
28
|
-
node.on('input', function (msg) {
|
29
16
|
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
17
|
+
|
30
18
|
query = {
|
31
19
|
...query,
|
32
|
-
identity:
|
20
|
+
identity: engine.identity,
|
33
21
|
};
|
34
22
|
|
35
23
|
client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
|
24
|
+
|
36
25
|
if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
|
37
26
|
let models = [];
|
38
27
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="User-Task-Sample_Definition" targetNamespace="http://bpmn.io/schema/bpmn" exporter="5Minds Studio" exporterVersion="1">
|
3
|
+
<bpmn:collaboration id="Collaboration_1cidyxu" name="">
|
4
|
+
<bpmn:participant id="Participant_0px403d" name="User-Task-Sample" processRef="User-Task-Sample_Process" />
|
5
|
+
</bpmn:collaboration>
|
6
|
+
<bpmn:process id="User-Task-Sample_Process" name="User-Task-Sample" isExecutable="true">
|
7
|
+
<bpmn:laneSet />
|
8
|
+
<bpmn:startEvent id="StartEvent_1" name="Start">
|
9
|
+
<bpmn:outgoing>Flow_142awo6</bpmn:outgoing>
|
10
|
+
</bpmn:startEvent>
|
11
|
+
<bpmn:sequenceFlow id="Flow_142awo6" sourceRef="StartEvent_1" targetRef="user_task" />
|
12
|
+
<bpmn:endEvent id="Event_07hak5r" name="End">
|
13
|
+
<bpmn:incoming>Flow_0i7xqvi</bpmn:incoming>
|
14
|
+
</bpmn:endEvent>
|
15
|
+
<bpmn:sequenceFlow id="Flow_0i7xqvi" sourceRef="user_task" targetRef="Event_07hak5r" />
|
16
|
+
<bpmn:userTask id="user_task" name="User Task">
|
17
|
+
<bpmn:extensionElements>
|
18
|
+
<camunda:formData>
|
19
|
+
<camunda:formField id="field_01" label="Field 01" type="string" />
|
20
|
+
<camunda:formField id="field_02" label="Field 02" type="string" />
|
21
|
+
</camunda:formData>
|
22
|
+
</bpmn:extensionElements>
|
23
|
+
<bpmn:incoming>Flow_142awo6</bpmn:incoming>
|
24
|
+
<bpmn:outgoing>Flow_0i7xqvi</bpmn:outgoing>
|
25
|
+
</bpmn:userTask>
|
26
|
+
</bpmn:process>
|
27
|
+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
28
|
+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1cidyxu">
|
29
|
+
<bpmndi:BPMNShape id="Participant_0px403d_di" bpmnElement="Participant_0px403d" isHorizontal="true">
|
30
|
+
<dc:Bounds x="5" y="30" width="415" height="260" />
|
31
|
+
</bpmndi:BPMNShape>
|
32
|
+
<bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1">
|
33
|
+
<dc:Bounds x="92" y="152" width="36" height="36" />
|
34
|
+
<bpmndi:BPMNLabel>
|
35
|
+
<dc:Bounds x="98" y="195" width="24" height="14" />
|
36
|
+
</bpmndi:BPMNLabel>
|
37
|
+
</bpmndi:BPMNShape>
|
38
|
+
<bpmndi:BPMNShape id="Event_07hak5r_di" bpmnElement="Event_07hak5r">
|
39
|
+
<dc:Bounds x="332" y="152" width="36" height="36" />
|
40
|
+
<bpmndi:BPMNLabel>
|
41
|
+
<dc:Bounds x="340" y="195" width="20" height="14" />
|
42
|
+
</bpmndi:BPMNLabel>
|
43
|
+
</bpmndi:BPMNShape>
|
44
|
+
<bpmndi:BPMNShape id="Activity_0c7im8g_di" bpmnElement="user_task">
|
45
|
+
<dc:Bounds x="180" y="130" width="100" height="80" />
|
46
|
+
</bpmndi:BPMNShape>
|
47
|
+
<bpmndi:BPMNEdge id="Flow_142awo6_di" bpmnElement="Flow_142awo6">
|
48
|
+
<di:waypoint x="128" y="170" />
|
49
|
+
<di:waypoint x="180" y="170" />
|
50
|
+
</bpmndi:BPMNEdge>
|
51
|
+
<bpmndi:BPMNEdge id="Flow_0i7xqvi_di" bpmnElement="Flow_0i7xqvi">
|
52
|
+
<di:waypoint x="280" y="170" />
|
53
|
+
<di:waypoint x="332" y="170" />
|
54
|
+
</bpmndi:BPMNEdge>
|
55
|
+
</bpmndi:BPMNPlane>
|
56
|
+
</bpmndi:BPMNDiagram>
|
57
|
+
</bpmn:definitions>
|
@@ -45,6 +45,17 @@
|
|
45
45
|
</div>
|
46
46
|
</script>
|
47
47
|
|
48
|
-
<script type="text/
|
49
|
-
|
48
|
+
<script type="text/markdown" data-help-name="processinstance-query">
|
49
|
+
Query a process instance in the ProcessCube.
|
50
|
+
|
51
|
+
## Inputs
|
52
|
+
|
53
|
+
: payload (Object | JSON) : Will be used as the input for the query or can be directly set as JSON.
|
54
|
+
|
55
|
+
### References
|
56
|
+
|
57
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
58
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
59
|
+
|
60
|
+
|
50
61
|
</script>
|
package/processinstance-query.js
CHANGED
@@ -1,35 +1,21 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
const EventEmitter = require('node:events');
|
3
|
-
|
4
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
5
|
-
|
6
1
|
module.exports = function (RED) {
|
7
2
|
function ProcessinstanceQuery(config) {
|
8
3
|
RED.nodes.createNode(this, config);
|
9
4
|
var node = this;
|
10
|
-
var flowContext = node.context().flow;
|
11
|
-
|
12
|
-
this.engine = this.server = RED.nodes.getNode(config.engine);
|
13
|
-
|
14
|
-
const client = this.engine.getEngineClient();
|
15
|
-
|
16
|
-
var eventEmitter = flowContext.get('emitter');
|
17
|
-
|
18
|
-
if (!eventEmitter) {
|
19
|
-
flowContext.set('emitter', new EventEmitter());
|
20
|
-
eventEmitter = flowContext.get('emitter');
|
21
|
-
}
|
22
|
-
|
23
|
-
node.on('close', async () => {
|
24
|
-
client.dispose();
|
25
|
-
client = null;
|
26
|
-
});
|
27
5
|
|
28
6
|
node.on('input', function (msg) {
|
29
7
|
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
30
8
|
|
9
|
+
const engine = RED.nodes.getNode(config.engine);
|
10
|
+
const client = engine.engineClient;
|
11
|
+
|
12
|
+
if (!client) {
|
13
|
+
node.error('No engine configured.');
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
|
31
17
|
client.processInstances
|
32
|
-
.query(query, { identity:
|
18
|
+
.query(query, { identity: engine.identity })
|
33
19
|
.then((matchingInstances) => {
|
34
20
|
msg.payload = matchingInstances;
|
35
21
|
|
@@ -36,6 +36,18 @@
|
|
36
36
|
</div>
|
37
37
|
</script>
|
38
38
|
|
39
|
-
<script type="text/
|
40
|
-
|
39
|
+
<script type="text/markdown" data-help-name="signal-event-trigger">
|
40
|
+
A node which emmits a signal event to the Engine.
|
41
|
+
|
42
|
+
From the config the `signalname` and the `processInstanceId` must be set.
|
43
|
+
|
44
|
+
## Inputs
|
45
|
+
|
46
|
+
: payload (Object) : Will sent to the event and used an new token payload.
|
47
|
+
|
48
|
+
### References
|
49
|
+
|
50
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
51
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
52
|
+
|
41
53
|
</script>
|
package/signal-event-trigger.js
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
|
3
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
4
|
-
|
5
1
|
module.exports = function (RED) {
|
6
2
|
function SignalEventTrigger(config) {
|
7
3
|
RED.nodes.createNode(this, config);
|
8
4
|
var node = this;
|
9
5
|
|
10
|
-
|
6
|
+
node.on('input', function (msg) {
|
7
|
+
const engine = RED.nodes.getNode(config.engine);
|
11
8
|
|
12
|
-
|
9
|
+
const client = engine.engineClient;
|
13
10
|
|
14
|
-
|
11
|
+
if (!client) {
|
12
|
+
node.error('No engine configured.');
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
|
15
16
|
client.events
|
16
17
|
.triggerSignalEvent(config.signalname, {
|
17
18
|
processInstanceId: config.processinstanceid,
|
18
19
|
payload: msg.payload,
|
19
|
-
identity:
|
20
|
+
identity: engine.identity,
|
20
21
|
})
|
21
22
|
.then((result) => {
|
22
23
|
msg.payload = result;
|
@@ -25,20 +25,21 @@
|
|
25
25
|
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
26
26
|
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
27
27
|
</div>
|
28
|
-
<div class="form-row" style="display:flex; margin-bottom: 3px;">
|
29
|
-
<label for="node-input-multisend" style="vertical-align:top"><i class="fa fa-list-alt"></i> Send multi</label>
|
30
|
-
<div>
|
31
|
-
<input
|
32
|
-
type="checkbox"
|
33
|
-
checked
|
34
|
-
id="node-input-multisend"
|
35
|
-
style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;"
|
36
|
-
/>
|
37
|
-
<label style="width:auto" for="node-input-multisend">Send one output of each usertask input?</label>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
28
|
</script>
|
41
29
|
|
42
|
-
<script type="text/
|
43
|
-
|
30
|
+
<script type="text/markdown" data-help-name="usertask-finished-listener">
|
31
|
+
A node which listens for finished usertasks in the ProcessCube.
|
32
|
+
|
33
|
+
## Outputs
|
34
|
+
|
35
|
+
: flowNodeInstanceId (string): The flow node instance id of the finished usertask.
|
36
|
+
: userTaskEvent (object): The user task event object.
|
37
|
+
: action (string): The action of the event.
|
38
|
+
: type (string): The type of the event.
|
39
|
+
|
40
|
+
### References
|
41
|
+
|
42
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
43
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
44
|
+
|
44
45
|
</script>
|
@@ -1,32 +1,25 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
const EventEmitter = require('node:events');
|
3
|
-
|
4
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
5
|
-
|
6
1
|
module.exports = function (RED) {
|
7
2
|
function UserTaskFinishedListener(config) {
|
8
3
|
RED.nodes.createNode(this, config);
|
9
4
|
var node = this;
|
10
|
-
|
11
|
-
|
12
|
-
this.engine = this.server = RED.nodes.getNode(config.engine);
|
13
|
-
|
14
|
-
const client = this.engine.getEngineClient();
|
5
|
+
node.engine = RED.nodes.getNode(config.engine);
|
15
6
|
|
16
|
-
|
7
|
+
const register = async () => {
|
8
|
+
let currentIdentity = node.engine.identity;
|
17
9
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
const client = node.engine.engineClient;
|
11
|
+
|
12
|
+
if (!client) {
|
13
|
+
node.error('No engine configured.');
|
14
|
+
return;
|
15
|
+
}
|
22
16
|
|
23
|
-
const register = async () => {
|
24
|
-
let currentIdentity = node.server.identity;
|
25
17
|
let subscription = await client.userTasks.onUserTaskFinished(
|
26
18
|
(userTaskFinishedNotification) => {
|
27
19
|
node.send({
|
28
20
|
payload: {
|
29
21
|
flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
|
22
|
+
userTaskEvent: userTaskFinishedNotification,
|
30
23
|
action: 'finished',
|
31
24
|
type: 'usertask',
|
32
25
|
},
|
@@ -35,7 +28,7 @@ module.exports = function (RED) {
|
|
35
28
|
{ identity: currentIdentity },
|
36
29
|
);
|
37
30
|
|
38
|
-
node.
|
31
|
+
node.engine.registerOnIdentityChanged(async (identity) => {
|
39
32
|
client.userTasks.removeSubscription(subscription, currentIdentity);
|
40
33
|
currentIdentity = identity;
|
41
34
|
|
@@ -44,6 +37,7 @@ module.exports = function (RED) {
|
|
44
37
|
node.send({
|
45
38
|
payload: {
|
46
39
|
flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
|
40
|
+
userTaskEvent: userTaskFinishedNotification,
|
47
41
|
action: 'finished',
|
48
42
|
type: 'usertask',
|
49
43
|
},
|
@@ -54,13 +48,13 @@ module.exports = function (RED) {
|
|
54
48
|
});
|
55
49
|
|
56
50
|
node.on('close', async () => {
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
if (node.engine && node.engine.engineClient && client) {
|
52
|
+
client.userTasks.removeSubscription(subscription, currentIdentity);
|
53
|
+
}
|
60
54
|
});
|
61
55
|
};
|
62
56
|
|
63
|
-
if (node.
|
57
|
+
if (node.engine) {
|
64
58
|
register();
|
65
59
|
}
|
66
60
|
}
|
package/usertask-input.html
CHANGED
@@ -75,6 +75,19 @@
|
|
75
75
|
</div>
|
76
76
|
</script>
|
77
77
|
|
78
|
-
<script type="text/
|
79
|
-
|
78
|
+
<script type="text/markdown" data-help-name="usertask-input">
|
79
|
+
A node which sends a payload to a usertask in the ProcessCube.
|
80
|
+
|
81
|
+
## Inputs
|
82
|
+
|
83
|
+
: payload (Object) : Will be used as the input for the usertask.
|
84
|
+
: query (String) : Will be used as the query for the usertask.
|
85
|
+
: query_type (String) : Will be used as the type of the query for the usertask.
|
86
|
+
: force_send_array (Boolean) : Will be used to force the payload to be sent as an array.
|
87
|
+
: multisend (Boolean) : Will be used to send one output of each usertask input.
|
88
|
+
|
89
|
+
### References
|
90
|
+
|
91
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
92
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
80
93
|
</script>
|
package/usertask-input.js
CHANGED
@@ -1,53 +1,26 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
const EventEmitter = require('node:events');
|
3
|
-
|
4
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
5
|
-
|
6
|
-
function showStatus(node, msgCounter) {
|
7
|
-
if (msgCounter >= 1) {
|
8
|
-
node.status({
|
9
|
-
fill: 'blue',
|
10
|
-
shape: 'dot',
|
11
|
-
text: `handling tasks ${msgCounter}`,
|
12
|
-
});
|
13
|
-
} else {
|
14
|
-
node.status({
|
15
|
-
fill: 'blue',
|
16
|
-
shape: 'ring',
|
17
|
-
text: `subcribed ${msgCounter}`,
|
18
|
-
});
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
1
|
module.exports = function (RED) {
|
23
2
|
function UserTaskInput(config) {
|
24
3
|
RED.nodes.createNode(this, config);
|
25
4
|
var node = this;
|
26
|
-
var msgCounter = 0;
|
27
|
-
var flowContext = node.context().flow;
|
28
5
|
|
29
|
-
|
30
|
-
|
31
|
-
const client = this.engine.getEngineClient();
|
6
|
+
node.on('input', function (msg) {
|
32
7
|
|
33
|
-
|
8
|
+
const engine = RED.nodes.getNode(config.engine);
|
34
9
|
|
35
|
-
|
36
|
-
flowContext.set('emitter', new EventEmitter());
|
37
|
-
eventEmitter = flowContext.get('emitter');
|
38
|
-
}
|
10
|
+
const client = engine.engineClient;
|
39
11
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
12
|
+
if (!client) {
|
13
|
+
node.error('No engine configured.');
|
14
|
+
return;
|
15
|
+
}
|
44
16
|
|
45
|
-
node.on('input', function (msg) {
|
46
17
|
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
18
|
+
|
47
19
|
query = {
|
48
20
|
...query,
|
49
|
-
identity:
|
21
|
+
identity: engine.identity,
|
50
22
|
};
|
23
|
+
|
51
24
|
client.userTasks.query(query).then((matchingFlowNodes) => {
|
52
25
|
if (
|
53
26
|
!config.force_send_array &&
|
@@ -67,10 +40,14 @@ module.exports = function (RED) {
|
|
67
40
|
node.send(msg);
|
68
41
|
});
|
69
42
|
} else {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
43
|
+
if (matchingFlowNodes.userTasks == 1) {
|
44
|
+
msg.payload = {
|
45
|
+
userTasks: matchingFlowNodes.userTasks,
|
46
|
+
};
|
47
|
+
node.send(msg);
|
48
|
+
} else {
|
49
|
+
node.log(`No user tasks found for query: ${JSON.stringify(query)}`);
|
50
|
+
}
|
74
51
|
}
|
75
52
|
} else {
|
76
53
|
msg.payload = {
|
@@ -25,20 +25,21 @@
|
|
25
25
|
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
26
26
|
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
27
27
|
</div>
|
28
|
-
<div class="form-row" style="display:flex; margin-bottom: 3px;">
|
29
|
-
<label for="node-input-multisend" style="vertical-align:top"><i class="fa fa-list-alt"></i> Send multi</label>
|
30
|
-
<div>
|
31
|
-
<input
|
32
|
-
type="checkbox"
|
33
|
-
checked
|
34
|
-
id="node-input-multisend"
|
35
|
-
style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;"
|
36
|
-
/>
|
37
|
-
<label style="width:auto" for="node-input-multisend">Send one output of each usertask input?</label>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
28
|
</script>
|
41
29
|
|
42
|
-
<script type="text/
|
43
|
-
|
30
|
+
<script type="text/markdown" data-help-name="usertask-new-listener">
|
31
|
+
A node which listens for new usertasks in the ProcessCube.
|
32
|
+
|
33
|
+
## Outputs
|
34
|
+
|
35
|
+
: flowNodeInstanceId (string): The flow node instance id of the new usertask.
|
36
|
+
: userTaskEvent (string) : The user task event object.
|
37
|
+
: action (string) : The action of the event.
|
38
|
+
: type (string) : The type of the event.
|
39
|
+
|
40
|
+
### References
|
41
|
+
|
42
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
43
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
44
|
+
|
44
45
|
</script>
|
package/usertask-new-listener.js
CHANGED
@@ -1,33 +1,26 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
const EventEmitter = require('node:events');
|
3
|
-
|
4
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
5
|
-
|
6
1
|
module.exports = function (RED) {
|
7
2
|
function UserTaskNewListener(config) {
|
8
3
|
RED.nodes.createNode(this, config);
|
9
4
|
var node = this;
|
10
|
-
|
11
|
-
|
12
|
-
this.engine = this.server = RED.nodes.getNode(config.engine);
|
13
|
-
|
14
|
-
const client = this.engine.getEngineClient();
|
5
|
+
node.engine = RED.nodes.getNode(config.engine);
|
15
6
|
|
16
|
-
|
7
|
+
const register = async () => {
|
8
|
+
const client = node.engine.engineClient;
|
17
9
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
if (!client) {
|
11
|
+
node.error('No engine configured.');
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
|
15
|
+
let currentIdentity = node.engine.identity;
|
22
16
|
|
23
|
-
const register = async () => {
|
24
|
-
let currentIdentity = node.server.identity;
|
25
17
|
let subscription = await client.userTasks.onUserTaskWaiting(
|
26
18
|
(userTaskWaitingNotification) => {
|
27
19
|
node.send({
|
28
20
|
payload: {
|
29
21
|
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
30
|
-
|
22
|
+
userTaskEvent: userTaskWaitingNotification,
|
23
|
+
action: 'new',
|
31
24
|
type: 'usertask',
|
32
25
|
},
|
33
26
|
});
|
@@ -35,7 +28,7 @@ module.exports = function (RED) {
|
|
35
28
|
{ identity: currentIdentity },
|
36
29
|
);
|
37
30
|
|
38
|
-
node.
|
31
|
+
node.engine.registerOnIdentityChanged(async (identity) => {
|
39
32
|
client.userTasks.removeSubscription(subscription, currentIdentity);
|
40
33
|
currentIdentity = identity;
|
41
34
|
|
@@ -44,6 +37,7 @@ module.exports = function (RED) {
|
|
44
37
|
node.send({
|
45
38
|
payload: {
|
46
39
|
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
40
|
+
userTaskEvent: userTaskWaitingNotification,
|
47
41
|
action: 'new',
|
48
42
|
type: 'usertask',
|
49
43
|
},
|
@@ -53,14 +47,14 @@ module.exports = function (RED) {
|
|
53
47
|
);
|
54
48
|
});
|
55
49
|
|
56
|
-
node.on('close',
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
node.on('close', () => {
|
51
|
+
if (node.engine && node.engine.engineClient && client) {
|
52
|
+
client.userTasks.removeSubscription(subscription, currentIdentity);
|
53
|
+
}
|
60
54
|
});
|
61
55
|
};
|
62
56
|
|
63
|
-
if (node.
|
57
|
+
if (node.engine) {
|
64
58
|
register();
|
65
59
|
}
|
66
60
|
}
|
package/usertask-output.html
CHANGED
@@ -45,6 +45,17 @@
|
|
45
45
|
</div>
|
46
46
|
</script>
|
47
47
|
|
48
|
-
<script type="text/
|
49
|
-
|
48
|
+
<script type="text/markdown" data-help-name="usertask-output">
|
49
|
+
A node which sends the result of a usertask to the ProcessCube.
|
50
|
+
|
51
|
+
## Inputs
|
52
|
+
|
53
|
+
: payload (Object | JSON) : Will be used as the result for the usertask or can be directly set as JSON.
|
54
|
+
: payload.usertask.flowNodeInstanceId (String) : The flowNodeInstanceId of the usertask that will be finished.
|
55
|
+
|
56
|
+
### References
|
57
|
+
|
58
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
59
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
60
|
+
|
50
61
|
</script>
|