@5minds/node-red-contrib-processcube 1.1.4-feature-285569-m0c23so4 → 1.1.4-feature-ce7ef0-m0c3u8nd

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.1.4-feature-285569-m0c23so4",
3
+ "version": "1.1.4-feature-ce7ef0-m0c3u8nd",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -6,7 +6,9 @@
6
6
  name: { value: '' },
7
7
  engine: { value: '', type: 'processcube-engine-config' },
8
8
  processmodel: { value: '', required: false },
9
- eventtype: { value: '', required: true}
9
+ eventtype: { value: '', required: true},
10
+ query: { value: '{}' },
11
+ query_type: { value: 'json' },
10
12
  },
11
13
  inputs: 0,
12
14
  outputs: 1,
@@ -14,6 +16,22 @@
14
16
  label: function () {
15
17
  return this.name || 'process-event-listener';
16
18
  },
19
+ oneditprepare: function () {
20
+ $('#node-input-query').typedInput({
21
+ default: 'json',
22
+ types: ['json'],
23
+ });
24
+
25
+ $('#node-input-query').typedInput('value', this.query);
26
+ $('#node-input-query').typedInput('type', this.query_type);
27
+ },
28
+ oneditsave: function () {
29
+ if ($('#node-input-query').typedInput('value') == '') {
30
+ $('#node-input-query').typedInput('value', '{}')
31
+ }
32
+ (this.query = $('#node-input-query').typedInput('value')),
33
+ (this.query_type = $('#node-input-query').typedInput('type'));
34
+ },
17
35
  });
18
36
  </script>
19
37
 
@@ -46,6 +64,10 @@
46
64
  <option value="undeployed">undeployed</option>
47
65
  </select>
48
66
  </div>
67
+ <div class="form-row">
68
+ <label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
69
+ <input type="text" id="node-input-query" />
70
+ </div>
49
71
  </script>
50
72
 
51
73
  <script type="text/markdown" data-help-name="process-event-listener">
@@ -15,148 +15,311 @@ module.exports = function (RED) {
15
15
  let currentIdentity = node.engine.identity;
16
16
 
17
17
  let subscription;
18
+ const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node);
18
19
 
