@5minds/node-red-contrib-processcube 1.5.5-feature-22f94f-m3eulbpf → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,33 +24,38 @@ 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 }
@@ -60,34 +65,39 @@ module.exports = function (RED) {
60
65
  async (processNotification) => {
61
66
  if (
62
67
  config.processmodel != '' &&
63
- config.processmodel != processNotification.processModelId
64
- )
68
+ config.processmodel != processNotification.processModelId) {
65
69
  return;
70
+ }
71
+
66
72
  const newQuery = {
67
73
  processInstanceId: processNotification.processInstanceId,
68
74
  ...query,
69
75
  };
70
76
 
71
- const matchingInstances = await client.processInstances.query(newQuery, {
72
- identity: currentIdentity,
73
- });
74
-
75
- if (
76
- matchingInstances.processInstances &&
77
- matchingInstances.processInstances.length == 1
78
- ) {
79
- const processInstance = matchingInstances.processInstances[0];
80
- node.send({
81
- payload: {
82
- processInstanceId: processNotification.processInstanceId,
83
- processModelId: processNotification.processModelId,
84
- flowNodeId: processNotification.flowNodeId,
85
- token: processNotification.currentToken,
86
- processInstance: processInstance,
87
- action: 'started',
88
- type: 'processInstance',
89
- },
77
+ try {
78
+ const matchingInstances = await client.processInstances.query(newQuery, {
79
+ identity: currentIdentity,
90
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);
91
101
  }
92
102
  },
93
103
  { identity: currentIdentity }
@@ -106,25 +116,29 @@ module.exports = function (RED) {
106
116
  ...query,
107
117
  };
108
118
 
109
- const matchingInstances = await client.processInstances.query(newQuery, {
110
- identity: currentIdentity,
111
- });
112
-
113
- if (
114
- matchingInstances.processInstances &&
115
- matchingInstances.processInstances.length == 1
116
- ) {
117
- const processInstance = matchingInstances.processInstances[0];
118
- node.send({
119
- payload: {
120
- processInstanceId: processNotification.processInstanceId,
121
- processModelId: processNotification.processModelId,
122
- token: processNotification.currentToken,
123
- processInstance: processInstance,
124
- action: 'resumed',
125
- type: 'processInstance',
126
- },
119
+ try {
120
+ const matchingInstances = await client.processInstances.query(newQuery, {
121
+ identity: currentIdentity,
127
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);
128
142
  }
129
143
  },
130
144
  { identity: currentIdentity }
@@ -143,26 +157,30 @@ module.exports = function (RED) {
143
157
  ...query,
144
158
  };
145
159
 
146
- const matchingInstances = await client.processInstances.query(newQuery, {
147
- identity: currentIdentity,
148
- });
149
-
150
- if (
151
- matchingInstances.processInstances &&
152
- matchingInstances.processInstances.length == 1
153
- ) {
154
- const processInstance = matchingInstances.processInstances[0];
155
- node.send({
156
- payload: {
157
- processInstanceId: processNotification.processInstanceId,
158
- processModelId: processNotification.processModelId,
159
- flowNodeId: processNotification.flowNodeId,
160
- token: processNotification.currentToken,
161
- processInstance: processInstance,
162
- action: 'finished',
163
- type: 'processInstance',
164
- },
160
+ try {
161
+ const matchingInstances = await client.processInstances.query(newQuery, {
162
+ identity: currentIdentity,
165
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);
166
184
  }
167
185
  },
168
186
  { identity: currentIdentity }
@@ -181,25 +199,28 @@ module.exports = function (RED) {
181
199
  ...query,
182
200
  };
183
201
 
184
- const matchingInstances = await client.processInstances.query(newQuery, {
185
- identity: currentIdentity,
186
- });
187
-
188
- if (
189
- matchingInstances.processInstances &&
190
- matchingInstances.processInstances.length == 1
191
- ) {
192
- const processInstance = matchingInstances.processInstances[0];
193
- node.send({
194
- payload: {
195
- processInstanceId: processNotification.processInstanceId,
196
- processModelId: processNotification.processModelId,
197
- token: processNotification.currentToken,
198
- processInstance: processInstance,
199
- action: 'terminated',
200
- type: 'processInstance',
201
- },
202
+ try {
203
+ const matchingInstances = await client.processInstances.query(newQuery, {
204
+ identity: currentIdentity,
202
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);
203
224
  }
204
225
  },
205
226
  { identity: currentIdentity }
@@ -218,25 +239,29 @@ module.exports = function (RED) {
218
239
  ...query,
219
240
  };
220
241
 
221
- const matchingInstances = await client.processInstances.query(newQuery, {
222
- identity: currentIdentity,
223
- });
224
-
225
- if (
226
- matchingInstances.processInstances &&
227
- matchingInstances.processInstances.length == 1
228
- ) {
229
- const processInstance = matchingInstances.processInstances[0];
230
- node.send({
231
- payload: {
232
- processInstanceId: processNotification.processInstanceId,
233
- processModelId: processNotification.processModelId,
234
- token: processNotification.currentToken,
235
- processInstance: processInstance,
236
- action: 'error',
237
- type: 'processInstance',
238
- },
242
+ try {
243
+ const matchingInstances = await client.processInstances.query(newQuery, {
244
+ identity: currentIdentity,
239
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);
240
265
  }
241
266
  },
242
267
  { identity: currentIdentity }
@@ -255,24 +280,28 @@ module.exports = function (RED) {
255
280
  ...query,
256
281
  };
257
282
 
258
- const matchingInstances = await client.processInstances.query(newQuery, {
259
- identity: currentIdentity,
260
- });
261
-
262
- if (
263
- matchingInstances.processInstances &&
264
- matchingInstances.processInstances.length == 1
265
- ) {
266
- const processInstance = matchingInstances.processInstances[0];
267
- node.send({
268
- payload: {
269
- processInstanceId: processNotification.processInstanceId,
270
- processModelId: processNotification.processModelId,
271
- processInstance: processInstance,
272
- action: 'owner-changed',
273
- type: 'processInstance',
274
- },
283
+ try {
284
+ const matchingInstances = await client.processInstances.query(newQuery, {
285
+ identity: currentIdentity,
275
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);
276
305
  }
277
306
  },
278
307
  { identity: currentIdentity }
@@ -291,24 +320,28 @@ module.exports = function (RED) {
291
320
  ...query,
292
321
  };
293
322
 
294
- const matchingInstances = await client.processInstances.query(newQuery, {
295
- identity: currentIdentity,
296
- });
297
-
298
- if (
299
- matchingInstances.processInstances &&
300
- matchingInstances.processInstances.length == 1
301
- ) {
302
- const processInstance = matchingInstances.processInstances[0];
303
- node.send({
304
- payload: {
305
- processInstanceId: processNotification.processInstanceId,
306
- processModelId: processNotification.processModelId,
307
- processInstance: processInstance,
308
- action: 'instances-deleted',
309
- type: 'processInstance',
310
- },
323
+ try {
324
+ const matchingInstances = await client.processInstances.query(newQuery, {
325
+ identity: currentIdentity,
311
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);
312
345
  }
313
346
  },
314
347
  { identity: currentIdentity }
@@ -400,6 +433,7 @@ module.exports = function (RED) {
400
433
  },
401
434
  { identity: currentIdentity }
402
435
  );
436
+
403
437
  });
404
438
 
405
439
  node.on('close', () => {
@@ -29,10 +29,9 @@
29
29
  <script type="text/markdown" data-help-name="process-terminate">
30
30
  Terminate an instance of a process model in the ProcessCube.
31
31
 
32
- ## Configs
32
+ ## Inputs
33
33
 
34
- : name (string): name of the node
35
- : engine (string): the engine to connect to
34
+ : payload (string): The id of the processinstance that is going to be terminated.
36
35
 
37
36
  ## Outputs
38
37
 
@@ -76,127 +76,6 @@ Only models can be queried by setting the `models_only` flag.
76
76
  : processDefinitions / models (Array) : The processDefinitions / models that matched the query.
77
77
  : totalCount (number) : The number of matches.
78
78
 
79
-
80
- ### Query fields
81
-
82
- **Summary**:
83
-
84
- **Description**: Filter result for &#39;ProcessInstance Query&#39;
85
-
86
- #### Parameters:
87
- - Name: `offset` Required: `false`
88
- - Type: number
89
- - Description: The index of the first ProcessInstance to include in the result set.
90
- - Name: `limit` Required: `false`
91
- - Type: number
92
- - Description: The maximum number of ProcessInstances to return.
93
- - Name: `correlationId` Required: `false`
94
- - Type: Array&lt;string&gt; | string | SearchQuery
95
- - string: myCorrelationId
96
- - Array&lt;string&gt;: myCorrelationId1,myCorrelationId2
97
- - object:
98
- - Description: Filter by the CorrelationId of the ProcessInstances.
99
- - Name: `processInstanceId` Required: ``
100
- - Type: Array&lt;string&gt; | string | SearchQuery
101
- - string: myProcessInstance_12345678
102
- - Array&lt;string&gt;: myProcessInstance_12345678,myProcessInstance_87654321
103
- - object:
104
- - Description: Filter by the ID of the ProcessInstances.
105
- - Name: `processDefinitionId` Required: ``
106
- - Type: Array&lt;string&gt; | string | SearchQuery
107
- - string: myProcess_12345678
108
- - Array&lt;string&gt;: myProcess_12345678,myProcess_87654321
109
- - object:
110
- - Description: Filter by the ID of the ProcessDefinition that the ProcessInstances belong to.
111
- - Name: `processModelId` Required: ``
112
- - Type: Array&lt;string&gt; | string | SearchQuery
113
- - string: myProcessModel_12345678
114
- - Array&lt;string&gt;: myProcessModel_12345678,myProcessModel_87654321
115
- - object:
116
- - Description: Filter by the ID of the ProcessModel that the ProcessInstances belong to.
117
- - Name: `processModelName` Required: ``
118
- - Type: Array&lt;string&gt; | string | SearchQuery
119
- - string: My Process Model
120
- - Array&lt;string&gt;: My Process Model,My Other Process Model
121
- - object:
122
- - Description: Filter by the name of the ProcessModel that the ProcessInstances belong to.
123
- - Name: `processModelHash` Required: ``
124
- - Type: Array&lt;string&gt; | string | SearchQuery
125
- - string: 12345678
126
- - Array&lt;string&gt;: 12345678,87654321
127
- - object:
128
- - Description: Filter by the hash of the ProcessModel that the ProcessInstances belong to.
129
- - Name: `ownerId` Required: ``
130
- - Type: Array&lt;string&gt; | string | SearchQuery
131
- - string: 12345678
132
- - Array&lt;string&gt;: 12345678,87654321
133
- - object:
134
- - Description: Filter by the ID of the User that owns the ProcessInstances.
135
- - Name: `state` Required: ``
136
- - Type: Array&lt;string&gt; | string | SearchQuery
137
- - string: running
138
- - Array&lt;string&gt;: running,finished
139
- - object:
140
- - Description: Filter by the state of the ProcessInstances.
141
- - Name: `parentProcessInstanceId` Required: ``
142
- - Type: Array&lt;string&gt; | string | SearchQuery
143
- - string: myParentProcessInstance_12345678
144
- - Array&lt;string&gt;: myParentProcessInstance_12345678,myParentProcessInstance_87654321
145
- - object:
146
- - Description: Filter by the ID of the parent ProcessInstance.
147
- - Name: `embeddedProcessModelId` Required: ``
148
- - Type: Array&lt;string&gt; | string | SearchQuery
149
- - string: myModel1
150
- - Array&lt;string&gt;: myModel1,myModel2
151
- - object:
152
- - Description: Filter by the ID of the embedded process model.
153
- - Name: `terminatedByUserId` Required: ``
154
- - Type: Array&lt;string&gt; | string | SearchQuery
155
- - string: 12345678
156
- - Array&lt;string&gt;: 12345678,87654321
157
- - object:
158
- - Description: Filter by the ID of the User that terminated the ProcessInstances.
159
- - Name: `createdBefore` Required: ``
160
- - Type: string
161
- - Description: The maximum created date of the ProcessInstances to include in the results.
162
- - Name: `createdAt` Required: ``
163
- - Type: Array&lt;string&gt; | string
164
- - string: 2021-01-01T00:00:00.000Z
165
- - array: 2021-01-01T00:00:00.000Z,2021-01-02T00:00:00.000Z
166
- - Description: The minimum created date of the ProcessInstances to include in the results.
167
- - Name: `createdAfter` Required: ``
168
- - Type: string
169
- - Description: The minimum created date of the ProcessInstances to include in the results.
170
- - Name: `updatedBefore` Required: ``
171
- - Type: string
172
- - Description: The maximum updated date of the ProcessInstances to include in the results.
173
- - Name: `updatedAt` Required: ``
174
- - Type: Array&lt;string&gt; | string
175
- - string: 2021-01-01T00:00:00.000Z
176
- - array: 2021-01-01T00:00:00.000Z,2021-01-02T00:00:00.000Z
177
- - Description: The exact updated date of the ProcessInstances to include in the results.
178
- - Name: `updatedAfter` Required: ``
179
- - Type: string
180
- - Description: The minimum updated date of the ProcessInstances to include in the results.
181
- - Name: `finishedBefore` Required: ``
182
- - Type: string
183
- - Description: The maximum finished date of the ProcessInstances to include in the results.
184
- - Name: `finishedAt` Required: ``
185
- - Type: Array&lt;string&gt; | string
186
- - string: 2021-01-01T00:00:00.000Z
187
- - array: 2021-01-01T00:00:00.000Z,2021-01-02T00:00:00.000Z
188
- - Description: The exact finished date of the ProcessInstances to include in the results.
189
- - Name: `finishedAfter` Required: ``
190
- - Type: string
191
- - Description: The minimum finished date of the ProcessInstances to include in the results.
192
- - Name: `triggeredByFlowNodeInstance` Required: ``
193
- - Type: Array&lt;string&gt; | string | SearchQuery
194
- - string: myFlowNodeInstance_12345678
195
- - array: myFlowNodeInstance_12345678,myFlowNodeInstance_87654321
196
- - object:
197
- - Description: Filter by the ID of the FlowNodeInstance that triggered the ProcessInstance.
198
-
199
-
200
79
  ### References
201
80
 
202
81
  - [The ProcessCube&copy; Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
@@ -20,6 +20,8 @@ module.exports = function (RED) {
20
20
  identity: engine.identity,
21
21
  };
22
22
 
23
+ node.log(`Querying process definitions with query: ${JSON.stringify(query)}`);
24
+
23
25
  client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
24
26
 
25
27
  if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
@@ -40,6 +42,8 @@ module.exports = function (RED) {
40
42
  }
41
43
 
42
44
  node.send(msg);
45
+ }).catch((error) => {
46
+ node.error(error);
43
47
  });
44
48
  });
45
49
  }
@@ -45,19 +45,19 @@
45
45
  </script>
46
46
 
47
47
  <script type="text/markdown" data-help-name="processinstance-delete">
48
- Delete old instances of a process model in the ProcessCube.
48
+ Delete old instances of a process model in the ProcessCube.
49
49
 
50
- ## Inputs
50
+ ## Inputs
51
51
 
52
- : payload.time (number): The number of given time periods.
53
- : payload.time_type ('hours' | 'days'): The type of time period to use.
52
+ : payload.time (number): The number of given time periods.
53
+ : payload.time_type ('hours' | 'days'): The type of time period to use.
54
54
 
55
- ## Outputs
55
+ ## Outputs
56
56
 
57
- : payload (string[]): The ids of the processinstances that were deleted.
57
+ : payload (string[]): The ids of the processinstances that were deleted.
58
58
 
59
- ### References
59
+ ### References
60
60
 
61
- - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
62
- - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
61
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
62
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
63
63
  </script>