@5minds/node-red-contrib-processcube 2.0.0-feature-629c78-m2dq1ygt → 7.6.0-develop-51b534-mjy4rzoh

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.
Files changed (68) hide show
  1. package/README.md +3 -58
  2. package/check-authorization.html +138 -0
  3. package/check-authorization.js +27 -0
  4. package/dataobject-instance-query.html +141 -0
  5. package/dataobject-instance-query.js +45 -0
  6. package/endevent-finished-listener.js +14 -25
  7. package/examples/Check-Authorization-Sample.json +109 -0
  8. package/examples/Dataobject-Instance-Query-Sample.json +109 -0
  9. package/externaltask-error.html +8 -3
  10. package/externaltask-error.js +43 -29
  11. package/externaltask-event-listener.js +11 -28
  12. package/externaltask-input.html +48 -3
  13. package/externaltask-input.js +581 -114
  14. package/externaltask-output.js +20 -16
  15. package/icons/data-object-query.svg +5 -0
  16. package/message-event-trigger.html +1 -1
  17. package/message-event-trigger.js +8 -7
  18. package/package.json +74 -67
  19. package/process-event-listener.js +166 -225
  20. package/process-start.html +6 -0
  21. package/process-start.js +29 -6
  22. package/process-terminate.html +1 -1
  23. package/process-terminate.js +7 -5
  24. package/processcube-engine-config.html +25 -7
  25. package/processcube-engine-config.js +25 -135
  26. package/processcube-google-docs-mail-template.html +150 -0
  27. package/processcube-google-docs-mail-template.js +158 -0
  28. package/processdefinition-deploy.html +44 -0
  29. package/processdefinition-deploy.js +28 -0
  30. package/processdefinition-query.html +18 -13
  31. package/processdefinition-query.js +33 -31
  32. package/processinstance-delete-advanced.html +82 -0
  33. package/processinstance-delete-advanced.js +33 -0
  34. package/processinstance-delete.html +60 -8
  35. package/processinstance-delete.js +84 -30
  36. package/processinstance-query.html +116 -109
  37. package/processinstance-query.js +28 -5
  38. package/signal-event-trigger.js +8 -6
  39. package/usertask-event-listener.html +123 -1
  40. package/usertask-event-listener.js +30 -45
  41. package/usertask-input.html +119 -0
  42. package/usertask-input.js +7 -9
  43. package/usertask-output.js +15 -8
  44. package/wait-for-usertask.html +122 -6
  45. package/wait-for-usertask.js +44 -47
  46. package/.github/workflows/build-and-publish.yml +0 -72
  47. package/.processcube/authority/config/config.json +0 -36
  48. package/.processcube/authority/config/upeSeedingData.json +0 -12
  49. package/Dockerfile +0 -9
  50. package/doc_generator/_process_instances_query.md +0 -115
  51. package/doc_generator/generator.js +0 -41
  52. package/doc_generator/generator_with_swagger.js +0 -72
  53. package/doc_generator/package-lock.json +0 -176
  54. package/doc_generator/package.json +0 -15
  55. package/doc_generator/query_template.mustache +0 -20
  56. package/doc_generator/swagger.json +0 -4110
  57. package/docker-compose.yml +0 -44
  58. package/nodered/flows.json +0 -2156
  59. package/nodered/flows_cred.json +0 -3
  60. package/nodered/settings.js +0 -562
  61. package/nodered/static/ProcessCube_Logo.svg +0 -53
  62. package/processes/Call-Activity-Sample.bpmn +0 -88
  63. package/processes/External-Task-Auth-Sample.bpmn +0 -82
  64. package/processes/External-Task-Sample.bpmn +0 -94
  65. package/processes/SampleEvent.bpmn +0 -73
  66. package/processes/User-Task-Auth-Sample.bpmn +0 -63
  67. package/processes/User-Task-Sample.bpmn +0 -76
  68. package/processes/Wait-For-Usertask.bpmn +0 -74
