@5minds/node-red-contrib-processcube 1.5.10 → 1.5.11-develop-034baa-m4sa5pvu
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 +6 -37
- package/externaltask-event-listener.js +5 -35
- package/externaltask-input.js +3 -15
- package/message-event-trigger.js +3 -5
- package/package.json +2 -2
- package/process-event-listener.js +279 -396
- package/process-start.js +14 -5
- package/process-terminate.js +4 -4
- package/processcube-engine-config.html +7 -7
- package/processcube-engine-config.js +16 -122
- package/processdefinition-query.js +24 -28
- package/processinstance-delete.html +56 -9
- package/processinstance-delete.js +30 -12
- package/processinstance-query.js +3 -3
- package/signal-event-trigger.js +4 -5
- package/usertask-event-listener.js +8 -42
- package/usertask-input.js +4 -8
- package/usertask-output.js +5 -5
- package/wait-for-usertask.js +27 -45
package/process-start.js
CHANGED
@@ -4,7 +4,6 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
8
7
|
const initialToken = RED.util.encodeObject(msg.payload);
|
9
8
|
|
10
9
|
const startParameters = {
|
@@ -13,8 +12,18 @@ module.exports = function (RED) {
|
|
13
12
|
initialToken: initialToken,
|
14
13
|
};
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
if (!startParameters.processModelId) {
|
16
|
+
node.error('No processModelId configured.');
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
|
20
|
+
if (!startParameters.startEventId) {
|
21
|
+
node.error('No startEventId configured.');
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
|
25
|
+
node.engine = RED.nodes.getNode(config.engine);
|
26
|
+
const client = node.engine.engineClient;
|
18
27
|
|
19
28
|
if (!client) {
|
20
29
|
node.error('No engine configured.');
|
@@ -22,7 +31,7 @@ module.exports = function (RED) {
|
|
22
31
|
}
|
23
32
|
|
24
33
|
client.processDefinitions
|
25
|
-
.startProcessInstance(startParameters
|
34
|
+
.startProcessInstance(startParameters)
|
26
35
|
.then((result) => {
|
27
36
|
msg.payload = result;
|
28
37
|
|
@@ -34,7 +43,7 @@ module.exports = function (RED) {
|
|
34
43
|
});
|
35
44
|
})
|
36
45
|
.catch((error) => {
|
37
|
-
node.error(error);
|
46
|
+
node.error(JSON.stringify(error));
|
38
47
|
});
|
39
48
|
});
|
40
49
|
}
|
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 = engine.engineClient;
|
7
|
+
node.engine = RED.nodes.getNode(config.engine);
|
8
|
+
const client = node.engine.engineClient;
|
9
9
|
|
10
10
|
if (!client) {
|
11
11
|
node.error('No engine configured.');
|
@@ -13,12 +13,12 @@ module.exports = function (RED) {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
client.processInstances
|
16
|
-
.terminateProcessInstance(msg.payload
|
16
|
+
.terminateProcessInstance(msg.payload)
|
17
17
|
.then(() => {
|
18
18
|
node.send(msg);
|
19
19
|
})
|
20
20
|
.catch((error) => {
|
21
|
-
node.error(error);
|
21
|
+
node.error(JSON.stringify(error));
|
22
22
|
});
|
23
23
|
});
|
24
24
|
}
|
@@ -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', '
|
19
|
+
types: ['str', 'env', 'cred'],
|
20
20
|
});
|
21
21
|
|
22
22
|
$('#node-config-input-clientId').typedInput({
|
23
23
|
default: 'str',
|
24
|
-
types: ['str', '
|
24
|
+
types: ['str', 'env', 'cred'],
|
25
25
|
});
|
26
26
|
|
27
27
|
$('#node-config-input-clientSecret').typedInput({
|
28
28
|
default: 'str',
|
29
|
-
types: ['str', '
|
29
|
+
types: ['str', 'env', '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="text" 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,4 +1,3 @@
|
|
1
|
-
const EventEmitter = require('node:events');
|
2
1
|
const engine_client = require('@5minds/processcube_engine_client');
|
3
2
|
const jwt = require('jwt-decode');
|
4
3
|
const oidc = require('openid-client');
|
@@ -7,138 +6,33 @@ module.exports = function (RED) {
|
|
7
6
|
function ProcessCubeEngineNode(n) {
|
8
7
|
RED.nodes.createNode(this, n);
|
9
8
|
const node = this;
|
10
|
-
const identityChangedCallbacks = [];
|
11
|
-
this.identity = null;
|
12
9
|
|
13
|
-
|
14
|
-
|
10
|
+
node.url = RED.util.evaluateNodeProperty(n.url, n.urlType, node);
|
11
|
+
node.credentials.clientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
|
12
|
+
node.credentials.clientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
this.registerOnIdentityChanged = function (callback) {
|
22
|
-
identityChangedCallbacks.push(callback);
|
23
|
-
};
|
24
|
-
|
25
|
-
this.isIdentityReady = function () {
|
26
|
-
if (this.credentials.clientId && this.credentials.clientSecret) {
|
27
|
-
return this.identity != null;
|
28
|
-
} else {
|
29
|
-
return true;
|
30
|
-
}
|
31
|
-
};
|
32
|
-
|
33
|
-
this.setIdentity = (identity) => {
|
34
|
-
node.log(`setIdentity: ${JSON.stringify(identity)}`);
|
35
|
-
this.identity = identity;
|
36
|
-
|
37
|
-
for (const callback of identityChangedCallbacks) {
|
38
|
-
callback(identity);
|
39
|
-
}
|
40
|
-
};
|
41
|
-
|
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);
|
85
|
-
}
|
86
|
-
|
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',
|
14
|
+
try {
|
15
|
+
if (node.credentials.clientId && node.credentials.clientSecret) {
|
16
|
+
node.engineClient = new engine_client.EngineClient(node.url, {
|
17
|
+
clientId: node.credentials.clientId,
|
18
|
+
clientSecret: node.credentials.clientSecret,
|
115
19
|
scope: 'engine_etw engine_read engine_write',
|
116
20
|
});
|
117
|
-
|
118
|
-
|
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}`);
|
21
|
+
} else {
|
22
|
+
node.engineClient = new engine_client.EngineClient(node.url);
|
131
23
|
}
|
24
|
+
} catch (error) {
|
25
|
+
node.error(JSON.stringify(error));
|
132
26
|
}
|
133
27
|
|
134
28
|
node.on('close', async () => {
|
135
|
-
if (
|
136
|
-
|
137
|
-
|
138
|
-
this.engineClient = null;
|
29
|
+
if (node.engineClient) {
|
30
|
+
node.engineClient.dispose();
|
31
|
+
node.engineClient = null;
|
139
32
|
}
|
140
33
|
});
|
141
34
|
}
|
35
|
+
|
142
36
|
RED.nodes.registerType('processcube-engine-config', ProcessCubeEngineNode, {
|
143
37
|
credentials: {
|
144
38
|
clientId: { type: 'text' },
|
@@ -4,8 +4,7 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
8
|
-
const engine = RED.nodes.getNode(config.engine);
|
7
|
+
node.engine = RED.nodes.getNode(config.engine);
|
9
8
|
const client = engine.engineClient;
|
10
9
|
|
11
10
|
if (!client) {
|
@@ -14,37 +13,34 @@ module.exports = function (RED) {
|
|
14
13
|
}
|
15
14
|
|
16
15
|
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
17
|
-
|
18
|
-
query = {
|
19
|
-
...query,
|
20
|
-
identity: engine.identity,
|
21
|
-
};
|
22
16
|
|
23
17
|
node.log(`Querying process definitions with query: ${JSON.stringify(query)}`);
|
24
|
-
|
25
|
-
client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
|
26
18
|
|
27
|
-
|
28
|
-
|
19
|
+
client.processDefinitions
|
20
|
+
.getAll(query)
|
21
|
+
.then((matchingProcessDefinitions) => {
|
22
|
+
if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
|
23
|
+
let models = [];
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
matchingProcessDefinitions.processDefinitions.forEach((processDefinition) => {
|
26
|
+
processDefinition.processModels.forEach((model) => {
|
27
|
+
models.push(model);
|
28
|
+
});
|
33
29
|
});
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
30
|
+
|
31
|
+
msg.payload = {
|
32
|
+
models: models,
|
33
|
+
totalCount: models.length,
|
34
|
+
};
|
35
|
+
} else {
|
36
|
+
msg.payload = matchingProcessDefinitions;
|
37
|
+
}
|
38
|
+
|
39
|
+
node.send(msg);
|
40
|
+
})
|
41
|
+
.catch((error) => {
|
42
|
+
node.error(JSON.stringify(error));
|
43
|
+
});
|
48
44
|
});
|
49
45
|
}
|
50
46
|
RED.nodes.registerType('processdefinition-query', ProcessdefinitionQuery);
|
@@ -6,8 +6,9 @@
|
|
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
|
+
batch_size: { value: '100', type: 'number' },
|
11
12
|
},
|
12
13
|
inputs: 1,
|
13
14
|
outputs: 1,
|
@@ -32,16 +33,20 @@
|
|
32
33
|
<input type="text" id="node-input-modelid" />
|
33
34
|
</div>
|
34
35
|
<div class="form-row">
|
35
|
-
<label for="node-input-
|
36
|
-
<input type="text" id="node-input-
|
36
|
+
<label for="node-input-duration"><i class="fa fa-tag"></i> Duration</label>
|
37
|
+
<input type="text" id="node-input-duration" />
|
37
38
|
</div>
|
38
39
|
<div class="form-row">
|
39
|
-
<label for="node-input-
|
40
|
-
<select id="node-input-
|
40
|
+
<label for="node-input-time_unit"><i class="fa fa-sliders"></i> Time Unit</label>
|
41
|
+
<select id="node-input-time_unit" style="width: 70%;">
|
41
42
|
<option value="hours">Hours</option>
|
42
43
|
<option value="days">Days</option>
|
43
44
|
</select>
|
44
45
|
</div>
|
46
|
+
<div class="form-row">
|
47
|
+
<label for="node-input-batch-size"><i class="fa fa-tag"></i> Batch Size</label>
|
48
|
+
<input type="text" id="node-input-batch_size" />
|
49
|
+
</div>
|
45
50
|
</script>
|
46
51
|
|
47
52
|
<script type="text/markdown" data-help-name="processinstance-delete">
|
@@ -49,12 +54,54 @@ Delete old instances of a process model in the ProcessCube.
|
|
49
54
|
|
50
55
|
## Inputs
|
51
56
|
|
52
|
-
: payload.
|
53
|
-
: payload.
|
57
|
+
: payload.duration (number): The number of given time periods.
|
58
|
+
: payload.time_unit ('hours' | 'days'): The type of time period to use.
|
59
|
+
: payload.batch_size (number): The number of instances to be deleted simultaneously. (default 100)
|
54
60
|
|
55
61
|
## Outputs
|
56
62
|
|
57
|
-
:
|
63
|
+
: Explanation of the payload:
|
64
|
+
|
65
|
+
Object
|
66
|
+
{
|
67
|
+
successfulDeletions: [Array of strings],
|
68
|
+
failedDeletions: [Array of objects]
|
69
|
+
}
|
70
|
+
|
71
|
+
- successfulDeletions:
|
72
|
+
- Type: Array<String>
|
73
|
+
- Content: A list of successfully deleted process instance IDs.
|
74
|
+
|
75
|
+
- excample:
|
76
|
+
successfulDeletions: [
|
77
|
+
"instanceId1",
|
78
|
+
"instanceId2",
|
79
|
+
"instanceId3"
|
80
|
+
]
|
81
|
+
|
82
|
+
- failedDeletions:
|
83
|
+
- Type: Array<Object>
|
84
|
+
- Content: A list of objects containing details of the failed deletions.
|
85
|
+
- Each object has the following fields:
|
86
|
+
- id: The ID of the process instance that could not be deleted.
|
87
|
+
- error: The error message or the reason for the error.
|
88
|
+
|
89
|
+
- Example of a complete output:
|
90
|
+
{
|
91
|
+
successfulDeletions: [
|
92
|
+
"instanceId1",
|
93
|
+
"instanceId2",
|
94
|
+
"instanceId3"
|
95
|
+
],
|
96
|
+
failedDeletions: [
|
97
|
+
{ id: "instanceId4", error: "Permission denied" },
|
98
|
+
{ id: "instanceId5", error: "Instance not found" }
|
99
|
+
]
|
100
|
+
}
|
101
|
+
|
102
|
+
The node processes the IDs in configurable batches (default value: 100) and inserts successfully deleted or failed instances into the arrays accordingly.
|
103
|
+
As processing is currently forced to batch, a detailed error output is not possible.
|
104
|
+
If an error occurs during the processing of a batch, all Id's of this batch are marked as faulty.
|
58
105
|
|
59
106
|
### References
|
60
107
|
|
@@ -4,21 +4,22 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', async function (msg) {
|
7
|
-
|
8
|
-
const client = engine.engineClient;
|
7
|
+
node.engine = RED.nodes.getNode(config.engine);
|
8
|
+
const client = node.engine.engineClient;
|
9
9
|
|
10
10
|
if (!client) {
|
11
11
|
node.error('No engine configured.');
|
12
12
|
return;
|
13
13
|
}
|
14
|
+
|
14
15
|
let timeMultiplier;
|
15
|
-
if (msg.payload.
|
16
|
-
timeMultiplier = msg.payload.
|
16
|
+
if (msg.payload.time_unit) {
|
17
|
+
timeMultiplier = msg.payload.time_unit == 'hours' ? 1 : 24;
|
17
18
|
} else {
|
18
|
-
timeMultiplier = config.
|
19
|
+
timeMultiplier = config.time_unit == 'hours' ? 1 : 24;
|
19
20
|
}
|
20
21
|
|
21
|
-
const timeToUse = msg.payload.
|
22
|
+
const timeToUse = msg.payload.duration ? msg.payload.duration : config.duration;
|
22
23
|
const modelId = msg.payload.processModelId
|
23
24
|
? msg.payload.processModelId != ''
|
24
25
|
? msg.payload.processModelId
|
@@ -27,12 +28,14 @@ module.exports = function (RED) {
|
|
27
28
|
? config.modelid
|
28
29
|
: undefined;
|
29
30
|
|
31
|
+
const batchSize = config.batch_size || 100; // Konfigurierbare Batchgröße, Standardwert 100
|
32
|
+
|
30
33
|
try {
|
31
34
|
const result = await client.processInstances.query({
|
32
35
|
processModelId: modelId
|
33
|
-
}, { identity: engine.identity });
|
36
|
+
}, { identity: node.engine.identity });
|
34
37
|
|
35
|
-
let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended');
|
38
|
+
let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended' && instance.state != 'running');
|
36
39
|
|
37
40
|
const today = new Date();
|
38
41
|
|
@@ -43,12 +46,27 @@ module.exports = function (RED) {
|
|
43
46
|
});
|
44
47
|
|
45
48
|
const ids = oldTasks.map((obj) => obj.processInstanceId);
|
46
|
-
msg.payload = ids;
|
47
49
|
|
48
|
-
|
50
|
+
msg.payload = {
|
51
|
+
successfulDeletions: [],
|
52
|
+
failedDeletions: []
|
53
|
+
};
|
54
|
+
|
55
|
+
for (let i = 0; i < ids.length; i += batchSize) {
|
56
|
+
const batch = ids.slice(i, i + batchSize);
|
57
|
+
try {
|
58
|
+
await client.processInstances.deleteProcessInstances(batch, true, engine.identity);
|
59
|
+
msg.payload.successfulDeletions.push(...batch); // Erfolgreiche IDs hinzufügen
|
60
|
+
} catch (deleteError) {
|
61
|
+
batch.forEach(id => {
|
62
|
+
msg.payload.failedDeletions.push({ id, error: deleteError.message }); // Fehler protokollieren
|
63
|
+
});
|
64
|
+
node.warn(`Failed to delete process instances in batch: ${batch.join(', ')}. Error: ${deleteError.message}`);
|
65
|
+
}
|
66
|
+
}
|
49
67
|
node.send(msg);
|
50
|
-
} catch (
|
51
|
-
node.error(
|
68
|
+
} catch (queryError) {
|
69
|
+
node.error(`Failed to query process instances: ${queryError.message}`);
|
52
70
|
}
|
53
71
|
});
|
54
72
|
}
|
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 = engine.engineClient;
|
9
|
+
node.engine = RED.nodes.getNode(config.engine);
|
10
|
+
const client = node.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
|
18
|
+
.query(query)
|
19
19
|
.then((matchingInstances) => {
|
20
20
|
msg.payload = matchingInstances;
|
21
21
|
|
package/signal-event-trigger.js
CHANGED
@@ -4,20 +4,19 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
7
|
+
node.engine = RED.nodes.getNode(config.engine);
|
8
8
|
|
9
|
-
const client = engine.engineClient;
|
9
|
+
const client = node.engine.engineClient;
|
10
10
|
|
11
11
|
if (!client) {
|
12
12
|
node.error('No engine configured.');
|
13
13
|
return;
|
14
14
|
}
|
15
|
-
|
15
|
+
|
16
16
|
client.events
|
17
17
|
.triggerSignalEvent(config.signalname, {
|
18
18
|
processInstanceId: msg.processinstanceid,
|
19
19
|
payload: msg.payload,
|
20
|
-
identity: engine.identity,
|
21
20
|
})
|
22
21
|
.then((result) => {
|
23
22
|
msg.payload = result;
|
@@ -30,7 +29,7 @@ module.exports = function (RED) {
|
|
30
29
|
});
|
31
30
|
})
|
32
31
|
.catch((error) => {
|
33
|
-
node.error(error);
|
32
|
+
node.error(JSON.stringify(error));
|
34
33
|
});
|
35
34
|
});
|
36
35
|
}
|
@@ -6,20 +6,7 @@ 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
|
-
|
20
9
|
const register = async () => {
|
21
|
-
let currentIdentity = node.engine.identity;
|
22
|
-
|
23
10
|
const client = node.engine.engineClient;
|
24
11
|
|
25
12
|
if (!client) {
|
@@ -39,9 +26,7 @@ module.exports = function (RED) {
|
|
39
26
|
};
|
40
27
|
|
41
28
|
try {
|
42
|
-
const matchingFlowNodes = await client.userTasks.query(newQuery
|
43
|
-
identity: currentIdentity,
|
44
|
-
});
|
29
|
+
const matchingFlowNodes = await client.userTasks.query(newQuery);
|
45
30
|
|
46
31
|
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
47
32
|
const userTask = matchingFlowNodes.userTasks[0];
|
@@ -57,7 +42,7 @@ module.exports = function (RED) {
|
|
57
42
|
});
|
58
43
|
}
|
59
44
|
} catch (error) {
|
60
|
-
node.error(error);
|
45
|
+
node.error(JSON.stringify(error));
|
61
46
|
}
|
62
47
|
};
|
63
48
|
}
|
@@ -65,42 +50,23 @@ module.exports = function (RED) {
|
|
65
50
|
async function subscribe() {
|
66
51
|
switch (config.eventtype) {
|
67
52
|
case 'new':
|
68
|
-
return await client.userTasks.onUserTaskWaiting(userTaskCallback()
|
69
|
-
identity: currentIdentity,
|
70
|
-
});
|
53
|
+
return await client.userTasks.onUserTaskWaiting(userTaskCallback());
|
71
54
|
case 'finished':
|
72
|
-
return await client.userTasks.onUserTaskFinished(userTaskCallback()
|
73
|
-
identity: currentIdentity,
|
74
|
-
});
|
55
|
+
return await client.userTasks.onUserTaskFinished(userTaskCallback());
|
75
56
|
case 'reserved':
|
76
|
-
return await client.userTasks.onUserTaskReserved(userTaskCallback()
|
77
|
-
identity: currentIdentity,
|
78
|
-
});
|
57
|
+
return await client.userTasks.onUserTaskReserved(userTaskCallback());
|
79
58
|
case 'reservation-canceled':
|
80
|
-
return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback()
|
81
|
-
identity: currentIdentity,
|
82
|
-
});
|
59
|
+
return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback());
|
83
60
|
default:
|
84
61
|
console.error('no such event: ' + config.eventtype);
|
85
62
|
}
|
86
63
|
}
|
87
64
|
|
88
|
-
|
89
|
-
subscription = subscribe();
|
90
|
-
}
|
91
|
-
|
92
|
-
node.engine.registerOnIdentityChanged(async (identity) => {
|
93
|
-
if (subscription) {
|
94
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
95
|
-
}
|
96
|
-
currentIdentity = identity;
|
97
|
-
|
98
|
-
subscription = subscribe();
|
99
|
-
});
|
65
|
+
subscription = subscribe();
|
100
66
|
|
101
67
|
node.on('close', async () => {
|
102
68
|
if (node.engine && node.engine.engineClient && client) {
|
103
|
-
client.userTasks.removeSubscription(subscription
|
69
|
+
client.userTasks.removeSubscription(subscription);
|
104
70
|
}
|
105
71
|
});
|
106
72
|
};
|