@5minds/node-red-contrib-processcube 1.5.5-develop-08b6df-m3hqaxvp → 1.5.5-develop-21476e-m3hs5zs1

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.
@@ -13,36 +13,37 @@ module.exports = function (RED) {
13
13
  }
14
14
 
15
15
  let currentIdentity = node.engine.identity;
16
- let subscription = await client.events.onEndEventFinished(
17
- (endEventFinished) => {
18
- node.send({
19
- payload: endEventFinished,
20
- });
21
- },
22
- { identity: currentIdentity },
23
- ).catch((error) => {
24
- node.error(error);
25
- });
26
16
 
27
- node.engine.registerOnIdentityChanged(async (identity) => {
28
- client.events.removeSubscription(subscription, currentIdentity);
29
-
30
- currentIdentity = identity;
17
+ let subscription = null;
31
18
 
19
+ try {
32
20
  subscription = await client.events.onEndEventFinished(
33
21
  (endEventFinished) => {
34
22
  node.send({
35
- payload: endEventFinished
23
+ payload: endEventFinished,
36
24
  });
37
25
  },
38
26
  { identity: currentIdentity },
39
- ).catch((error) => {
40
- node.error(error);
27
+ );
28
+
29
+ node.engine.registerOnIdentityChanged(async (identity) => {
30
+ client.events.removeSubscription(subscription, currentIdentity);
31
+
32
+ currentIdentity = identity;
33
+
34
+ subscription = await client.events.onEndEventFinished(
35
+ (endEventFinished) => {
36
+ node.send({
37
+ payload: endEventFinished
38
+ });
39
+ },
40
+ { identity: currentIdentity },
41
+ );
41
42
  });
42
43
 
43
- }).catch((error) => {
44
+ } catch (error) {
44
45
  node.error(error);
45
- });
46
+ }
46
47
 
47
48
  node.on('close', async () => {
48
49
  if (node.engine && node.engine.engineClient && client) {
@@ -241,7 +241,7 @@
241
241
  "fc23f271b106648f"
242
242
  ],
243
243
  "x": 34,
244
- "y": 259,
244
+ "y": 239,
245
245
  "w": 652,
246
246
  "h": 202
247
247
  },
@@ -467,6 +467,30 @@
467
467
  "w": 572,
468
468
  "h": 142
469
469
  },
470
+ {
471
+ "id": "3f3c01daebb2d215",
472
+ "type": "group",
473
+ "z": "fd3c725340de4f74",
474
+ "style": {
475
+ "stroke": "#999999",
476
+ "stroke-opacity": "1",
477
+ "fill": "none",
478
+ "fill-opacity": "1",
479
+ "label": true,
480
+ "label-position": "nw",
481
+ "color": "#a4a4a4"
482
+ },
483
+ "nodes": [
484
+ "2fadb4c4667ecaf2",
485
+ "93331783b7ef3fc5",
486
+ "bc26f9821540f097",
487
+ "cc3fb9c2cb0edd3a"
488
+ ],
489
+ "x": 34,
490
+ "y": 459,
491
+ "w": 552,
492
+ "h": 142
493
+ },
470
494
  {
471
495
  "id": "42e6796dddd9d4db",
472
496
  "type": "processcube-engine-config",
@@ -479,17 +503,6 @@
479
503
  "name": "Engine Auth 8000",
480
504
  "url": "http://engine:8000"
481
505
  },
482
- {
483
- "id": "392373f3e1403770",
484
- "type": "processcube-engine-config",
485
- "name": "",
486
- "url": "http://host.docker.internal:56000",
487
- "urlType": "str",
488
- "clientId": "",
489
- "clientIdType": "str",
490
- "clientSecret": "",
491
- "clientSecretType": "str"
492
- },
493
506
  {
494
507
  "id": "2991a5e6df2b87d2",
495
508
  "type": "externaltask-input",
@@ -498,6 +511,8 @@
498
511
  "name": "Test",
499
512
  "engine": "42e6796dddd9d4db",
500
513
  "topic": "Test",
514
+ "workerConfig": "{}",
515
+ "workerConfigType": "json",
501
516
  "x": 110,
502
517
  "y": 180,
503
518
  "wires": [
@@ -550,6 +565,8 @@
550
565
  "name": "SampleError",
551
566
  "engine": "42e6796dddd9d4db",
552
567
  "topic": "SampleError",
568
+ "workerConfig": "{}",
569
+ "workerConfigType": "json",
553
570
  "x": 130,
554
571
  "y": 360,
555
572
  "wires": [
@@ -809,6 +826,8 @@
809
826
  "name": "Test_Auth",
810
827
  "engine": "b78932d162d8d468",
811
828
  "topic": "Test_Auth",
829
+ "workerConfig": "{}",
830
+ "workerConfigType": "json",
812
831
  "x": 120,
813
832
  "y": 180,
814
833
  "wires": [
@@ -872,6 +891,8 @@
872
891
  "name": "SampleError_Auth",
873
892
  "engine": "b78932d162d8d468",
874
893
  "topic": "SampleError_Auth",
894
+ "workerConfig": "{}",
895
+ "workerConfigType": "json",
875
896
  "x": 150,
876
897
  "y": 360,
877
898
  "wires": [
@@ -1131,7 +1152,7 @@
1131
1152
  "query": "payload",
1132
1153
  "query_type": "msg",
1133
1154
  "x": 180,
1134
- "y": 420,
1155
+ "y": 400,
1135
1156
  "wires": [
1136
1157
  [
1137
1158
  "8ef39e83173d41e3"
@@ -1152,7 +1173,7 @@
1152
1173
  "finalize": "",
1153
1174
  "libs": [],
1154
1175
  "x": 390,
1155
- "y": 420,
1176
+ "y": 400,
1156
1177
  "wires": [
1157
1178
  [
1158
1179
  "f524b8cc35d56849"
@@ -1169,7 +1190,7 @@
1169
1190
  "result": "payload.result",
1170
1191
  "result_type": "msg",
1171
1192
  "x": 580,
1172
- "y": 420,
1193
+ "y": 400,
1173
1194
  "wires": [
1174
1195
  []
1175
1196
  ]
@@ -1182,7 +1203,7 @@
1182
1203
  "name": "Demo to listen on a new usertask an finish them",
1183
1204
  "info": "",
1184
1205
  "x": 240,
1185
- "y": 300,
1206
+ "y": 280,
1186
1207
  "wires": []
1187
1208
  },
1188
1209
  {
@@ -1197,7 +1218,7 @@
1197
1218
  "query": "{}",
1198
1219
  "query_type": "json",
1199
1220
  "x": 160,
1200
- "y": 360,
1221
+ "y": 340,
1201
1222
  "wires": [
1202
1223
  [
1203
1224
  "f7c7682e3a6adaaa"
@@ -1242,6 +1263,72 @@
1242
1263
  ]
1243
1264
  ]
1244
1265
  },
1266
+ {
1267
+ "id": "2fadb4c4667ecaf2",
1268
+ "type": "usertask-input",
1269
+ "z": "fd3c725340de4f74",
1270
+ "g": "3f3c01daebb2d215",
1271
+ "name": "",
1272
+ "engine": "42e6796dddd9d4db",
1273
+ "query": "{\"flowNodeId\":\"gibt_es_nicht\"}",
1274
+ "query_type": "json",
1275
+ "sendtype": "array",
1276
+ "x": 300,
1277
+ "y": 560,
1278
+ "wires": [
1279
+ [
1280
+ "bc26f9821540f097"
1281
+ ]
1282
+ ]
1283
+ },
1284
+ {
1285
+ "id": "93331783b7ef3fc5",
1286
+ "type": "inject",
1287
+ "z": "fd3c725340de4f74",
1288
+ "g": "3f3c01daebb2d215",
1289
+ "name": "",
1290
+ "props": [],
1291
+ "repeat": "",
1292
+ "crontab": "",
1293
+ "once": false,
1294
+ "onceDelay": 0.1,
1295
+ "topic": "",
1296
+ "x": 130,
1297
+ "y": 560,
1298
+ "wires": [
1299
+ [
1300
+ "2fadb4c4667ecaf2"
1301
+ ]
1302
+ ]
1303
+ },
1304
+ {
1305
+ "id": "bc26f9821540f097",
1306
+ "type": "debug",
1307
+ "z": "fd3c725340de4f74",
1308
+ "g": "3f3c01daebb2d215",
1309
+ "name": "debug 34",
1310
+ "active": true,
1311
+ "tosidebar": true,
1312
+ "console": false,
1313
+ "tostatus": false,
1314
+ "complete": "false",
1315
+ "statusVal": "",
1316
+ "statusType": "auto",
1317
+ "x": 480,
1318
+ "y": 560,
1319
+ "wires": []
1320
+ },
1321
+ {
1322
+ "id": "cc3fb9c2cb0edd3a",
1323
+ "type": "comment",
1324
+ "z": "fd3c725340de4f74",
1325
+ "g": "3f3c01daebb2d215",
1326
+ "name": "Search UserTasks",
1327
+ "info": "",
1328
+ "x": 150,
1329
+ "y": 500,
1330
+ "wires": []
1331
+ },
1245
1332
  {
1246
1333
  "id": "c4f20aefe585bdad",
1247
1334
  "type": "comment",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.5.5-develop-08b6df-m3hqaxvp",
3
+ "version": "1.5.5-develop-21476e-m3hs5zs1",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -24,80 +24,84 @@ module.exports = function (RED) {
24
24
  async (processNotification) => {
25
25
  if (
26
26
  config.processmodel != '' &&
27
- config.processmodel != processNotification.processModelId
28
- )
27
+ config.processmodel != processNotification.processModelId) {
29
28
  return;
29
+ }
30
+
30
31
  const newQuery = {
31
32
  processInstanceId: processNotification.processInstanceId,
32
33
  ...query,
33
34
  };
34
35
 
35
- const matchingInstances = await client.processInstances.query(newQuery, {
36
- identity: currentIdentity,
37
- });
38
-
39
- if (
40
- matchingInstances.processInstances &&
41
- matchingInstances.processInstances.length == 1
42
- ) {
43
- const processInstance = matchingInstances.processInstances[0];
44
-
45
- node.send({
46
- payload: {
47
- processInstanceId: processNotification.processInstanceId,
48
- processModelId: processNotification.processModelId,
49
- processInstance: processInstance,
50
- action: 'starting',
51
- type: 'processInstance',
52
- },
36
+ try {
37
+ const matchingInstances = await client.processInstances.query(newQuery, {
38
+ identity: currentIdentity,
53
39
  });
40
+
41
+ if (
42
+ matchingInstances.processInstances &&
43
+ matchingInstances.processInstances.length == 1
44
+ ) {
45
+ const processInstance = matchingInstances.processInstances[0];
46
+
47
+ node.send({
48
+ payload: {
49
+ processInstanceId: processNotification.processInstanceId,
50
+ processModelId: processNotification.processModelId,
51
+ processInstance: processInstance,
52
+ action: 'starting',
53
+ type: 'processInstance',
54
+ },
55
+ });
56
+ }
57
+ } catch (error) {
58
+ node.error(error);
54
59
  }
55
60
  },
56
61
  { identity: currentIdentity }
57
- ).catch((error) => {
58
- node.error(error);
59
- });
62
+ );
60
63
  case 'started':
61
64
  return await client.notification.onProcessStarted(
62
65
  async (processNotification) => {
63
66
  if (
64
67
  config.processmodel != '' &&
65
- config.processmodel != processNotification.processModelId
66
- )
68
+ config.processmodel != processNotification.processModelId) {
67
69
  return;
70
+ }
71
+
68
72
  const newQuery = {
69
73
  processInstanceId: processNotification.processInstanceId,
70
74
  ...query,
71
75
  };
72
76
 
73
- const matchingInstances = await client.processInstances.query(newQuery, {
74
- identity: currentIdentity,
75
- }).catch((error) => {
76
- node.error(error);
77
- });
78
-
79
- if (
80
- matchingInstances.processInstances &&
81
- matchingInstances.processInstances.length == 1
82
- ) {
83
- const processInstance = matchingInstances.processInstances[0];
84
- node.send({
85
- payload: {
86
- processInstanceId: processNotification.processInstanceId,
87
- processModelId: processNotification.processModelId,
88
- flowNodeId: processNotification.flowNodeId,
89
- token: processNotification.currentToken,
90
- processInstance: processInstance,
91
- action: 'started',
92
- type: 'processInstance',
93
- },
77
+ try {
78
+ const matchingInstances = await client.processInstances.query(newQuery, {
79
+ identity: currentIdentity,
94
80
  });
81
+
82
+ if (
83
+ matchingInstances.processInstances &&
84
+ matchingInstances.processInstances.length == 1
85
+ ) {
86
+ const processInstance = matchingInstances.processInstances[0];
87
+ node.send({
88
+ payload: {
89
+ processInstanceId: processNotification.processInstanceId,
90
+ processModelId: processNotification.processModelId,
91
+ flowNodeId: processNotification.flowNodeId,
92
+ token: processNotification.currentToken,
93
+ processInstance: processInstance,
94
+ action: 'started',
95
+ type: 'processInstance',
96
+ },
97
+ });
98
+ }
99
+ } catch (error) {
100
+ node.error(error);
95
101
  }
96
102
  },
97
103
  { identity: currentIdentity }
98
- ).catch((error) => {
99
- node.error(error);
100
- });
104
+ );
101
105
  case 'resumed':
102
106
  return await client.notification.onProcessResumed(
103
107
  async (processNotification) => {
@@ -112,33 +116,33 @@ module.exports = function (RED) {
112
116
  ...query,
113
117
  };
114
118
 
115
- const matchingInstances = await client.processInstances.query(newQuery, {
116
- identity: currentIdentity,
117
- }).catch((error) => {
118
- node.error(error);
119
- });
120
-
121
- if (
122
- matchingInstances.processInstances &&
123
- matchingInstances.processInstances.length == 1
124
- ) {
125
- const processInstance = matchingInstances.processInstances[0];
126
- node.send({
127
- payload: {
128
- processInstanceId: processNotification.processInstanceId,
129
- processModelId: processNotification.processModelId,
130
- token: processNotification.currentToken,
131
- processInstance: processInstance,
132
- action: 'resumed',
133
- type: 'processInstance',
134
- },
119
+ try {
120
+ const matchingInstances = await client.processInstances.query(newQuery, {
121
+ identity: currentIdentity,
135
122
  });
123
+
124
+ if (
125
+ matchingInstances.processInstances &&
126
+ matchingInstances.processInstances.length == 1
127
+ ) {
128
+ const processInstance = matchingInstances.processInstances[0];
129
+ node.send({
130
+ payload: {
131
+ processInstanceId: processNotification.processInstanceId,
132
+ processModelId: processNotification.processModelId,
133
+ token: processNotification.currentToken,
134
+ processInstance: processInstance,
135
+ action: 'resumed',
136
+ type: 'processInstance',
137
+ },
138
+ });
139
+ }
140
+ } catch (error) {
141
+ node.error(error);
136
142
  }
137
143
  },
138
144
  { identity: currentIdentity }
139
- ).catch((error) => {
140
- node.error(error);
141
- });
145
+ );
142
146
  case 'finished':
143
147
  return await client.notification.onProcessEnded(
144
148
  async (processNotification) => {
@@ -153,34 +157,34 @@ module.exports = function (RED) {
153
157
  ...query,
154
158
  };
155
159
 
156
- const matchingInstances = await client.processInstances.query(newQuery, {
157
- identity: currentIdentity,
158
- }).catch((error) => {
159
- node.error(error);
160
- });
161
-
162
- if (
163
- matchingInstances.processInstances &&
164
- matchingInstances.processInstances.length == 1
165
- ) {
166
- const processInstance = matchingInstances.processInstances[0];
167
- node.send({
168
- payload: {
169
- processInstanceId: processNotification.processInstanceId,
170
- processModelId: processNotification.processModelId,
171
- flowNodeId: processNotification.flowNodeId,
172
- token: processNotification.currentToken,
173
- processInstance: processInstance,
174
- action: 'finished',
175
- type: 'processInstance',
176
- },
160
+ try {
161
+ const matchingInstances = await client.processInstances.query(newQuery, {
162
+ identity: currentIdentity,
177
163
  });
164
+
165
+ if (
166
+ matchingInstances.processInstances &&
167
+ matchingInstances.processInstances.length == 1
168
+ ) {
169
+ const processInstance = matchingInstances.processInstances[0];
170
+ node.send({
171
+ payload: {
172
+ processInstanceId: processNotification.processInstanceId,
173
+ processModelId: processNotification.processModelId,
174
+ flowNodeId: processNotification.flowNodeId,
175
+ token: processNotification.currentToken,
176
+ processInstance: processInstance,
177
+ action: 'finished',
178
+ type: 'processInstance',
179
+ },
180
+ });
181
+ }
182
+ } catch (error) {
183
+ node.error(error);
178
184
  }
179
185
  },
180
186
  { identity: currentIdentity }
181
- ).catch((error) => {
182
- node.error(error);
183
- });
187
+ );
184
188
  case 'terminated':
185
189
  return await client.notification.onProcessTerminated(
186
190
  async (processNotification) => {
@@ -195,33 +199,32 @@ module.exports = function (RED) {
195
199
  ...query,
196
200
  };
197
201
 
198
- const matchingInstances = await client.processInstances.query(newQuery, {
199
- identity: currentIdentity,
200
- }).catch((error) => {
201
- node.error(error);
202
- });
203
-
204
- if (
205
- matchingInstances.processInstances &&
206
- matchingInstances.processInstances.length == 1
207
- ) {
208
- const processInstance = matchingInstances.processInstances[0];
209
- node.send({
210
- payload: {
211
- processInstanceId: processNotification.processInstanceId,
212
- processModelId: processNotification.processModelId,
213
- token: processNotification.currentToken,
214
- processInstance: processInstance,
215
- action: 'terminated',
216
- type: 'processInstance',
217
- },
202
+ try {
203
+ const matchingInstances = await client.processInstances.query(newQuery, {
204
+ identity: currentIdentity,
218
205
  });
206
+ if (
207
+ matchingInstances.processInstances &&
208
+ matchingInstances.processInstances.length == 1
209
+ ) {
210
+ const processInstance = matchingInstances.processInstances[0];
211
+ node.send({
212
+ payload: {
213
+ processInstanceId: processNotification.processInstanceId,
214
+ processModelId: processNotification.processModelId,
215
+ token: processNotification.currentToken,
216
+ processInstance: processInstance,
217
+ action: 'terminated',
218
+ type: 'processInstance',
219
+ },
220
+ });
221
+ }
222
+ } catch (error) {
223
+ node.error(error);
219
224
  }
220
225
  },
221
226
  { identity: currentIdentity }
222
- ).catch((error) => {
223
- node.error(error);
224
- });
227
+ );
225
228
  case 'error':
226
229
  return await client.notification.onProcessError(
227
230
  async (processNotification) => {
@@ -236,33 +239,33 @@ module.exports = function (RED) {
236
239
  ...query,
237
240
  };
238
241
 
239
- const matchingInstances = await client.processInstances.query(newQuery, {
240
- identity: currentIdentity,
241
- }).catch((error) => {
242
- node.error(error);
243
- });
244
-
245
- if (
246
- matchingInstances.processInstances &&
247
- matchingInstances.processInstances.length == 1
248
- ) {
249
- const processInstance = matchingInstances.processInstances[0];
250
- node.send({
251
- payload: {
252
- processInstanceId: processNotification.processInstanceId,
253
- processModelId: processNotification.processModelId,
254
- token: processNotification.currentToken,
255
- processInstance: processInstance,
256
- action: 'error',
257
- type: 'processInstance',
258
- },
242
+ try {
243
+ const matchingInstances = await client.processInstances.query(newQuery, {
244
+ identity: currentIdentity,
259
245
  });
246
+
247
+ if (
248
+ matchingInstances.processInstances &&
249
+ matchingInstances.processInstances.length == 1
250
+ ) {
251
+ const processInstance = matchingInstances.processInstances[0];
252
+ node.send({
253
+ payload: {
254
+ processInstanceId: processNotification.processInstanceId,
255
+ processModelId: processNotification.processModelId,
256
+ token: processNotification.currentToken,
257
+ processInstance: processInstance,
258
+ action: 'error',
259
+ type: 'processInstance',
260
+ },
261
+ });
262
+ }
263
+ } catch (error) {
264
+ node.error(error);
260
265
  }
261
266
  },
262
267
  { identity: currentIdentity }
263
- ).catch((error) => {
264
- node.error(error);
265
- });
268
+ );
266
269
  case 'owner-changed':
267
270
  return await client.notification.onProcessOwnerChanged(
268
271
  async (processNotification) => {
@@ -277,32 +280,32 @@ module.exports = function (RED) {
277
280
  ...query,
278
281
  };
279
282
 
280
- const matchingInstances = await client.processInstances.query(newQuery, {
281
- identity: currentIdentity,
282
- }).catch((error) => {
283
- node.error(error);
284
- });
285
-
286
- if (
287
- matchingInstances.processInstances &&
288
- matchingInstances.processInstances.length == 1
289
- ) {
290
- const processInstance = matchingInstances.processInstances[0];
291
- node.send({
292
- payload: {
293
- processInstanceId: processNotification.processInstanceId,
294
- processModelId: processNotification.processModelId,
295
- processInstance: processInstance,
296
- action: 'owner-changed',
297
- type: 'processInstance',
298
- },
283
+ try {
284
+ const matchingInstances = await client.processInstances.query(newQuery, {
285
+ identity: currentIdentity,
299
286
  });
287
+
288
+ if (
289
+ matchingInstances.processInstances &&
290
+ matchingInstances.processInstances.length == 1
291
+ ) {
292
+ const processInstance = matchingInstances.processInstances[0];
293
+ node.send({
294
+ payload: {
295
+ processInstanceId: processNotification.processInstanceId,
296
+ processModelId: processNotification.processModelId,
297
+ processInstance: processInstance,
298
+ action: 'owner-changed',
299
+ type: 'processInstance',
300
+ },
301
+ });
302
+ }
303
+ } catch (error) {
304
+ node.error(error);
300
305
  }
301
306
  },
302
307
  { identity: currentIdentity }
303
- ).catch((error) => {
304
- node.error(error);
305
- });
308
+ );
306
309
  case 'instances-deleted':
307
310
  return await client.notification.onProcessInstancesDeleted(
308
311
  async (processNotification) => {
@@ -317,32 +320,32 @@ module.exports = function (RED) {
317
320
  ...query,
318
321
  };
319
322
 
320
- const matchingInstances = await client.processInstances.query(newQuery, {
321
- identity: currentIdentity,
322
- }).catch((error) => {
323
- node.error(error);
324
- });
325
-
326
- if (
327
- matchingInstances.processInstances &&
328
- matchingInstances.processInstances.length == 1
329
- ) {
330
- const processInstance = matchingInstances.processInstances[0];
331
- node.send({
332
- payload: {
333
- processInstanceId: processNotification.processInstanceId,
334
- processModelId: processNotification.processModelId,
335
- processInstance: processInstance,
336
- action: 'instances-deleted',
337
- type: 'processInstance',
338
- },
323
+ try {
324
+ const matchingInstances = await client.processInstances.query(newQuery, {
325
+ identity: currentIdentity,
339
326
  });
327
+
328
+ if (
329
+ matchingInstances.processInstances &&
330
+ matchingInstances.processInstances.length == 1
331
+ ) {
332
+ const processInstance = matchingInstances.processInstances[0];
333
+ node.send({
334
+ payload: {
335
+ processInstanceId: processNotification.processInstanceId,
336
+ processModelId: processNotification.processModelId,
337
+ processInstance: processInstance,
338
+ action: 'instances-deleted',
339
+ type: 'processInstance',
340
+ },
341
+ });
342
+ }
343
+ } catch (error) {
344
+ node.error(error);
340
345
  }
341
346
  },
342
347
  { identity: currentIdentity }
343
- ).catch((error) => {
344
- node.error(error);
345
- });
348
+ );
346
349
  case 'is-executable-changed':
347
350
  return await client.notification.onProcessIsExecutableChanged(
348
351
  (processNotification) => {
@@ -360,9 +363,7 @@ module.exports = function (RED) {
360
363
  });
361
364
  },
362
365
  { identity: currentIdentity }
363
- ).catch((error) => {
364
- node.error(error);
365
- });
366
+ );
366
367
  case 'deployed':
367
368
  return await client.notification.onProcessDeployed(
368
369
  (processNotification) => {
@@ -380,9 +381,7 @@ module.exports = function (RED) {
380
381
  });
381
382
  },
382
383
  { identity: currentIdentity }
383
- ).catch((error) => {
384
- node.error(error);
385
- });
384
+ );
386
385
  case 'undeployed':
387
386
  return await client.notification.onProcessUndeployed(
388
387
  (processNotification) => {
@@ -400,9 +399,7 @@ module.exports = function (RED) {
400
399
  });
401
400
  },
402
401
  { identity: currentIdentity }
403
- ).catch((error) => {
404
- node.error(error);
405
- });
402
+ );
406
403
  default:
407
404
  console.error('no such event: ' + eventType);
408
405
  break;
@@ -435,9 +432,7 @@ module.exports = function (RED) {
435
432
  });
436
433
  },
437
434
  { identity: currentIdentity }
438
- ).catch((error) => {
439
- node.error(error);
440
- });
435
+ );
441
436
 
442
437
  });
443
438
 
@@ -17,10 +17,11 @@ module.exports = function (RED) {
17
17
 
18
18
  query = {
19
19
  ...query,
20
- identity: undefined,
20
+ identity: engine.identity,
21
21
  };
22
22
 
23
23
  node.log(`Querying process definitions with query: ${JSON.stringify(query)}`);
24
+
24
25
  client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
25
26
 
26
27
  if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
@@ -20,27 +20,32 @@ module.exports = function (RED) {
20
20
  function userTaskCallback() {
21
21
  return async (userTaskNotification) => {
22
22
  if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
23
+
23
24
  const newQuery = {
24
25
  flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
25
26
  ...query,
26
27
  };
27
28
 
28
- const matchingFlowNodes = await client.userTasks.query(newQuery, {
29
- identity: currentIdentity,
30
- });
29
+ try {
30
+ const matchingFlowNodes = await client.userTasks.query(newQuery, {
31
+ identity: currentIdentity,
32
+ });
31
33
 
32
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
33
- const userTask = matchingFlowNodes.userTasks[0];
34
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
35
+ const userTask = matchingFlowNodes.userTasks[0];
34
36
 
35
- node.send({
36
- payload: {
37
- flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
38
- userTaskEvent: userTaskNotification,
39
- userTask: userTask,
40
- action: config.eventtype,
41
- type: 'usertask',
42
- },
43
- });
37
+ node.send({
38
+ payload: {
39
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
40
+ userTaskEvent: userTaskNotification,
41
+ userTask: userTask,
42
+ action: config.eventtype,
43
+ type: 'usertask',
44
+ },
45
+ });
46
+ }
47
+ } catch (error) {
48
+ node.error(error);
44
49
  }
45
50
  };
46
51
  }
@@ -50,26 +55,18 @@ module.exports = function (RED) {
50
55
  case 'new':
51
56
  return await client.userTasks.onUserTaskWaiting(userTaskCallback(), {
52
57
  identity: currentIdentity,
53
- }).catch((error) => {
54
- node.error(error);
55
58
  });
56
59
  case 'finished':
57
60
  return await client.userTasks.onUserTaskFinished(userTaskCallback(), {
58
61
  identity: currentIdentity,
59
- }).catch((error) => {
60
- node.error(error);
61
62
  });
62
63
  case 'reserved':
63
64
  return await client.userTasks.onUserTaskReserved(userTaskCallback(), {
64
65
  identity: currentIdentity,
65
- }).catch((error) => {
66
- node.error(error);
67
66
  });
68
67
  case 'reservation-canceled':
69
68
  return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback(), {
70
69
  identity: currentIdentity,
71
- }).catch((error) => {
72
- node.error(error);
73
70
  });
74
71
  default:
75
72
  console.error('no such event: ' + config.eventtype);
@@ -27,23 +27,27 @@ module.exports = function (RED) {
27
27
  ...query
28
28
  };
29
29
 
30
- const matchingFlowNodes = await client.userTasks.query(newQuery, { identity: currentIdentity });
31
-
32
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
33
- // remove subscription
34
- client.userTasks.removeSubscription(subscription, currentIdentity);
35
-
36
- const userTask = matchingFlowNodes.userTasks[0];
37
-
38
- msg.payload = { userTask: userTask };
39
- node.send(msg);
40
- } else {
41
- // nothing todo - wait for next notification
30
+ try {
31
+ const matchingFlowNodes = await client.userTasks.query(newQuery, { identity: currentIdentity });
32
+
33
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
34
+ // remove subscription
35
+ client.userTasks.removeSubscription(subscription, currentIdentity);
36
+
37
+ const userTask = matchingFlowNodes.userTasks[0];
38
+
39
+ msg.payload = { userTask: userTask };
40
+ node.send(msg);
41
+ } else {
42
+ // nothing todo - wait for next notification
43
+ }
44
+ } catch (error) {
45
+ node.error(error);
42
46
  }
43
47
 
44
48
  }, { identity: currentIdentity });
45
49
 
46
- node.log({"Handling old userTasks config.only_for_new": config.only_for_new});
50
+ node.log({ "Handling old userTasks config.only_for_new": config.only_for_new });
47
51
 
48
52
  if (config.only_for_new === false) {
49
53
  // only check suspended user tasks
@@ -52,18 +56,22 @@ module.exports = function (RED) {
52
56
  ...query
53
57
  };
54
58
 
55
- const matchingFlowNodes = await client.userTasks.query(suspendedQuery, { identity: currentIdentity });
59
+ try {
60
+ const matchingFlowNodes = await client.userTasks.query(suspendedQuery, { identity: currentIdentity });
56
61
 
57
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
58
- const userTask = matchingFlowNodes.userTasks[0];
62
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
63
+ const userTask = matchingFlowNodes.userTasks[0];
59
64
 
60
- msg.payload = { userTask: userTask };
61
- node.send(msg);
65
+ msg.payload = { userTask: userTask };
66
+ node.send(msg);
62
67
 
63
- // remove subscription
64
- client.userTasks.removeSubscription(subscription, currentIdentity);
65
- } else {
66
- // let the *currentIdentity* be active
68
+ // remove subscription
69
+ client.userTasks.removeSubscription(subscription, currentIdentity);
70
+ } else {
71
+ // let the *currentIdentity* be active
72
+ }
73
+ } catch (error) {
74
+ node.error(error);
67
75
  }
68
76
  }
69
77
  };
@@ -84,7 +92,7 @@ module.exports = function (RED) {
84
92
 
85
93
  node.on("close", async () => {
86
94
  if (client != null && subscription != null) {
87
- client.userTasks.removeSubscription(subscription, currentIdentity);
95
+ client.userTasks.removeSubscription(subscription, currentIdentity);
88
96
  }
89
97
  });
90
98
  }