@@ -4,44 +4,42 @@ module.exports = function (RED) {
4
4
  var node = this;
5
5
  node.engine = RED.nodes.getNode(config.engine);
6
6
 
7
+ let subscription;
8
+
7
9
  const register = async () => {
8
10
  const client = node.engine.engineClient;
9
11
 
10
12
  if (!client) {
11
- node.error('No engine configured.');
13
+ node.error('No engine configured.', {});
12
14
  return;
13
15
  }
14
16
 
15
- let currentIdentity = node.engine.identity;
16
-
17
- let subscription;
18
17
  const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node);
19
18
 
20
19
  async function subscribe(eventType) {
21
20
  switch (eventType) {
22
21
  case 'starting':
23
- return await client.notification.onProcessStarting(
24
- async (processNotification) => {
25
- if (
26
- config.processmodel != '' &&
27
- config.processmodel != processNotification.processModelId
28
- )
29
- return;
30
- const newQuery = {
31
- processInstanceId: processNotification.processInstanceId,
32
- ...query,
33
- };
34
-
35
- const matchingInstances = await client.processInstances.query(newQuery, {
36
- identity: currentIdentity,
37
- });
22
+ return await client.notification.onProcessStarting(async (processNotification) => {
23
+ if (
24
+ config.processmodel != '' &&
25
+ config.processmodel != processNotification.processModelId
26
+ ) {
27
+ return;
28
+ }
29
+
30
+ const newQuery = {
31
+ processInstanceId: processNotification.processInstanceId,
32
+ ...query,
33
+ };
34
+
35
+ try {
36
+ const matchingInstances = await client.processInstances.query(newQuery);
38
37
 
39
38
  if (
40
39
  matchingInstances.processInstances &&
41
40
  matchingInstances.processInstances.length == 1
42
41
  ) {
43
42
  const processInstance = matchingInstances.processInstances[0];
44
-
45
43
  node.send({
46
44
  payload: {
47
45
  processInstanceId: processNotification.processInstanceId,
@@ -52,25 +50,27 @@ module.exports = function (RED) {
52
50
  },
53
51
  });
54
52
  }
55
- },
56
- { identity: currentIdentity }
57
- );
53
+ } catch (error) {
54
+ node.error(error, {});
55
+ }
56
+
57
+ });
58
58
  case 'started':
59
- return await client.notification.onProcessStarted(
60
- async (processNotification) => {
61
- if (
62
- config.processmodel != '' &&
63
- config.processmodel != processNotification.processModelId
64
- )
65
- return;
66
- const newQuery = {
67
- processInstanceId: processNotification.processInstanceId,
68
- ...query,
69
- };
70
-
71
- const matchingInstances = await client.processInstances.query(newQuery, {
72
- identity: currentIdentity,
73
- });
59
+ return await client.notification.onProcessStarted(async (processNotification) => {
60
+ if (
61
+ config.processmodel != '' &&
62
+ config.processmodel != processNotification.processModelId
63
+ ) {
64
+ return;
65
+ }
66
+
67
+ const newQuery = {
68
+ processInstanceId: processNotification.processInstanceId,
69
+ ...query,
70
+ };
71
+
72
+ try {
73
+ const matchingInstances = await client.processInstances.query(newQuery);
74
74
 
75
75
  if (
76
76
  matchingInstances.processInstances &&
@@ -89,26 +89,22 @@ module.exports = function (RED) {
89
89
  },
90
90
  });
91
91
  }
92
- },
93
- { identity: currentIdentity }
94
- );
92
+ } catch (error) {
93
+ node.error(error, {});
94
+ }
95
+ });
95
96
  case 'resumed':
96
- return await client.notification.onProcessResumed(
97
- async (processNotification) => {
98
- if (
99
- config.processmodel != '' &&
100
- config.processmodel != processNotification.processModelId
101
- )
102
- return;
97
+ return await client.notification.onProcessResumed(async (processNotification) => {
98
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
99
+ return;
103
100
 
104
- const newQuery = {
105
- processInstanceId: processNotification.processInstanceId,
106
- ...query,
107
- };
101
+ const newQuery = {
102
+ processInstanceId: processNotification.processInstanceId,
103
+ ...query,
104
+ };
108
105
 
109
- const matchingInstances = await client.processInstances.query(newQuery, {
110
- identity: currentIdentity,
111
- });
106
+ try {
107
+ const matchingInstances = await client.processInstances.query(newQuery);
112
108
 
113
109
  if (
114
110
  matchingInstances.processInstances &&
@@ -126,26 +122,22 @@ module.exports = function (RED) {
126
122
  },
127
123
  });
128
124
  }
129
- },
130
- { identity: currentIdentity }
131
- );
125
+ } catch (error) {
126
+ node.error(error, {});
127
+ }
128
+ });
132
129
  case 'finished':
