@5minds/node-red-contrib-processcube 1.5.10-feature-350169-m4jpqvzq → 1.5.10-feature-70f7fe-m4jq28wc
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/endevent-finished-listener.js +11 -0
- package/externaltask-event-listener.js +11 -0
- package/externaltask-input.js +12 -5
- package/message-event-trigger.js +4 -4
- package/package.json +1 -1
- package/process-event-listener.js +11 -0
- package/process-start.js +3 -3
- package/process-terminate.js +3 -3
- package/processcube-engine-config.html +7 -7
- package/processcube-engine-config.js +108 -65
- package/processdefinition-query.js +2 -2
- package/processinstance-delete.html +5 -5
- package/processinstance-delete.js +8 -8
- package/processinstance-query.js +3 -3
- package/signal-event-trigger.js +3 -3
- package/usertask-event-listener.js +11 -0
- package/usertask-input.js +3 -3
- package/usertask-output.js +3 -3
@@ -6,6 +6,17 @@ module.exports = function (RED) {
|
|
6
6
|
|
7
7
|
let subscription = null;
|
8
8
|
|
9
|
+
const eventEmitter = node.engine.eventEmitter;
|
10
|
+
|
11
|
+
eventEmitter.on('engine-client-dispose', () => {
|
12
|
+
node.engine.engineClient.events.removeSubscription(subscription, node.engine.identity);
|
13
|
+
});
|
14
|
+
|
15
|
+
eventEmitter.on('engine-client-changed', () => {
|
16
|
+
node.log('new engineClient received');
|
17
|
+
register();
|
18
|
+
});
|
19
|
+
|
9
20
|
const register = async () => {
|
10
21
|
const client = node.engine.engineClient;
|
11
22
|
|
@@ -6,6 +6,17 @@ module.exports = function (RED) {
|
|
6
6
|
|
7
7
|
let subscription;
|
8
8
|
|
9
|
+
const eventEmitter = node.engine.eventEmitter;
|
10
|
+
|
11
|
+
eventEmitter.on('engine-client-dispose', () => {
|
12
|
+
node.engine.engineClient.notification.removeSubscription(subscription, node.engine.identity);
|
13
|
+
});
|
14
|
+
|
15
|
+
eventEmitter.on('engine-client-changed', () => {
|
16
|
+
node.log('new engineClient received');
|
17
|
+
register();
|
18
|
+
});
|
19
|
+
|
9
20
|
const register = async () => {
|
10
21
|
let currentIdentity = node.engine.identity;
|
11
22
|
|
package/externaltask-input.js
CHANGED
@@ -16,7 +16,7 @@ module.exports = function (RED) {
|
|
16
16
|
var node = this;
|
17
17
|
var flowContext = node.context().flow;
|
18
18
|
|
19
|
-
|
19
|
+
const engine = RED.nodes.getNode(config.engine);
|
20
20
|
|
21
21
|
var eventEmitter = flowContext.get('emitter');
|
22
22
|
|
@@ -25,6 +25,13 @@ module.exports = function (RED) {
|
|
25
25
|
eventEmitter = flowContext.get('emitter');
|
26
26
|
}
|
27
27
|
|
28
|
+
const engineEventEmitter = engine.eventEmitter;
|
29
|
+
|
30
|
+
engineEventEmitter.on('engine-client-changed', () => {
|
31
|
+
node.log('new engineClient received');
|
32
|
+
register();
|
33
|
+
});
|
34
|
+
|
28
35
|
const register = async () => {
|
29
36
|
if (node.etw) {
|
30
37
|
try {
|
@@ -34,7 +41,7 @@ module.exports = function (RED) {
|
|
34
41
|
node.log(`cant close etw: ${JSON.stringify(node.etw)}`);
|
35
42
|
}
|
36
43
|
}
|
37
|
-
const client =
|
44
|
+
const client = engine.engineClient;
|
38
45
|
|
39
46
|
if (!client) {
|
40
47
|
node.error('No engine configured.');
|
@@ -126,8 +133,8 @@ module.exports = function (RED) {
|
|
126
133
|
|
127
134
|
node.etw = externalTaskWorker;
|
128
135
|
|
129
|
-
externalTaskWorker.identity =
|
130
|
-
|
136
|
+
externalTaskWorker.identity = engine.identity;
|
137
|
+
engine.registerOnIdentityChanged((identity) => {
|
131
138
|
externalTaskWorker.identity = identity;
|
132
139
|
});
|
133
140
|
|
@@ -178,7 +185,7 @@ module.exports = function (RED) {
|
|
178
185
|
});
|
179
186
|
};
|
180
187
|
|
181
|
-
if (
|
188
|
+
if (engine) {
|
182
189
|
register();
|
183
190
|
}
|
184
191
|
}
|
package/message-event-trigger.js
CHANGED
@@ -5,19 +5,19 @@ module.exports = function (RED) {
|
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
7
|
|
8
|
-
|
9
|
-
const client =
|
8
|
+
const engine = RED.nodes.getNode(config.engine);
|
9
|
+
const client = engine.engineClient;
|
10
10
|
|
11
11
|
if (!client) {
|
12
12
|
node.error('No engine configured.');
|
13
13
|
return;
|
14
14
|
}
|
15
15
|
|
16
|
-
|
16
|
+
engine.engineClient.events
|
17
17
|
.triggerMessageEvent(config.messagename, {
|
18
18
|
processInstanceId: msg.processinstanceid,
|
19
19
|
payload: msg.payload,
|
20
|
-
identity:
|
20
|
+
identity: engine.identity,
|
21
21
|
})
|
22
22
|
.then((result) => {
|
23
23
|
msg.payload = result;
|
package/package.json
CHANGED
@@ -6,6 +6,17 @@ module.exports = function (RED) {
|
|
6
6
|
|
7
7
|
let subscription;
|
8
8
|
|
9
|
+
const engineEventEmitter = node.engine.eventEmitter;
|
10
|
+
|
11
|
+
engineEventEmitter.on('engine-client-dispose', () => {
|
12
|
+
node.engine.engineClient.notification.removeSubscription(subscription, node.engine.identity);
|
13
|
+
});
|
14
|
+
|
15
|
+
engineEventEmitter.on('engine-client-changed', () => {
|
16
|
+
node.log('new engineClient received');
|
17
|
+
register();
|
18
|
+
});
|
19
|
+
|
9
20
|
const register = async () => {
|
10
21
|
const client = node.engine.engineClient;
|
11
22
|
|
package/process-start.js
CHANGED
@@ -22,8 +22,8 @@ module.exports = function (RED) {
|
|
22
22
|
return;
|
23
23
|
}
|
24
24
|
|
25
|
-
|
26
|
-
const client =
|
25
|
+
const engine = RED.nodes.getNode(config.engine);
|
26
|
+
const client = engine.engineClient;
|
27
27
|
|
28
28
|
if (!client) {
|
29
29
|
node.error('No engine configured.');
|
@@ -31,7 +31,7 @@ module.exports = function (RED) {
|
|
31
31
|
}
|
32
32
|
|
33
33
|
client.processDefinitions
|
34
|
-
.startProcessInstance(startParameters,
|
34
|
+
.startProcessInstance(startParameters, engine.identity)
|
35
35
|
.then((result) => {
|
36
36
|
msg.payload = result;
|
37
37
|
|
package/process-terminate.js
CHANGED
@@ -4,8 +4,8 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
8
|
-
const client =
|
7
|
+
const engine = RED.nodes.getNode(config.engine);
|
8
|
+
const client = engine.engineClient;
|
9
9
|
|
10
10
|
if (!client) {
|
11
11
|
node.error('No engine configured.');
|
@@ -13,7 +13,7 @@ module.exports = function (RED) {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
client.processInstances
|
16
|
-
.terminateProcessInstance(msg.payload,
|
16
|
+
.terminateProcessInstance(msg.payload, engine.identity)
|
17
17
|
.then(() => {
|
18
18
|
node.send(msg);
|
19
19
|
})
|
@@ -4,7 +4,7 @@
|
|
4
4
|
defaults: {
|
5
5
|
name: { value: '' },
|
6
6
|
url: { value: 'http://engine:8000', required: true },
|
7
|
-
urlType: { type: 'str'
|
7
|
+
urlType: { type: 'str'},
|
8
8
|
clientId: { value: '' },
|
9
9
|
clientIdType: { type: 'str' },
|
10
10
|
clientSecret: { value: '' },
|
@@ -16,17 +16,17 @@
|
|
16
16
|
oneditprepare: function () {
|
17
17
|
$('#node-config-input-url').typedInput({
|
18
18
|
default: 'str',
|
19
|
-
types: ['str', 'env', 'cred'],
|
19
|
+
types: ['str', 'global', 'flow', 'env', 'msg', 'cred'],
|
20
20
|
});
|
21
21
|
|
22
22
|
$('#node-config-input-clientId').typedInput({
|
23
23
|
default: 'str',
|
24
|
-
types: ['str', 'env', 'cred'],
|
24
|
+
types: ['str', 'global', 'flow', 'env', 'msg', 'cred'],
|
25
25
|
});
|
26
26
|
|
27
27
|
$('#node-config-input-clientSecret').typedInput({
|
28
28
|
default: 'str',
|
29
|
-
types: ['str', 'env', 'cred'],
|
29
|
+
types: ['str', 'global', 'flow', 'env', 'msg', 'cred'],
|
30
30
|
});
|
31
31
|
|
32
32
|
$('#node-config-input-url').typedInput('value', this.url);
|
@@ -66,7 +66,7 @@
|
|
66
66
|
</div>
|
67
67
|
<div class="form-row">
|
68
68
|
<label for="node-config-input-clientSecret"><i class="fa fa-bookmark"></i> Client secret</label>
|
69
|
-
<input type="
|
69
|
+
<input type="password" id="node-config-input-clientSecret" />
|
70
70
|
</div>
|
71
71
|
</script>
|
72
72
|
|
@@ -81,6 +81,6 @@ The configuration for the ProcessCube engine.
|
|
81
81
|
|
82
82
|
### References
|
83
83
|
|
84
|
-
-
|
85
|
-
-
|
84
|
+
- [The ProcessCube© Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
85
|
+
- [ProcessCube© LowCode Integration](https://processcube.io/docs/node-red) - LowCode integration in ProcessCube©
|
86
86
|
</script>
|
@@ -1,3 +1,4 @@
|
|
1
|
+
const EventEmitter = require('node:events');
|
1
2
|
const engine_client = require('@5minds/processcube_engine_client');
|
2
3
|
const jwt = require('jwt-decode');
|
3
4
|
const oidc = require('openid-client');
|
@@ -7,92 +8,134 @@ module.exports = function (RED) {
|
|
7
8
|
RED.nodes.createNode(this, n);
|
8
9
|
const node = this;
|
9
10
|
const identityChangedCallbacks = [];
|
10
|
-
|
11
|
+
this.identity = null;
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
this.credentials.clientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
|
14
|
+
this.credentials.clientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
|
14
15
|
|
15
|
-
node.
|
16
|
+
node.eventEmitter = new EventEmitter();
|
17
|
+
|
18
|
+
// set the engine url
|
19
|
+
const stopRefreshing = periodicallyRefreshEngineClient(this, n, 10000);
|
20
|
+
|
21
|
+
this.registerOnIdentityChanged = function (callback) {
|
16
22
|
identityChangedCallbacks.push(callback);
|
17
23
|
};
|
18
24
|
|
19
|
-
|
20
|
-
if (
|
21
|
-
return
|
25
|
+
this.isIdentityReady = function () {
|
26
|
+
if (this.credentials.clientId && this.credentials.clientSecret) {
|
27
|
+
return this.identity != null;
|
22
28
|
} else {
|
23
29
|
return true;
|
24
30
|
}
|
25
31
|
};
|
26
32
|
|
27
|
-
|
33
|
+
this.setIdentity = (identity) => {
|
28
34
|
node.log(`setIdentity: ${JSON.stringify(identity)}`);
|
29
|
-
|
35
|
+
this.identity = identity;
|
30
36
|
|
31
37
|
for (const callback of identityChangedCallbacks) {
|
32
38
|
callback(identity);
|
33
39
|
}
|
34
40
|
};
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
function periodicallyRefreshEngineClient(node, n, intervalMs) {
|
43
|
+
function refreshUrl() {
|
44
|
+
const newUrl = RED.util.evaluateNodeProperty(n.url, n.urlType, node);
|
45
|
+
const newClientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
|
46
|
+
const newClientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
|
47
|
+
|
48
|
+
if (
|
49
|
+
node.url === newUrl &&
|
50
|
+
node.credentials.clientId === newClientId &&
|
51
|
+
node.credentials.clientSecret === newClientSecret
|
52
|
+
) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
|
56
|
+
node.url = newUrl;
|
57
|
+
node.credentials.clientId = newClientId;
|
58
|
+
node.credentials.clientSecret = newClientSecret;
|
59
|
+
|
60
|
+
if (node.credentials.clientId && node.credentials.clientSecret) {
|
61
|
+
if (node.engineClient) {
|
62
|
+
node.eventEmitter.emit('engine-client-dispose');
|
63
|
+
node.engineClient.dispose();
|
64
|
+
}
|
65
|
+
node.engineClient = new engine_client.EngineClient(node.url, () =>
|
66
|
+
getFreshIdentity(node.url, node)
|
67
|
+
);
|
68
|
+
|
69
|
+
node.eventEmitter.emit('engine-client-changed');
|
70
|
+
} else {
|
71
|
+
if (node.engineClient) {
|
72
|
+
node.eventEmitter.emit('engine-client-dispose');
|
73
|
+
node.engineClient.dispose();
|
74
|
+
}
|
75
|
+
node.engineClient = new engine_client.EngineClient(node.url);
|
76
|
+
|
77
|
+
node.eventEmitter.emit('engine-client-changed');
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
refreshUrl();
|
82
|
+
const intervalId = setInterval(refreshUrl, intervalMs);
|
83
|
+
|
84
|
+
return () => clearInterval(intervalId);
|
43
85
|
}
|
44
86
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
async function getFreshIdentity(url, node) {
|
88
|
+
try {
|
89
|
+
if (
|
90
|
+
!RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node) ||
|
91
|
+
!RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node)
|
92
|
+
) {
|
93
|
+
return null;
|
94
|
+
}
|
95
|
+
|
96
|
+
const res = await fetch(url + '/atlas_engine/api/v1/authority', {
|
97
|
+
method: 'GET',
|
98
|
+
headers: {
|
99
|
+
Authorization: `Bearer ZHVtbXlfdG9rZW4=`,
|
100
|
+
'Content-Type': 'application/json',
|
101
|
+
},
|
102
|
+
});
|
103
|
+
|
104
|
+
const body = await res.json();
|
105
|
+
|
106
|
+
const issuer = await oidc.Issuer.discover(body);
|
107
|
+
|
108
|
+
const client = new issuer.Client({
|
109
|
+
client_id: RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node),
|
110
|
+
client_secret: RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node),
|
111
|
+
});
|
112
|
+
|
113
|
+
const tokenSet = await client.grant({
|
114
|
+
grant_type: 'client_credentials',
|
115
|
+
scope: 'engine_etw engine_read engine_write',
|
116
|
+
});
|
117
|
+
|
118
|
+
const accessToken = tokenSet.access_token;
|
119
|
+
const decodedToken = jwt.jwtDecode(accessToken);
|
120
|
+
|
121
|
+
const freshIdentity = {
|
122
|
+
token: tokenSet.access_token,
|
123
|
+
userId: decodedToken.sub,
|
124
|
+
};
|
125
|
+
|
126
|
+
node.setIdentity(freshIdentity);
|
127
|
+
|
128
|
+
return freshIdentity;
|
129
|
+
} catch (e) {
|
130
|
+
node.error(`Could not get fresh identity: ${e}`);
|
131
|
+
}
|
132
|
+
}
|
91
133
|
|
92
134
|
node.on('close', async () => {
|
93
|
-
if (
|
94
|
-
|
95
|
-
|
135
|
+
if (this.engineClient) {
|
136
|
+
stopRefreshing();
|
137
|
+
this.engineClient.dispose();
|
138
|
+
this.engineClient = null;
|
96
139
|
}
|
97
140
|
});
|
98
141
|
}
|
@@ -5,7 +5,7 @@ module.exports = function (RED) {
|
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
7
|
|
8
|
-
|
8
|
+
const engine = RED.nodes.getNode(config.engine);
|
9
9
|
const client = engine.engineClient;
|
10
10
|
|
11
11
|
if (!client) {
|
@@ -17,7 +17,7 @@ module.exports = function (RED) {
|
|
17
17
|
|
18
18
|
query = {
|
19
19
|
...query,
|
20
|
-
identity:
|
20
|
+
identity: engine.identity,
|
21
21
|
};
|
22
22
|
|
23
23
|
node.log(`Querying process definitions with query: ${JSON.stringify(query)}`);
|
@@ -6,8 +6,8 @@
|
|
6
6
|
name: { value: '' },
|
7
7
|
engine: { value: '', type: 'processcube-engine-config' },
|
8
8
|
modelid: { value: '' },
|
9
|
-
|
10
|
-
|
9
|
+
duration: { value: '', type: 'number' },
|
10
|
+
time_unit: { value: 'hours' },
|
11
11
|
},
|
12
12
|
inputs: 1,
|
13
13
|
outputs: 1,
|
@@ -32,12 +32,12 @@
|
|
32
32
|
<input type="text" id="node-input-modelid" />
|
33
33
|
</div>
|
34
34
|
<div class="form-row">
|
35
|
-
<label for="node-input-
|
35
|
+
<label for="node-input-duration"><i class="fa fa-tag"></i> Duration</label>
|
36
36
|
<input type="text" id="node-input-time" />
|
37
37
|
</div>
|
38
38
|
<div class="form-row">
|
39
|
-
<label for="node-input-
|
40
|
-
<select id="node-input-
|
39
|
+
<label for="node-input-time_unit"><i class="fa fa-sliders"></i> Time Unit</label>
|
40
|
+
<select id="node-input-time_unit" style="width: 70%;">
|
41
41
|
<option value="hours">Hours</option>
|
42
42
|
<option value="days">Days</option>
|
43
43
|
</select>
|
@@ -4,21 +4,21 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', async function (msg) {
|
7
|
-
|
8
|
-
const client =
|
7
|
+
const engine = RED.nodes.getNode(config.engine);
|
8
|
+
const client = engine.engineClient;
|
9
9
|
|
10
10
|
if (!client) {
|
11
11
|
node.error('No engine configured.');
|
12
12
|
return;
|
13
13
|
}
|
14
14
|
let timeMultiplier;
|
15
|
-
if (msg.payload.
|
16
|
-
timeMultiplier = msg.payload.
|
15
|
+
if (msg.payload.time_unit) {
|
16
|
+
timeMultiplier = msg.payload.time_unit == 'hours' ? 1 : 24;
|
17
17
|
} else {
|
18
|
-
timeMultiplier = config.
|
18
|
+
timeMultiplier = config.time_unit == 'hours' ? 1 : 24;
|
19
19
|
}
|
20
20
|
|
21
|
-
const timeToUse = msg.payload.
|
21
|
+
const timeToUse = msg.payload.duration ? msg.payload.duration : config.duration;
|
22
22
|
const modelId = msg.payload.processModelId
|
23
23
|
? msg.payload.processModelId != ''
|
24
24
|
? msg.payload.processModelId
|
@@ -30,7 +30,7 @@ module.exports = function (RED) {
|
|
30
30
|
try {
|
31
31
|
const result = await client.processInstances.query({
|
32
32
|
processModelId: modelId
|
33
|
-
}, { identity:
|
33
|
+
}, { identity: engine.identity });
|
34
34
|
|
35
35
|
let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended');
|
36
36
|
|
@@ -45,7 +45,7 @@ module.exports = function (RED) {
|
|
45
45
|
const ids = oldTasks.map((obj) => obj.processInstanceId);
|
46
46
|
msg.payload = ids;
|
47
47
|
|
48
|
-
await client.processInstances.deleteProcessInstances(ids, true,
|
48
|
+
await client.processInstances.deleteProcessInstances(ids, true, engine.identity);
|
49
49
|
node.send(msg);
|
50
50
|
} catch (error) {
|
51
51
|
node.error(error);
|
package/processinstance-query.js
CHANGED
@@ -6,8 +6,8 @@ module.exports = function (RED) {
|
|
6
6
|
node.on('input', function (msg) {
|
7
7
|
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
8
8
|
|
9
|
-
|
10
|
-
const client =
|
9
|
+
const engine = RED.nodes.getNode(config.engine);
|
10
|
+
const client = engine.engineClient;
|
11
11
|
|
12
12
|
if (!client) {
|
13
13
|
node.error('No engine configured.');
|
@@ -15,7 +15,7 @@ module.exports = function (RED) {
|
|
15
15
|
}
|
16
16
|
|
17
17
|
client.processInstances
|
18
|
-
.query(query, { identity:
|
18
|
+
.query(query, { identity: engine.identity })
|
19
19
|
.then((matchingInstances) => {
|
20
20
|
msg.payload = matchingInstances;
|
21
21
|
|
package/signal-event-trigger.js
CHANGED
@@ -4,9 +4,9 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
7
|
+
const engine = RED.nodes.getNode(config.engine);
|
8
8
|
|
9
|
-
const client =
|
9
|
+
const client = engine.engineClient;
|
10
10
|
|
11
11
|
if (!client) {
|
12
12
|
node.error('No engine configured.');
|
@@ -17,7 +17,7 @@ module.exports = function (RED) {
|
|
17
17
|
.triggerSignalEvent(config.signalname, {
|
18
18
|
processInstanceId: msg.processinstanceid,
|
19
19
|
payload: msg.payload,
|
20
|
-
identity:
|
20
|
+
identity: engine.identity,
|
21
21
|
})
|
22
22
|
.then((result) => {
|
23
23
|
msg.payload = result;
|
@@ -6,6 +6,17 @@ module.exports = function (RED) {
|
|
6
6
|
|
7
7
|
let subscription;
|
8
8
|
|
9
|
+
const eventEmitter = node.engine.eventEmitter;
|
10
|
+
|
11
|
+
eventEmitter.on('engine-client-dispose', () => {
|
12
|
+
node.engine.engineClient.userTasks.removeSubscription(subscription, node.engine.identity);
|
13
|
+
});
|
14
|
+
|
15
|
+
eventEmitter.on('engine-client-changed', () => {
|
16
|
+
node.log('new engineClient received');
|
17
|
+
register();
|
18
|
+
});
|
19
|
+
|
9
20
|
const register = async () => {
|
10
21
|
let currentIdentity = node.engine.identity;
|
11
22
|
|
package/usertask-input.js
CHANGED
@@ -4,9 +4,9 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
7
|
+
const engine = RED.nodes.getNode(config.engine);
|
8
8
|
|
9
|
-
const client =
|
9
|
+
const client = engine.engineClient;
|
10
10
|
|
11
11
|
if (!client) {
|
12
12
|
node.error('No engine configured.');
|
@@ -20,7 +20,7 @@ module.exports = function (RED) {
|
|
20
20
|
};
|
21
21
|
|
22
22
|
client.userTasks
|
23
|
-
.query(query, { identity:
|
23
|
+
.query(query, { identity: engine.identity })
|
24
24
|
.then((matchingFlowNodes) => {
|
25
25
|
if (config.sendtype === 'array') {
|
26
26
|
msg.payload = { userTasks: matchingFlowNodes.userTasks || [] };
|
package/usertask-output.js
CHANGED
@@ -9,9 +9,9 @@ module.exports = function (RED) {
|
|
9
9
|
|
10
10
|
const userTaskResult = RED.util.evaluateNodeProperty(config.result, config.result_type, node, msg);
|
11
11
|
|
12
|
-
|
12
|
+
const engine = RED.nodes.getNode(config.engine);
|
13
13
|
|
14
|
-
const client =
|
14
|
+
const client = engine.engineClient;
|
15
15
|
|
16
16
|
if (!client) {
|
17
17
|
node.error('No engine configured.');
|
@@ -19,7 +19,7 @@ module.exports = function (RED) {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
client.userTasks
|
22
|
-
.finishUserTask(flowNodeInstanceId, userTaskResult,
|
22
|
+
.finishUserTask(flowNodeInstanceId, userTaskResult, engine.identity)
|
23
23
|
.then(() => {
|
24
24
|
node.send(msg);
|
25
25
|
})
|