@5minds/node-red-contrib-processcube 0.10.3 → 0.11.0-feature-34fec2-lydislpd
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.
@@ -39,6 +39,14 @@
|
|
39
39
|
"info": "",
|
40
40
|
"env": []
|
41
41
|
},
|
42
|
+
{
|
43
|
+
"id": "0825fee24edbf04b",
|
44
|
+
"type": "tab",
|
45
|
+
"label": "Wait for Usertask",
|
46
|
+
"disabled": false,
|
47
|
+
"info": "",
|
48
|
+
"env": []
|
49
|
+
},
|
42
50
|
{
|
43
51
|
"id": "09cdc14cfb8ad687",
|
44
52
|
"type": "group",
|
@@ -1528,6 +1536,7 @@
|
|
1528
1536
|
"id": "3e89be46a437d93c",
|
1529
1537
|
"type": "usertask-finished-listener",
|
1530
1538
|
"z": "fd3c725340de4f74",
|
1539
|
+
"d": true,
|
1531
1540
|
"g": "f29182f397cab86b",
|
1532
1541
|
"name": "",
|
1533
1542
|
"engine": "d042a4c68f51d6ab",
|
@@ -1563,6 +1572,7 @@
|
|
1563
1572
|
"id": "3011d9be5207350a",
|
1564
1573
|
"type": "usertask-new-listener",
|
1565
1574
|
"z": "fd3c725340de4f74",
|
1575
|
+
"d": true,
|
1566
1576
|
"g": "f29182f397cab86b",
|
1567
1577
|
"name": "",
|
1568
1578
|
"engine": "d042a4c68f51d6ab",
|
@@ -2766,5 +2776,93 @@
|
|
2766
2776
|
"x": 90,
|
2767
2777
|
"y": 260,
|
2768
2778
|
"wires": []
|
2779
|
+
},
|
2780
|
+
{
|
2781
|
+
"id": "22a41b4678ae316d",
|
2782
|
+
"type": "wait-for-usertask",
|
2783
|
+
"z": "0825fee24edbf04b",
|
2784
|
+
"name": "",
|
2785
|
+
"engine": "d042a4c68f51d6ab",
|
2786
|
+
"query": "{\"flowNodeId\":\"PlaceAnOrderUserTask\"}",
|
2787
|
+
"query_type": "json",
|
2788
|
+
"only_for_new": true,
|
2789
|
+
"x": 350,
|
2790
|
+
"y": 160,
|
2791
|
+
"wires": [
|
2792
|
+
[
|
2793
|
+
"fdd00e4099ca2ff6",
|
2794
|
+
"f7c378cc51a6244d"
|
2795
|
+
]
|
2796
|
+
]
|
2797
|
+
},
|
2798
|
+
{
|
2799
|
+
"id": "d1336102e406b91c",
|
2800
|
+
"type": "inject",
|
2801
|
+
"z": "0825fee24edbf04b",
|
2802
|
+
"name": "",
|
2803
|
+
"props": [
|
2804
|
+
{
|
2805
|
+
"p": "payload"
|
2806
|
+
},
|
2807
|
+
{
|
2808
|
+
"p": "topic",
|
2809
|
+
"vt": "str"
|
2810
|
+
}
|
2811
|
+
],
|
2812
|
+
"repeat": "",
|
2813
|
+
"crontab": "",
|
2814
|
+
"once": false,
|
2815
|
+
"onceDelay": 0.1,
|
2816
|
+
"topic": "",
|
2817
|
+
"payload": "",
|
2818
|
+
"payloadType": "date",
|
2819
|
+
"x": 100,
|
2820
|
+
"y": 160,
|
2821
|
+
"wires": [
|
2822
|
+
[
|
2823
|
+
"22a41b4678ae316d"
|
2824
|
+
]
|
2825
|
+
]
|
2826
|
+
},
|
2827
|
+
{
|
2828
|
+
"id": "fdd00e4099ca2ff6",
|
2829
|
+
"type": "debug",
|
2830
|
+
"z": "0825fee24edbf04b",
|
2831
|
+
"name": "debug 28",
|
2832
|
+
"active": true,
|
2833
|
+
"tosidebar": true,
|
2834
|
+
"console": false,
|
2835
|
+
"tostatus": false,
|
2836
|
+
"complete": "false",
|
2837
|
+
"statusVal": "",
|
2838
|
+
"statusType": "auto",
|
2839
|
+
"x": 570,
|
2840
|
+
"y": 160,
|
2841
|
+
"wires": []
|
2842
|
+
},
|
2843
|
+
{
|
2844
|
+
"id": "f7c378cc51a6244d",
|
2845
|
+
"type": "delay",
|
2846
|
+
"z": "0825fee24edbf04b",
|
2847
|
+
"name": "",
|
2848
|
+
"pauseType": "delay",
|
2849
|
+
"timeout": "5",
|
2850
|
+
"timeoutUnits": "seconds",
|
2851
|
+
"rate": "1",
|
2852
|
+
"nbRateUnits": "1",
|
2853
|
+
"rateUnits": "second",
|
2854
|
+
"randomFirst": "1",
|
2855
|
+
"randomLast": "5",
|
2856
|
+
"randomUnits": "seconds",
|
2857
|
+
"drop": false,
|
2858
|
+
"allowrate": false,
|
2859
|
+
"outputs": 1,
|
2860
|
+
"x": 340,
|
2861
|
+
"y": 240,
|
2862
|
+
"wires": [
|
2863
|
+
[
|
2864
|
+
"22a41b4678ae316d"
|
2865
|
+
]
|
2866
|
+
]
|
2769
2867
|
}
|
2770
2868
|
]
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@5minds/node-red-contrib-processcube",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.11.0-feature-34fec2-lydislpd",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"authors": [
|
@@ -44,7 +44,8 @@
|
|
44
44
|
"UserTaskNewListener": "usertask-new-listener.js",
|
45
45
|
"UserTaskFinishedListener": "usertask-finished-listener.js",
|
46
46
|
"UserTaskInput": "usertask-input.js",
|
47
|
-
"UserTaskOutput": "usertask-output.js"
|
47
|
+
"UserTaskOutput": "usertask-output.js",
|
48
|
+
"WaitForUsertask": "wait-for-usertask.js"
|
48
49
|
}
|
49
50
|
},
|
50
51
|
"dependencies": {
|
package/usertask-input.js
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
RED.nodes.registerType('wait-for-usertask',{
|
3
|
+
category: 'ProcessCube',
|
4
|
+
color: '#02AFD6',
|
5
|
+
defaults: {
|
6
|
+
name: {value: ""},
|
7
|
+
engine: {value: "", type: "processcube-engine-config"},
|
8
|
+
query: {value: "payload"},
|
9
|
+
query_type: {value: "msg"},
|
10
|
+
only_for_new: {value: false}
|
11
|
+
},
|
12
|
+
inputs: 1,
|
13
|
+
outputs: 1,
|
14
|
+
icon: "font-awesome/fa-envelope-open",
|
15
|
+
label: function() {
|
16
|
+
return this.name || "wait-for-usertask";
|
17
|
+
},
|
18
|
+
oneditprepare: function() {
|
19
|
+
$("#node-input-query").typedInput({
|
20
|
+
default: 'msg',
|
21
|
+
types: ['msg', 'json']
|
22
|
+
});
|
23
|
+
|
24
|
+
$("#node-input-query").typedInput('value', this.query);
|
25
|
+
$("#node-input-query").typedInput('type', this.query_type);
|
26
|
+
},
|
27
|
+
oneditsave: function() {
|
28
|
+
this.query = $("#node-input-query").typedInput('value'),
|
29
|
+
this.query_type = $("#node-input-query").typedInput('type')
|
30
|
+
|
31
|
+
}
|
32
|
+
});
|
33
|
+
</script>
|
34
|
+
|
35
|
+
<script type="text/html" data-template-name="wait-for-usertask">
|
36
|
+
<div class="form-row">
|
37
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
38
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
39
|
+
</div>
|
40
|
+
<div class="form-row">
|
41
|
+
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
42
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000">
|
43
|
+
</div>
|
44
|
+
<div class="form-row">
|
45
|
+
<label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
|
46
|
+
<input type="text" id="node-input-query">
|
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>
|
55
|
+
</script>
|
56
|
+
|
57
|
+
<script type="text/markdown" data-help-name="wait-for-usertask">
|
58
|
+
Waiting for Usertasks of the connected ProcessCube Engine.
|
59
|
+
|
60
|
+
### Inputs
|
61
|
+
|
62
|
+
: payload (json) : the query to filter the usertasks.
|
63
|
+
|
64
|
+
## Outputs
|
65
|
+
|
66
|
+
: payload.userTask (string) : The filtered UserTask
|
67
|
+
|
68
|
+
### Details
|
69
|
+
|
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.
|
72
|
+
|
73
|
+
### References
|
74
|
+
|
75
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© Plattform
|
76
|
+
</script>
|
@@ -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
|
+
}
|