133
- return await client.notification.onProcessEnded(
134
- async (processNotification) => {
135
- if (
136
- config.processmodel != '' &&
137
- config.processmodel != processNotification.processModelId
138
- )
139
- return;
130
+ return await client.notification.onProcessEnded(async (processNotification) => {
131
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
132
+ return;
140
133
 
141
- const newQuery = {
142
- processInstanceId: processNotification.processInstanceId,
143
- ...query,
144
- };
134
+ const newQuery = {
135
+ processInstanceId: processNotification.processInstanceId,
136
+ ...query,
137
+ };
145
138
 
146
- const matchingInstances = await client.processInstances.query(newQuery, {
147
- identity: currentIdentity,
148
- });
139
+ try {
140
+ const matchingInstances = await client.processInstances.query(newQuery);
149
141
 
150
142
  if (
151
143
  matchingInstances.processInstances &&
@@ -164,27 +156,22 @@ module.exports = function (RED) {
164
156
  },
165
157
  });
166
158
  }
167
- },
168
- { identity: currentIdentity }
169
- );
159
+ } catch (error) {
160
+ node.error(error, {});
161
+ }
162
+ });
170
163
  case 'terminated':
171
- return await client.notification.onProcessTerminated(
172
- async (processNotification) => {
173
- if (
174
- config.processmodel != '' &&
175
- config.processmodel != processNotification.processModelId
176
- )
177
- return;
164
+ return await client.notification.onProcessTerminated(async (processNotification) => {
165
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
166
+ return;
178
167
 
179
- const newQuery = {
180
- processInstanceId: processNotification.processInstanceId,
181
- ...query,
182
- };
183
-
184
- const matchingInstances = await client.processInstances.query(newQuery, {
185
- identity: currentIdentity,
186
- });
168
+ const newQuery = {
169
+ processInstanceId: processNotification.processInstanceId,
170
+ ...query,
171
+ };
187
172
 
173
+ try {
174
+ const matchingInstances = await client.processInstances.query(newQuery);
188
175
  if (
189
176
  matchingInstances.processInstances &&
190
177
  matchingInstances.processInstances.length == 1
@@ -201,26 +188,22 @@ module.exports = function (RED) {
201
188
  },
202
189
  });
203
190
  }
204
- },
205
- { identity: currentIdentity }
206
- );
191
+ } catch (error) {
192
+ node.error(error, {});
193
+ }
194
+ });
207
195
  case 'error':
208
- return await client.notification.onProcessError(
209
- async (processNotification) => {
210
- if (
211
- config.processmodel != '' &&
212
- config.processmodel != processNotification.processModelId
213
- )
214
- return;
196
+ return await client.notification.onProcessError(async (processNotification) => {
197
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
198
+ return;
215
199
 
216
- const newQuery = {
217
- processInstanceId: processNotification.processInstanceId,
218
- ...query,
219
- };
200
+ const newQuery = {
201
+ processInstanceId: processNotification.processInstanceId,
202
+ ...query,
203
+ };
220
204
 
221
- const matchingInstances = await client.processInstances.query(newQuery, {
222
- identity: currentIdentity,
223
- });
205
+ try {
206
+ const matchingInstances = await client.processInstances.query(newQuery);
224
207
 
225
208
  if (
226
209
  matchingInstances.processInstances &&
@@ -238,26 +221,22 @@ module.exports = function (RED) {
238
221
  },
239
222
  });
240
223
  }
241
- },
242
- { identity: currentIdentity }
243
- );
224
+ } catch (error) {
225
+ node.error(error, {});
226
+ }
227
+ });
244
228
  case 'owner-changed':
