@5minds/node-red-contrib-processcube 0.11.0-feature-1a3680-lyc1y00u → 0.11.0-feature-34fec2-lydislpd
Sign up to get free protection for your applications and to get access to all the features.
@@ -2785,6 +2785,7 @@
|
|
2785
2785
|
"engine": "d042a4c68f51d6ab",
|
2786
2786
|
"query": "{\"flowNodeId\":\"PlaceAnOrderUserTask\"}",
|
2787
2787
|
"query_type": "json",
|
2788
|
+
"only_for_new": true,
|
2788
2789
|
"x": 350,
|
2789
2790
|
"y": 160,
|
2790
2791
|
"wires": [
|
@@ -2845,8 +2846,8 @@
|
|
2845
2846
|
"z": "0825fee24edbf04b",
|
2846
2847
|
"name": "",
|
2847
2848
|
"pauseType": "delay",
|
2848
|
-
"timeout": "
|
2849
|
-
"timeoutUnits": "
|
2849
|
+
"timeout": "5",
|
2850
|
+
"timeoutUnits": "seconds",
|
2850
2851
|
"rate": "1",
|
2851
2852
|
"nbRateUnits": "1",
|
2852
2853
|
"rateUnits": "second",
|
@@ -2856,7 +2857,7 @@
|
|
2856
2857
|
"drop": false,
|
2857
2858
|
"allowrate": false,
|
2858
2859
|
"outputs": 1,
|
2859
|
-
"x":
|
2860
|
+
"x": 340,
|
2860
2861
|
"y": 240,
|
2861
2862
|
"wires": [
|
2862
2863
|
[
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@5minds/node-red-contrib-processcube",
|
3
|
-
"version": "0.11.0-feature-
|
3
|
+
"version": "0.11.0-feature-34fec2-lydislpd",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"authors": [
|
@@ -45,7 +45,7 @@
|
|
45
45
|
"UserTaskFinishedListener": "usertask-finished-listener.js",
|
46
46
|
"UserTaskInput": "usertask-input.js",
|
47
47
|
"UserTaskOutput": "usertask-output.js",
|
48
|
-
"WaitForUsertask": "
|
48
|
+
"WaitForUsertask": "wait-for-usertask.js"
|
49
49
|
}
|
50
50
|
},
|
51
51
|
"dependencies": {
|
@@ -6,7 +6,8 @@
|
|
6
6
|
name: {value: ""},
|
7
7
|
engine: {value: "", type: "processcube-engine-config"},
|
8
8
|
query: {value: "payload"},
|
9
|
-
query_type: {value: "msg"}
|
9
|
+
query_type: {value: "msg"},
|
10
|
+
only_for_new: {value: false}
|
10
11
|
},
|
11
12
|
inputs: 1,
|
12
13
|
outputs: 1,
|
@@ -44,6 +45,13 @@
|
|
44
45
|
<label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
|
45
46
|
<input type="text" id="node-input-query">
|
46
47
|
</div>
|
48
|
+
<div class="form-row" style="display:flex; margin-bottom: 3px;">
|
49
|
+
<label for="node-input-only_for_new" style="vertical-align:top"><i class="fa fa-list-alt"></i> Only for new</label>
|
50
|
+
<div>
|
51
|
+
<input type="checkbox" checked id="node-input-only_for_new" style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;">
|
52
|
+
<label style="width:auto" for="node-input-multisend">Trigger only for new user task or *checked* also for old ones?</label>
|
53
|
+
</div>
|
54
|
+
</div>
|
47
55
|
</script>
|
48
56
|
|
49
57
|
<script type="text/markdown" data-help-name="wait-for-usertask">
|
@@ -59,7 +67,8 @@ Waiting for Usertasks of the connected ProcessCube Engine.
|
|
59
67
|
|
60
68
|
### Details
|
61
69
|
|
62
|
-
`msg.payload` or a constant json to filter the UserTasks for Waiting for
|
70
|
+
- `msg.payload` or a constant json to filter the UserTasks for Waiting for
|
71
|
+
- `Only for new` will trigger only for new UserTasks if checked and also for old ones if not checked.
|
63
72
|
|
64
73
|
### References
|
65
74
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
const process = require('process');
|
2
|
+
|
3
|
+
const engine_client = require('@5minds/processcube_engine_client');
|
4
|
+
const { userInfo } = require('os');
|
5
|
+
|
6
|
+
module.exports = function (RED) {
|
7
|
+
function WaitForUsertask(config) {
|
8
|
+
RED.nodes.createNode(this, config);
|
9
|
+
var node = this;
|
10
|
+
var nodeContext = node.context();
|
11
|
+
|
12
|
+
this.engine = this.server = RED.nodes.getNode(config.engine);
|
13
|
+
|
14
|
+
const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
|
15
|
+
|
16
|
+
var client = nodeContext.get('client');
|
17
|
+
|
18
|
+
if (!client) {
|
19
|
+
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
20
|
+
client = nodeContext.get('client');
|
21
|
+
}
|
22
|
+
|
23
|
+
node.on("close", async () => {
|
24
|
+
if (client != null) {
|
25
|
+
client.dispose();
|
26
|
+
client = null;
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
30
|
+
node.on('input', async function (msg) {
|
31
|
+
|
32
|
+
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
|
33
|
+
|
34
|
+
const sub = await client.userTasks.onUserTaskWaiting(async (userTaskWaitingNotification) => {
|
35
|
+
|
36
|
+
const newQuery = {
|
37
|
+
'flowNodeInstanceId': userTaskWaitingNotification.flowNodeInstanceId,
|
38
|
+
...query
|
39
|
+
};
|
40
|
+
|
41
|
+
const matchingFlowNodes = await client.userTasks.query(newQuery);
|
42
|
+
|
43
|
+
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
44
|
+
const userTask = matchingFlowNodes.userTasks[0];
|
45
|
+
|
46
|
+
msg.payload = { userTask: userTask };
|
47
|
+
node.send(msg);
|
48
|
+
} else {
|
49
|
+
}
|
50
|
+
|
51
|
+
// remove subscription
|
52
|
+
client.userTasks.removeSubscription(sub);
|
53
|
+
});
|
54
|
+
|
55
|
+
console.debug('Handling old userTasks config.only_for_new', config.only_for_new);
|
56
|
+
|
57
|
+
if (config.only_for_new === false) {
|
58
|
+
// only check suspended user tasks
|
59
|
+
const suspendedQuery = {
|
60
|
+
'state': 'suspended',
|
61
|
+
...query
|
62
|
+
};
|
63
|
+
|
64
|
+
const matchingFlowNodes = await client.userTasks.query(suspendedQuery);
|
65
|
+
|
66
|
+
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
|
67
|
+
const userTask = matchingFlowNodes.userTasks[0];
|
68
|
+
|
69
|
+
msg.payload = { userTask: userTask };
|
70
|
+
node.send(msg);
|
71
|
+
|
72
|
+
// remove subscription
|
73
|
+
client.userTasks.removeSubscription(sub);
|
74
|
+
} else {
|
75
|
+
// let the *sub* be active
|
76
|
+
|
77
|
+
}
|
78
|
+
}
|
79
|
+
});
|
80
|
+
}
|
81
|
+
RED.nodes.registerType("wait-for-usertask", WaitForUsertask);
|
82
|
+
}
|
package/wait_for_usertask.js
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
|
3
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
4
|
-
|
5
|
-
module.exports = function (RED) {
|
6
|
-
function WaitForUsertask(config) {
|
7
|
-
RED.nodes.createNode(this, config);
|
8
|
-
var node = this;
|
9
|
-
let client = null;
|
10
|
-
|
11
|
-
this.engine = this.server = RED.nodes.getNode(config.engine);
|
12
|
-
|
13
|
-
const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
|
14
|
-
|
15
|
-
node.on("close", async () => {
|
16
|
-
if (client != null) {
|
17
|
-
client.dispose();
|
18
|
-
client = null;
|
19
|
-
}
|
20
|
-
});
|
21
|
-
|
22
|
-
node.on('input', function (msg) {
|
23
|
-
|
24
|
-
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
|
25
|
-
|
26
|
-
client = new engine_client.EngineClient(engineUrl);
|
27
|
-
client.userTasks.onUserTaskWaiting((userTaskWaitingNotification) => {
|
28
|
-
|
29
|
-
query['flowNodeInstanceId'] = userTaskWaitingNotification.flowNodeInstanceId;
|
30
|
-
|
31
|
-
client.userTasks.query(query).then((matchingFlowNodes) => {
|
32
|
-
|
33
|
-
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
34
|
-
userTask = matchingFlowNodes.userTasks[0];
|
35
|
-
|
36
|
-
msg.payload = { userTask: userTask };
|
37
|
-
node.send(msg);
|
38
|
-
} else {
|
39
|
-
// do nothing, cause we are waiting for a specific user task
|
40
|
-
}
|
41
|
-
|
42
|
-
// dispose the client
|
43
|
-
if (client != null) {
|
44
|
-
client.dispose();
|
45
|
-
client = null;
|
46
|
-
}
|
47
|
-
});
|
48
|
-
});
|
49
|
-
});
|
50
|
-
}
|
51
|
-
RED.nodes.registerType("wait-for-usertask", WaitForUsertask);
|
52
|
-
}
|