19
20
  async function subscribe(eventType) {
20
21
  switch (eventType) {
21
- case "starting":
22
+ case 'starting':
22
23
  return await client.notification.onProcessStarting(
23
- (processNotification) => {
24
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
24
+ async (processNotification) => {
25
+ if (
26
+ config.processmodel != '' &&
27
+ config.processmodel != processNotification.processModelId
28
+ )
25
29
  return;
26
- node.send({
27
- payload: {
28
- processInstanceId: processNotification.processInstanceId,
29
- processModelId: processNotification.processModelId,
30
- action: 'starting',
31
- type: 'processInstance',
32
- },
30
+ const newQuery = {
31
+ processInstanceId: processNotification.processInstanceId,
32
+ ...query,
33
+ };
34
+
35
+ const matchingInstances = await client.processInstances.query(newQuery, {
36
+ identity: currentIdentity,
33
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
+ },
53
+ });
54
+ }
34
55
  },
35
56
  { identity: currentIdentity }
36
57
  );
37
58
  case 'started':
38
59
  return await client.notification.onProcessStarted(
39
- (processNotification) => {
40
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
60
+ async (processNotification) => {
61
+ if (
62
+ config.processmodel != '' &&
63
+ config.processmodel != processNotification.processModelId
64
+ )
41
65
  return;
42
- node.send({
43
- payload: {
44
- processInstanceId: processNotification.processInstanceId,
45
- processModelId: processNotification.processModelId,
46
- flowNodeId: processNotification.flowNodeId,
47
- token: processNotification.currentToken,
48
- action: 'started',
49
- type: 'processInstance',
50
- },
66
+ const newQuery = {
67
+ processInstanceId: processNotification.processInstanceId,
68
+ ...query,
69
+ };
70
+
71
+ const matchingInstances = await client.processInstances.query(newQuery, {
72
+ identity: currentIdentity,
51
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
+ },
90
+ });
91
+ }
52
92
  },
53
93
  { identity: currentIdentity }
54
94
  );
55
95
  case 'resumed':
56
96
  return await client.notification.onProcessResumed(
57
- (processNotification) => {
58
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
97
+ async (processNotification) => {
98
+ if (
99
+ config.processmodel != '' &&
100
+ config.processmodel != processNotification.processModelId
101
+ )
59
102
  return;
60
- node.send({
61
- payload: {
62
- processInstanceId: processNotification.processInstanceId,
63
- processModelId: processNotification.processModelId,
64
- token: processNotification.currentToken,
65
- action: 'resumed',
66
- type: 'processInstance',
67
- },
103
+
104
+ const newQuery = {
105
+ processInstanceId: processNotification.processInstanceId,
106
+ ...query,
107
+ };
108
+
109
+ const matchingInstances = await client.processInstances.query(newQuery, {
110
+ identity: currentIdentity,
68
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
+ },
127
+ });
128
+ }
69
129
  },
70
- { identity: currentIdentity }
130
+ { identity: currentIdentity }
71
131
  );
72
132
  case 'finished':
73
133
  return await client.notification.onProcessEnded(
74
- (processNotification) => {
75
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
134
+ async (processNotification) => {
135
+ if (
136
+ config.processmodel != '' &&
137
+ config.processmodel != processNotification.processModelId
138
+ )
76
139
  return;
77
- node.send({
78
- payload: {
79
- processInstanceId: processNotification.processInstanceId,
80
- processModelId: processNotification.processModelId,
81
- flowNodeId: processNotification.flowNodeId,
82
- token: processNotification.currentToken,
83
- action: 'finished',
84
- type: 'processInstance',
85
- },
140
+
141
+ const newQuery = {
142
+ processInstanceId: processNotification.processInstanceId,
143
+ ...query,
144
+ };
145
+
146
+ const matchingInstances = await client.processInstances.query(newQuery, {
147
+ identity: currentIdentity,
86
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
+ },
165
+ });
166
+ }
87
167
  },
88
168
  { identity: currentIdentity }
89
169
  );
90
170
  case 'terminated':
91
171
  return await client.notification.onProcessTerminated(
92
- (processNotification) => {
93
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
172
+ async (processNotification) => {
173
+ if (
174
+ config.processmodel != '' &&
175
+ config.processmodel != processNotification.processModelId
176
+ )
94
177
  return;
95
- node.send({
96
- payload: {
97
- processInstanceId: processNotification.processInstanceId,
98
- processModelId: processNotification.processModelId,
99
- token: processNotification.currentToken,
100
- action: 'terminated',
101
- type: 'processInstance',
102
- },
178
+
179
+ const newQuery = {
180
+ processInstanceId: processNotification.processInstanceId,
181
+ ...query,
182
+ };
183
+
184
+ const matchingInstances = await client.processInstances.query(newQuery, {
185
+ identity: currentIdentity,
103
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
+ });
203
+ }
104
204
  },
105
205
  { identity: currentIdentity }
106
206
  );
107
- case "error":
207
+ case 'error':
108
208
  return await client.notification.onProcessError(
109
- (processNotification) => {
110
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
209
+ async (processNotification) => {
210
+ if (
211
+ config.processmodel != '' &&
212
+ config.processmodel != processNotification.processModelId
213
+ )
111
214
  return;
112
- node.send({
113
- payload: {
114
- processInstanceId: processNotification.processInstanceId,
115
- processModelId: processNotification.processModelId,
116
- token: processNotification.currentToken,
117
- action: 'error',
118
- type: 'processInstance',
119
- },
215
+
216
+ const newQuery = {
217
+ processInstanceId: processNotification.processInstanceId,
218
+ ...query,
219
+ };
220
+
221
+ const matchingInstances = await client.processInstances.query(newQuery, {
222
+ identity: currentIdentity,
120
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
+ },
239
+ });
240
+ }
121
241
  },
122
242
  { identity: currentIdentity }
123
243
  );
124
- case "owner-changed":
244
+ case 'owner-changed':
125
245
  return await client.notification.onProcessOwnerChanged(
126
- (processNotification) => {
127
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
246
+ async (processNotification) => {
247
+ if (
248
+ config.processmodel != '' &&
249
+ config.processmodel != processNotification.processModelId
250
+ )
128
251
  return;
129
- node.send({
130
- payload: {
131
- processInstanceId: processNotification.processInstanceId,
132
- processModelId: processNotification.processModelId,
133
- action: 'owner-changed',
134
- type: 'processInstance',
135
- },
252
+
253
+ const newQuery = {
254
+ processInstanceId: processNotification.processInstanceId,
255
+ ...query,
256
+ };
257
+
258
+ const matchingInstances = await client.processInstances.query(newQuery, {
259
+ identity: currentIdentity,
136
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
+ },
275
+ });
276
+ }
137
277
  },
138
278
  { identity: currentIdentity }
139
279
  );
140
- case "instances-deleted":
280
+ case 'instances-deleted':
141
281
  return await client.notification.onProcessInstancesDeleted(
142
- (processNotification) => {
143
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
282
+ async (processNotification) => {
283
+ if (
284
+ config.processmodel != '' &&
285
+ config.processmodel != processNotification.processModelId
286
+ )
144
287
  return;
145
- node.send({
146
- payload: {
147
- processInstanceId: processNotification.processInstanceId,
148
- processModelId: processNotification.processModelId,
149
- action: 'instances-deleted',
150
- type: 'processInstance',
151
- },
288
+
289
+ const newQuery = {
290
+ processInstanceId: processNotification.processInstanceId,
291
+ ...query,
292
+ };
293
+
294
+ const matchingInstances = await client.processInstances.query(newQuery, {
295
+ identity: currentIdentity,
152
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
+ },
311
+ });
312
+ }
153
313
  },
154
314
  { identity: currentIdentity }
155
315
  );
156
- case "is-executable-changed":
316
+ case 'is-executable-changed':
157
317
  return await client.notification.onProcessIsExecutableChanged(
158
318
  (processNotification) => {
159
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
319
+ if (
320
+ config.processmodel != '' &&
321
+ config.processmodel != processNotification.processModelId
322
+ )
160
323
  return;
161
324
  node.send({
162
325
  payload: {
@@ -168,10 +331,13 @@ module.exports = function (RED) {
168
331
  },
169
332
  { identity: currentIdentity }
170
333
  );
171
- case "deployed":
334
+ case 'deployed':
172
335
  return await client.notification.onProcessDeployed(
173
336
  (processNotification) => {
174
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
337
+ if (
338
+ config.processmodel != '' &&
339
+ config.processmodel != processNotification.processModelId
340
+ )
175
341
  return;
176
342
  node.send({
177
343
  payload: {
@@ -183,10 +349,13 @@ module.exports = function (RED) {
183
349
  },
184
350
  { identity: currentIdentity }
185
351
  );
186
- case "undeployed":
352
+ case 'undeployed':
187
353
  return await client.notification.onProcessUndeployed(
188
354
  (processNotification) => {
189
- if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
355
+ if (
356
+ config.processmodel != '' &&
357
+ config.processmodel != processNotification.processModelId
358
+ )
190
359
  return;
191
360
  node.send({
192
361
  payload: {
@@ -199,13 +368,13 @@ module.exports = function (RED) {
199
368
  { identity: currentIdentity }
200
369
  );
201
370
  default:
202
- console.error("no such event: " + eventType)
371
+ console.error('no such event: ' + eventType);
203
372
  break;
204
373
  }
205
374
  }
206
375
 
207
376
  if (node.engine.isIdentityReady()) {
208
- subscription = await subscribe(config.eventtype)
377
+ subscription = await subscribe(config.eventtype);
209
378
  }
210
379
 
211
380
  node.engine.registerOnIdentityChanged(async (identity) => {
@@ -17,25 +17,6 @@ module.exports = function (RED) {
17
17
  let subscription;
18
18
  const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node);
19
19
 
20
- async function filterAndSend(query) {
21
- const newQuery = {
22
- flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
23
- ...query,
24
- };
25
-
26
- const matchingFlowNodes = await client.userTasks.query(newQuery, {
27
- identity: currentIdentity,
28
- });
29
-
30
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
31
- const userTask = matchingFlowNodes.userTasks[0];
32
-
33
- node.send({
34
- payload: { userTask: userTask },
35
- });
36
- }
37
- }
38
-
39
20
  async function subscribe() {
40
21
  switch (config.eventtype) {
41
22
  case 'new':