245
- return await client.notification.onProcessOwnerChanged(
246
- async (processNotification) => {
247
- if (
248
- config.processmodel != '' &&
249
- config.processmodel != processNotification.processModelId
250
- )
251
- return;
229
+ return await client.notification.onProcessOwnerChanged(async (processNotification) => {
230
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
231
+ return;
252
232
 
253
- const newQuery = {
254
- processInstanceId: processNotification.processInstanceId,
255
- ...query,
256
- };
233
+ const newQuery = {
234
+ processInstanceId: processNotification.processInstanceId,
235
+ ...query,
236
+ };
257
237
 
258
- const matchingInstances = await client.processInstances.query(newQuery, {
259
- identity: currentIdentity,
260
- });
238
+ try {
239
+ const matchingInstances = await client.processInstances.query(newQuery);
261
240
 
262
241
  if (
263
242
  matchingInstances.processInstances &&
@@ -274,26 +253,22 @@ module.exports = function (RED) {
274
253
  },
275
254
  });
276
255
  }
277
- },
278
- { identity: currentIdentity }
279
- );
256
+ } catch (error) {
257
+ node.error(error, {});
258
+ }
259
+ });
280
260
  case 'instances-deleted':
281
- return await client.notification.onProcessInstancesDeleted(
282
- async (processNotification) => {
283
- if (
284
- config.processmodel != '' &&
285
- config.processmodel != processNotification.processModelId
286
- )
287
- return;
261
+ return await client.notification.onProcessInstancesDeleted(async (processNotification) => {
262
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
263
+ return;
288
264
 
289
- const newQuery = {
290
- processInstanceId: processNotification.processInstanceId,
291
- ...query,
292
- };
265
+ const newQuery = {
266
+ processInstanceId: processNotification.processInstanceId,
267
+ ...query,
268
+ };
293
269
 
294
- const matchingInstances = await client.processInstances.query(newQuery, {
295
- identity: currentIdentity,
296
- });
270
+ try {
271
+ const matchingInstances = await client.processInstances.query(newQuery);
297
272
 
298
273
  if (
299
274
  matchingInstances.processInstances &&
@@ -310,107 +285,73 @@ module.exports = function (RED) {
310
285
  },
311
286
  });
312
287
  }
313
- },
314
- { identity: currentIdentity }
315
- );
288
+ } catch (error) {
289
+ node.error(error, {});
290
+ }
291
+ });
316
292
  case 'is-executable-changed':
317
- return await client.notification.onProcessIsExecutableChanged(
318
- (processNotification) => {
319
- if (
320
- config.processmodel != '' &&
321
- config.processmodel != processNotification.processModelId
322
- )
323
- return;
324
- node.send({
325
- payload: {
326
- processModelId: processNotification.processModelId,
327
- action: 'is-executable-changed',
328
- type: 'processModel',
329
- },
330
- });
331
- },
332
- { identity: currentIdentity }
333
- );
293
+ return await client.notification.onProcessIsExecutableChanged((processNotification) => {
294
+ node.log(
295
+ 'processNotification (is-executable-changed): ' + JSON.stringify(processNotification)
296
+ );
297
+
298
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
299
+ return;
300
+ node.send({
301
+ payload: {
302
+ processModelId: processNotification.processModelId,
303
+ action: 'is-executable-changed',
304
+ type: 'processModel',
305
+ },
306
+ });
307
+ });
334
308
  case 'deployed':
