@5minds/node-red-contrib-processcube 0.14.0-develop-7fe136-lygsbbpi → 0.14.0-error-handling-in-process-instance-query-and-add-prettier-8b2f33-lz08cr3v
Sign up to get free protection for your applications and to get access to all the features.
- package/.prettierrc.json +6 -0
- package/Dockerfile +1 -1
- package/docker-compose.yml +12 -0
- package/examples/External-Task-Sample.json +252 -0
- package/externaltask-error.html +26 -12
- package/externaltask-error.js +19 -22
- package/externaltask-input.html +31 -14
- package/externaltask-input.js +114 -57
- package/externaltask-output.html +20 -10
- package/externaltask-output.js +11 -12
- package/message-event-trigger.html +14 -14
- package/message-event-trigger.js +25 -33
- package/nodered/node-red-contrib-processcube-flows.json +216 -132
- package/nodered/package.json +1 -0
- package/nodered/settings.js +82 -92
- package/package.json +5 -2
- package/process-start.html +19 -23
- package/process-start.js +22 -27
- package/processcube-engine-config.html +10 -10
- package/processcube-engine-config.js +39 -17
- package/processdefinition-query.html +29 -23
- package/processdefinition-query.js +13 -25
- package/processes/External-Task-Sample.bpmn +94 -0
- package/processinstance-query.html +19 -20
- package/processinstance-query.js +17 -21
- package/signal-event-trigger.html +14 -14
- package/signal-event-trigger.js +25 -33
- package/usertask-finished-listener.html +17 -12
- package/usertask-finished-listener.js +34 -24
- package/usertask-input.html +40 -27
- package/usertask-input.js +34 -29
- package/usertask-new-listener.html +17 -12
- package/usertask-new-listener.js +35 -26
- package/usertask-output.html +23 -24
- package/usertask-output.js +13 -21
- package/processes/CheckError.bpmn +0 -78
- package/processes/NodeRedExternalTask.bpmn +0 -77
- package/processes/SampleUserTask.bpmn +0 -95
@@ -3,23 +3,15 @@ const EventEmitter = require('node:events');
|
|
3
3
|
|
4
4
|
const engine_client = require('@5minds/processcube_engine_client');
|
5
5
|
|
6
|
-
module.exports = function(RED) {
|
6
|
+
module.exports = function (RED) {
|
7
7
|
function UserTaskFinishedListener(config) {
|
8
8
|
RED.nodes.createNode(this, config);
|
9
9
|
var node = this;
|
10
10
|
var flowContext = node.context().flow;
|
11
|
-
var nodeContext = node.context();
|
12
11
|
|
13
12
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
14
13
|
|
15
|
-
const
|
16
|
-
|
17
|
-
var client = nodeContext.get('client');
|
18
|
-
|
19
|
-
if (!client) {
|
20
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
21
|
-
client = nodeContext.get('client');
|
22
|
-
}
|
14
|
+
const client = this.engine.getEngineClient();
|
23
15
|
|
24
16
|
var eventEmitter = flowContext.get('emitter');
|
25
17
|
|
@@ -30,29 +22,47 @@ module.exports = function(RED) {
|
|
30
22
|
|
31
23
|
const register = async () => {
|
32
24
|
let currentIdentity = node.server.identity;
|
33
|
-
let subscription = await client.userTasks.onUserTaskFinished(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
let subscription = await client.userTasks.onUserTaskFinished(
|
26
|
+
(userTaskFinishedNotification) => {
|
27
|
+
node.send({
|
28
|
+
payload: {
|
29
|
+
flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
|
30
|
+
action: 'finished',
|
31
|
+
type: 'usertask',
|
32
|
+
},
|
33
|
+
});
|
34
|
+
},
|
35
|
+
{ identity: currentIdentity },
|
36
|
+
);
|
37
|
+
|
38
|
+
node.server.registerOnIdentityChanged(async (identity) => {
|
38
39
|
client.userTasks.removeSubscription(subscription, currentIdentity);
|
39
40
|
currentIdentity = identity;
|
40
|
-
|
41
|
-
subscription = await client.userTasks.onUserTaskFinished(
|
42
|
-
|
43
|
-
|
41
|
+
|
42
|
+
subscription = await client.userTasks.onUserTaskFinished(
|
43
|
+
(userTaskFinishedNotification) => {
|
44
|
+
node.send({
|
45
|
+
payload: {
|
46
|
+
flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
|
47
|
+
action: 'finished',
|
48
|
+
type: 'usertask',
|
49
|
+
},
|
50
|
+
});
|
51
|
+
},
|
52
|
+
{ identity: currentIdentity },
|
53
|
+
);
|
44
54
|
});
|
45
|
-
|
46
|
-
node.on(
|
55
|
+
|
56
|
+
node.on('close', async () => {
|
47
57
|
client.userTasks.removeSubscription(subscription, currentIdentity);
|
48
58
|
client.dispose();
|
49
59
|
client = null;
|
50
60
|
});
|
51
|
-
}
|
61
|
+
};
|
52
62
|
|
53
63
|
if (node.server) {
|
54
64
|
register();
|
55
65
|
}
|
56
66
|
}
|
57
|
-
RED.nodes.registerType(
|
58
|
-
}
|
67
|
+
RED.nodes.registerType('usertask-finished-listener', UserTaskFinishedListener);
|
68
|
+
};
|
package/usertask-input.html
CHANGED
@@ -1,62 +1,75 @@
|
|
1
1
|
<script type="text/javascript">
|
2
|
-
RED.nodes.registerType('usertask-input',{
|
2
|
+
RED.nodes.registerType('usertask-input', {
|
3
3
|
category: 'ProcessCube',
|
4
4
|
color: '#02AFD6',
|
5
5
|
defaults: {
|
6
|
-
name: {value:
|
7
|
-
engine: {value:
|
8
|
-
query: {value:
|
9
|
-
query_type: {value:
|
10
|
-
force_send_array: {value: false},
|
11
|
-
multisend: {value: false}
|
6
|
+
name: { value: '' },
|
7
|
+
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
+
query: { value: 'payload' },
|
9
|
+
query_type: { value: 'msg' },
|
10
|
+
force_send_array: { value: false },
|
11
|
+
multisend: { value: false },
|
12
12
|
},
|
13
13
|
inputs: 1,
|
14
14
|
outputs: 1,
|
15
|
-
icon:
|
16
|
-
label: function() {
|
17
|
-
return this.name ||
|
15
|
+
icon: 'font-awesome/fa-envelope-open',
|
16
|
+
label: function () {
|
17
|
+
return this.name || 'usertask-input';
|
18
18
|
},
|
19
|
-
oneditprepare: function() {
|
20
|
-
$(
|
19
|
+
oneditprepare: function () {
|
20
|
+
$('#node-input-query').typedInput({
|
21
21
|
default: 'msg',
|
22
|
-
types: ['msg', 'json']
|
22
|
+
types: ['msg', 'json'],
|
23
23
|
});
|
24
24
|
|
25
|
-
$(
|
26
|
-
$(
|
25
|
+
$('#node-input-query').typedInput('value', this.query);
|
26
|
+
$('#node-input-query').typedInput('type', this.query_type);
|
27
|
+
},
|
28
|
+
oneditsave: function () {
|
29
|
+
(this.query = $('#node-input-query').typedInput('value')),
|
30
|
+
(this.query_type = $('#node-input-query').typedInput('type'));
|
27
31
|
},
|
28
|
-
oneditsave: function() {
|
29
|
-
this.query = $("#node-input-query").typedInput('value'),
|
30
|
-
this.query_type = $("#node-input-query").typedInput('type')
|
31
|
-
|
32
|
-
}
|
33
32
|
});
|
34
33
|
</script>
|
35
34
|
|
36
35
|
<script type="text/html" data-template-name="usertask-input">
|
37
36
|
<div class="form-row">
|
38
37
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
39
|
-
<input type="text" id="node-input-name" placeholder="Name"
|
38
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
40
39
|
</div>
|
41
40
|
<div class="form-row">
|
42
41
|
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
43
|
-
<input type="text" id="node-input-engine" placeholder="http://engine:8000"
|
42
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
44
43
|
</div>
|
45
44
|
<div class="form-row">
|
46
45
|
<label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
|
47
|
-
<input type="text" id="node-input-query"
|
46
|
+
<input type="text" id="node-input-query" />
|
48
47
|
</div>
|
49
48
|
<div class="form-row" style="display:flex; margin-bottom: 3px;">
|
50
|
-
<label for="node-input-force_send_array" style="vertical-align:top"
|
49
|
+
<label for="node-input-force_send_array" style="vertical-align:top"
|
50
|
+
><i class="fa fa-list-alt"></i> Force send payload as array</label
|
51
|
+
>
|
51
52
|
<div>
|
52
|
-
<input
|
53
|
-
|
53
|
+
<input
|
54
|
+
type="checkbox"
|
55
|
+
checked
|
56
|
+
id="node-input-force_send_array"
|
57
|
+
style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;"
|
58
|
+
/>
|
59
|
+
<label style="width:auto" for="node-input-force_send_array"
|
60
|
+
>Alway send an array? Only works if <i>Send multi</i> is false.</label
|
61
|
+
>
|
54
62
|
</div>
|
55
63
|
</div>
|
56
64
|
<div class="form-row" style="display:flex; margin-bottom: 3px;">
|
57
65
|
<label for="node-input-multisend" style="vertical-align:top"><i class="fa fa-list-alt"></i> Send multi</label>
|
58
66
|
<div>
|
59
|
-
<input
|
67
|
+
<input
|
68
|
+
type="checkbox"
|
69
|
+
checked
|
70
|
+
id="node-input-multisend"
|
71
|
+
style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;"
|
72
|
+
/>
|
60
73
|
<label style="width:auto" for="node-input-multisend">Send one output of each usertask input?</label>
|
61
74
|
</div>
|
62
75
|
</div>
|
package/usertask-input.js
CHANGED
@@ -5,30 +5,30 @@ const engine_client = require('@5minds/processcube_engine_client');
|
|
5
5
|
|
6
6
|
function showStatus(node, msgCounter) {
|
7
7
|
if (msgCounter >= 1) {
|
8
|
-
node.status({
|
8
|
+
node.status({
|
9
|
+
fill: 'blue',
|
10
|
+
shape: 'dot',
|
11
|
+
text: `handling tasks ${msgCounter}`,
|
12
|
+
});
|
9
13
|
} else {
|
10
|
-
node.status({
|
14
|
+
node.status({
|
15
|
+
fill: 'blue',
|
16
|
+
shape: 'ring',
|
17
|
+
text: `subcribed ${msgCounter}`,
|
18
|
+
});
|
11
19
|
}
|
12
20
|
}
|
13
21
|
|
14
|
-
module.exports = function(RED) {
|
22
|
+
module.exports = function (RED) {
|
15
23
|
function UserTaskInput(config) {
|
16
|
-
RED.nodes.createNode(this,config);
|
24
|
+
RED.nodes.createNode(this, config);
|
17
25
|
var node = this;
|
18
26
|
var msgCounter = 0;
|
19
27
|
var flowContext = node.context().flow;
|
20
|
-
var nodeContext = node.context();
|
21
28
|
|
22
29
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
23
30
|
|
24
|
-
const
|
25
|
-
|
26
|
-
var client = nodeContext.get('client');
|
27
|
-
|
28
|
-
if (!client) {
|
29
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
30
|
-
client = nodeContext.get('client');
|
31
|
-
}
|
31
|
+
const client = this.engine.getEngineClient();
|
32
32
|
|
33
33
|
var eventEmitter = flowContext.get('emitter');
|
34
34
|
|
@@ -37,20 +37,24 @@ module.exports = function(RED) {
|
|
37
37
|
eventEmitter = flowContext.get('emitter');
|
38
38
|
}
|
39
39
|
|
40
|
-
node.on(
|
40
|
+
node.on('close', async () => {
|
41
41
|
client.dispose();
|
42
42
|
client = null;
|
43
43
|
});
|
44
44
|
|
45
|
-
node.on('input', function(msg) {
|
46
|
-
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
|
45
|
+
node.on('input', function (msg) {
|
46
|
+
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
47
47
|
query = {
|
48
48
|
...query,
|
49
|
-
identity: node.server.identity
|
50
|
-
}
|
49
|
+
identity: node.server.identity,
|
50
|
+
};
|
51
51
|
client.userTasks.query(query).then((matchingFlowNodes) => {
|
52
|
-
|
53
|
-
|
52
|
+
if (
|
53
|
+
!config.force_send_array &&
|
54
|
+
matchingFlowNodes &&
|
55
|
+
matchingFlowNodes.userTasks &&
|
56
|
+
matchingFlowNodes.userTasks.length == 1
|
57
|
+
) {
|
54
58
|
userTask = matchingFlowNodes.userTasks[0];
|
55
59
|
|
56
60
|
msg.payload = { userTask: userTask };
|
@@ -59,23 +63,24 @@ module.exports = function(RED) {
|
|
59
63
|
if (!config.force_send_array) {
|
60
64
|
if (config.multisend && matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length > 1) {
|
61
65
|
matchingFlowNodes.userTasks.forEach((userTask) => {
|
62
|
-
|
63
|
-
msg.payload = { userTask: userTask } ;
|
66
|
+
msg.payload = { userTask: userTask };
|
64
67
|
node.send(msg);
|
65
68
|
});
|
66
69
|
} else {
|
67
|
-
|
68
|
-
|
70
|
+
msg.payload = {
|
71
|
+
userTasks: matchingFlowNodes.userTasks,
|
72
|
+
};
|
69
73
|
node.send(msg);
|
70
74
|
}
|
71
75
|
} else {
|
72
|
-
|
73
|
-
|
76
|
+
msg.payload = {
|
77
|
+
userTasks: matchingFlowNodes.userTasks || [],
|
78
|
+
};
|
74
79
|
node.send(msg);
|
75
80
|
}
|
76
|
-
|
81
|
+
}
|
77
82
|
});
|
78
83
|
});
|
79
84
|
}
|
80
|
-
RED.nodes.registerType(
|
81
|
-
}
|
85
|
+
RED.nodes.registerType('usertask-input', UserTaskInput);
|
86
|
+
};
|
@@ -1,34 +1,39 @@
|
|
1
1
|
<script type="text/javascript">
|
2
|
-
RED.nodes.registerType('usertask-new-listener',{
|
2
|
+
RED.nodes.registerType('usertask-new-listener', {
|
3
3
|
category: 'ProcessCube Events',
|
4
4
|
color: '#02AFD6',
|
5
5
|
defaults: {
|
6
|
-
name: {value:
|
7
|
-
engine: {value:
|
8
|
-
multisend: {value: false}
|
6
|
+
name: { value: '' },
|
7
|
+
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
+
multisend: { value: false },
|
9
9
|
},
|
10
10
|
inputs: 0,
|
11
11
|
outputs: 1,
|
12
|
-
icon:
|
13
|
-
label: function() {
|
14
|
-
return this.name ||
|
15
|
-
}
|
12
|
+
icon: 'font-awesome/fa-envelope-open',
|
13
|
+
label: function () {
|
14
|
+
return this.name || 'usertask-new-listener';
|
15
|
+
},
|
16
16
|
});
|
17
17
|
</script>
|
18
18
|
|
19
19
|
<script type="text/html" data-template-name="usertask-new-listener">
|
20
20
|
<div class="form-row">
|
21
21
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
22
|
-
<input type="text" id="node-input-name" placeholder="Name"
|
22
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
23
23
|
</div>
|
24
24
|
<div class="form-row">
|
25
25
|
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
26
|
-
<input type="text" id="node-input-engine" placeholder="http://engine:8000"
|
26
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
27
27
|
</div>
|
28
28
|
<div class="form-row" style="display:flex; margin-bottom: 3px;">
|
29
29
|
<label for="node-input-multisend" style="vertical-align:top"><i class="fa fa-list-alt"></i> Send multi</label>
|
30
30
|
<div>
|
31
|
-
<input
|
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
|
+
/>
|
32
37
|
<label style="width:auto" for="node-input-multisend">Send one output of each usertask input?</label>
|
33
38
|
</div>
|
34
39
|
</div>
|
@@ -36,4 +41,4 @@
|
|
36
41
|
|
37
42
|
<script type="text/html" data-help-name="usertask-new-listener">
|
38
43
|
<p>A node which subscribes to an User Task of https://processcube.io</p>
|
39
|
-
</script>
|
44
|
+
</script>
|
package/usertask-new-listener.js
CHANGED
@@ -3,23 +3,15 @@ const EventEmitter = require('node:events');
|
|
3
3
|
|
4
4
|
const engine_client = require('@5minds/processcube_engine_client');
|
5
5
|
|
6
|
-
module.exports = function(RED) {
|
6
|
+
module.exports = function (RED) {
|
7
7
|
function UserTaskNewListener(config) {
|
8
8
|
RED.nodes.createNode(this, config);
|
9
9
|
var node = this;
|
10
10
|
var flowContext = node.context().flow;
|
11
|
-
var nodeContext = node.context();
|
12
11
|
|
13
12
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
14
13
|
|
15
|
-
const
|
16
|
-
|
17
|
-
var client = nodeContext.get('client');
|
18
|
-
|
19
|
-
if (!client) {
|
20
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
21
|
-
client = nodeContext.get('client');
|
22
|
-
}
|
14
|
+
const client = this.engine.getEngineClient();
|
23
15
|
|
24
16
|
var eventEmitter = flowContext.get('emitter');
|
25
17
|
|
@@ -27,33 +19,50 @@ module.exports = function(RED) {
|
|
27
19
|
flowContext.set('emitter', new EventEmitter());
|
28
20
|
eventEmitter = flowContext.get('emitter');
|
29
21
|
}
|
30
|
-
|
22
|
+
|
31
23
|
const register = async () => {
|
32
24
|
let currentIdentity = node.server.identity;
|
33
|
-
let subscription = await client.userTasks.onUserTaskWaiting(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
let subscription = await client.userTasks.onUserTaskWaiting(
|
26
|
+
(userTaskWaitingNotification) => {
|
27
|
+
node.send({
|
28
|
+
payload: {
|
29
|
+
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
30
|
+
action: 'new',
|
31
|
+
type: 'usertask',
|
32
|
+
},
|
33
|
+
});
|
34
|
+
},
|
35
|
+
{ identity: currentIdentity },
|
36
|
+
);
|
37
|
+
|
38
|
+
node.server.registerOnIdentityChanged(async (identity) => {
|
38
39
|
client.userTasks.removeSubscription(subscription, currentIdentity);
|
39
40
|
currentIdentity = identity;
|
40
|
-
|
41
|
-
subscription = await client.userTasks.onUserTaskWaiting(
|
42
|
-
|
43
|
-
|
41
|
+
|
42
|
+
subscription = await client.userTasks.onUserTaskWaiting(
|
43
|
+
(userTaskWaitingNotification) => {
|
44
|
+
node.send({
|
45
|
+
payload: {
|
46
|
+
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
47
|
+
action: 'new',
|
48
|
+
type: 'usertask',
|
49
|
+
},
|
50
|
+
});
|
51
|
+
},
|
52
|
+
{ identity: currentIdentity },
|
53
|
+
);
|
44
54
|
});
|
45
|
-
|
46
|
-
node.on(
|
55
|
+
|
56
|
+
node.on('close', async () => {
|
47
57
|
client.userTasks.removeSubscription(subscription, currentIdentity);
|
48
58
|
client.dispose();
|
49
59
|
client = null;
|
50
60
|
});
|
51
|
-
}
|
61
|
+
};
|
52
62
|
|
53
63
|
if (node.server) {
|
54
64
|
register();
|
55
65
|
}
|
56
|
-
|
57
66
|
}
|
58
|
-
RED.nodes.registerType(
|
59
|
-
}
|
67
|
+
RED.nodes.registerType('usertask-new-listener', UserTaskNewListener);
|
68
|
+
};
|
package/usertask-output.html
CHANGED
@@ -1,48 +1,47 @@
|
|
1
1
|
<script type="text/javascript">
|
2
|
-
RED.nodes.registerType('usertask-output',{
|
2
|
+
RED.nodes.registerType('usertask-output', {
|
3
3
|
category: 'ProcessCube',
|
4
4
|
color: '#02AFD6',
|
5
5
|
defaults: {
|
6
|
-
name: {value:
|
7
|
-
engine: {value:
|
8
|
-
result: {value:
|
9
|
-
result_type: {value:
|
6
|
+
name: { value: '' },
|
7
|
+
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
+
result: { value: 'payload' },
|
9
|
+
result_type: { value: 'msg' },
|
10
10
|
},
|
11
11
|
inputs: 1,
|
12
12
|
outputs: 1,
|
13
|
-
icon:
|
14
|
-
label: function() {
|
15
|
-
return this.name ||
|
13
|
+
icon: 'font-awesome/fa-envelope',
|
14
|
+
label: function () {
|
15
|
+
return this.name || 'usertask-output';
|
16
16
|
},
|
17
|
-
oneditprepare: function() {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
oneditprepare: function () {
|
18
|
+
$('#node-input-result').typedInput({
|
19
|
+
default: 'msg',
|
20
|
+
types: ['msg', 'json'],
|
21
|
+
});
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
}
|
23
|
+
$('#node-input-result').typedInput('value', this.result);
|
24
|
+
$('#node-input-result').typedInput('type', this.result_type);
|
25
|
+
},
|
26
|
+
oneditsave: function () {
|
27
|
+
(this.result = $('#node-input-result').typedInput('value')),
|
28
|
+
(this.result_type = $('#node-input-result').typedInput('type'));
|
29
|
+
},
|
31
30
|
});
|
32
31
|
</script>
|
33
32
|
|
34
33
|
<script type="text/html" data-template-name="usertask-output">
|
35
34
|
<div class="form-row">
|
36
35
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
37
|
-
<input type="text" id="node-input-name" placeholder="Name"
|
36
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
38
37
|
</div>
|
39
38
|
<div class="form-row">
|
40
39
|
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
41
|
-
<input type="text" id="node-input-engine" placeholder="http://engine:8000"
|
40
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
42
41
|
</div>
|
43
42
|
<div class="form-row">
|
44
43
|
<label for="node-input-result"><i class="fa fa-tag"></i> Result</label>
|
45
|
-
<input type="text" id="node-input-result"
|
44
|
+
<input type="text" id="node-input-result" />
|
46
45
|
</div>
|
47
46
|
</script>
|
48
47
|
|
package/usertask-output.js
CHANGED
@@ -3,25 +3,16 @@ const EventEmitter = require('node:events');
|
|
3
3
|
|
4
4
|
const engine_client = require('@5minds/processcube_engine_client');
|
5
5
|
|
6
|
-
module.exports = function(RED) {
|
6
|
+
module.exports = function (RED) {
|
7
7
|
function UserTaskOutput(config) {
|
8
|
-
|
9
8
|
RED.nodes.createNode(this, config);
|
10
9
|
|
11
10
|
var node = this;
|
12
11
|
var flowContext = node.context().flow;
|
13
|
-
var nodeContext = node.context();
|
14
12
|
|
15
13
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
16
14
|
|
17
|
-
const
|
18
|
-
|
19
|
-
var client = nodeContext.get('client');
|
20
|
-
|
21
|
-
if (!client) {
|
22
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
23
|
-
client = nodeContext.get('client');
|
24
|
-
}
|
15
|
+
const client = this.engine.getEngineClient();
|
25
16
|
|
26
17
|
var eventEmitter = flowContext.get('emitter');
|
27
18
|
|
@@ -30,24 +21,25 @@ module.exports = function(RED) {
|
|
30
21
|
eventEmitter = flowContext.get('emitter');
|
31
22
|
}
|
32
23
|
|
33
|
-
node.on('input', function(msg) {
|
24
|
+
node.on('input', function (msg) {
|
34
25
|
if (msg.payload.userTask) {
|
35
|
-
|
36
26
|
const flowNodeInstanceId = msg.payload.userTask.flowNodeInstanceId;
|
37
27
|
|
38
28
|
const userTaskResult = RED.util.evaluateNodeProperty(config.result, config.result_type, node, msg);
|
39
29
|
|
40
|
-
client.userTasks
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
30
|
+
client.userTasks
|
31
|
+
.finishUserTask(flowNodeInstanceId, userTaskResult, node.server.identity)
|
32
|
+
.then(() => {
|
33
|
+
node.send(msg);
|
34
|
+
})
|
35
|
+
.catch((error) => {
|
36
|
+
node.error(error);
|
37
|
+
});
|
46
38
|
} else {
|
47
39
|
node.error(`No UserTask found in message: ${JSON.stringify(msg.payload)}`);
|
48
40
|
}
|
49
41
|
});
|
50
42
|
}
|
51
43
|
|
52
|
-
RED.nodes.registerType(
|
53
|
-
}
|
44
|
+
RED.nodes.registerType('usertask-output', UserTaskOutput);
|
45
|
+
};
|