335
- return await client.notification.onProcessDeployed(
336
- (processNotification) => {
337
- if (
338
- config.processmodel != '' &&
339
- config.processmodel != processNotification.processModelId
340
- )
341
- return;
342
- node.send({
343
- payload: {
344
- processModelId: processNotification.processModelId,
345
- action: 'deployed',
346
- type: 'processModel',
347
- },
348
- });
349
- },
350
- { identity: currentIdentity }
351
- );
309
+ return await client.notification.onProcessDeployed((processNotification) => {
310
+ node.log('processNotification (deployed): ' + JSON.stringify(processNotification));
311
+
312
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
313
+ return;
314
+ node.send({
315
+ payload: {
316
+ processModelId: processNotification.processModelId,
317
+ action: 'deployed',
318
+ type: 'processModel',
319
+ },
320
+ });
321
+ });
352
322
  case 'undeployed':
353
- return await client.notification.onProcessUndeployed(
354
- (processNotification) => {
355
- if (
356
- config.processmodel != '' &&
357
- config.processmodel != processNotification.processModelId
358
- )
359
- return;
360
- node.send({
361
- payload: {
362
- processModelId: processNotification.processModelId,
363
- action: 'undeployed',
364
- type: 'processModel',
365
- },
366
- });
367
- },
368
- { identity: currentIdentity }
369
- );
323
+ return await client.notification.onProcessUndeployed((processNotification) => {
324
+ node.log('processNotification (undeployed): ' + JSON.stringify(processNotification));
325
+
326
+ if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
327
+ return;
328
+ node.send({
329
+ payload: {
330
+ processModelId: processNotification.processModelId,
331
+ action: 'undeployed',
332
+ type: 'processModel',
333
+ },
334
+ });
335
+ });
370
336
  default:
371
337
  console.error('no such event: ' + eventType);
372
338
  break;
373
339
  }
374
340
  }
375
341
 
376
- if (node.engine.isIdentityReady()) {
377
- subscription = await subscribe(config.eventtype);
378
- }
379
-
380
- node.engine.registerOnIdentityChanged(async (identity) => {
381
- if (subscription) {
382
- client.notification.removeSubscription(subscription, currentIdentity);
383
- }
384
-
385
- currentIdentity = identity;
386
-
387
- subscription = await client.notification.onProcessResumed(
388
- (processNotification) => {
389
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
390
- return;
391
- node.send({
392
- payload: {
393
- processInstanceId: processNotification.processInstanceId,
394
- processModelId: processNotification.processModelId,
395
- token: processNotification.currentToken,
396
- action: 'resumed',
397
- type: 'processInstance',
398
- },
399
- });
400
- },
401
- { identity: currentIdentity }
402
- );
403
- });
342
+ subscription = await subscribe(config.eventtype);
404
343
 
405
344
  node.on('close', () => {
406
345
  if (node.engine && node.engine.engineClient && client) {
407
- client.notification.removeSubscription(subscription, currentIdentity);
346
+ client.notification.removeSubscription(subscription);
408
347
  }
409
348
  });
410
349
  };
411
350
 
412
351
  if (node.engine) {
413
- register();
352
+ register().catch((error) => {
353
+ node.error(error, {});
354
+ });
414
355
  }
415
356
  }
416
357
  RED.nodes.registerType('process-event-listener', ProcessEventListener);
@@ -7,6 +7,7 @@
7
7
  engine: { value: '', type: 'processcube-engine-config' },
8
8
  processmodel: { value: '', required: false },
9
9
  startevent: { value: '', required: false },
10
+ correlationId: { value: '', required: false },
10
11
  },
11
12
  inputs: 1,
12
13
  outputs: 1,
@@ -34,6 +35,10 @@
34
35
  <label for="node-input-startevent"><i class="fa fa-tag"></i> Startevent</label>
35
36
  <input type="text" id="node-input-startevent" placeholder="ID of Startevent" />
36
37
  </div>
38
+ <div class="form-row">
39
+ <label for="node-input-correlationId"><i class="fa fa-tag"></i> CorrelationId</label>
40
+ <input type="text" id="node-input-correlationId" placeholder="ID of Correlation" />
41
+ </div>
37
42
  </script>
38
43
 
39
44
  <script type="text/markdown" data-help-name="process-start">
@@ -46,6 +51,7 @@ The `processModelId` and `startEventId` can be set in the message object to over
46
51
  : payload (Object) : Will be used as the start token for the process.
47
52
  : processModelId (String) : Will be used as the process model and override the configured `Processmodel`.
48
53
  : startEventId (String) : Will be used as the start event and override the configured `Startevent`.
54
+ : correlationId (String) : Will be used as the correlation identifier and override the configured `CorrelationId`.
49
55
 
50
56
  ## Outputs
51
57
 
package/process-start.js CHANGED
@@ -4,25 +4,48 @@ module.exports = function (RED) {
4
4
  var node = this;
5
5
 
6
6
  node.on('input', function (msg) {
7
+ let initialToken = {};
7
8
 
8
- const initialToken = RED.util.encodeObject(msg.payload);
9
+ if (msg.payload) {
10
+ initialToken = RED.util.encodeObject(msg.payload);
11
+
12
+ // remote msg and format from result
13
+ if (initialToken) {
14
+ delete initialToken.msg;
15
+ delete initialToken.format;
16
+ }
17
+ }
9
18
 
10
19
  const startParameters = {
11
20
  processModelId: msg.processModelId || config.processmodel,
12
21
  startEventId: msg.startEventId || config.startevent,
22
+ correlationId: msg.correlationId || config.correlationId,
13
23
  initialToken: initialToken,
14
24
  };
15
25
 
16
- const engine = RED.nodes.getNode(config.engine);
17
- const client = engine.engineClient;
26
+ if (!startParameters.processModelId) {
27
+ node.error('No processModelId configured.', msg);
28
+ return;
29
+ }
30
+
31
+ if (!startParameters.startEventId) {
32
+ node.error('No startEventId configured.', msg);
33
+ return;
34
+ }
35
+
36
+ node.engine = RED.nodes.getNode(config.engine);
37
+ const client = node.engine.engineClient;
18
38
 
19
39
  if (!client) {
20
- node.error('No engine configured.');
40
+ node.error('No engine configured.', msg);
21
41
  return;
22
42
  }
23
43
 
44
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
45
+ const identity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
46
+
24
47
  client.processDefinitions
25
- .startProcessInstance(startParameters, engine.identity)
48
+ .startProcessInstance(startParameters, identity)
26
49
  .then((result) => {
27
50
  msg.payload = result;
28
51
 
@@ -34,7 +57,7 @@ module.exports = function (RED) {
34
57
  });
35
58
  })
36
59
  .catch((error) => {
37
- node.error(error);
60
+ node.error(error, msg);
38
61
  });
39
62
  });
40
63
  }
@@ -32,7 +32,7 @@ Terminate an instance of a process model in the ProcessCube.
32
32
  ## Configs
33
33
 
34
34
  : name (string): name of the node
35
- : engine (string): the engine to connect to
35
+ : engine (engine-node): the engine to connect to
36
36
 
37
37
  ## Outputs
38
38
 
@@ -4,21 +4,23 @@ module.exports = function (RED) {
4
4
  var node = this;
5
5
 
6
6
  node.on('input', function (msg) {
7
- const engine = RED.nodes.getNode(config.engine);
8
- const client = engine.engineClient;
7
+ node.engine = RED.nodes.getNode(config.engine);
8
+ const client = node.engine.engineClient;
9
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
10
+ const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
9
11
 
10
12
  if (!client) {
11
- node.error('No engine configured.');
13
+ node.error('No engine configured.', msg);
12
14
  return;
13
15
  }
14
16
 
15
17
  client.processInstances
16
- .terminateProcessInstance(msg.payload, engine.identity)
18
+ .terminateProcessInstance(msg.payload, userIdentity)
17
19
  .then(() => {
18
20
  node.send(msg);
19
21
  })
20
22
  .catch((error) => {
21
- node.error(error);
23
+ node.error(error, msg);
22
24
  });
23
25
  });
24
26
  }