@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/usertask-input.js CHANGED
@@ -4,9 +4,9 @@ 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);
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.');
@@ -15,12 +15,8 @@ module.exports = function (RED) {
15
15
 
16
16
  let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
17
17
 
18
- query = {
19
- ...query,
20
- };
21
-
22
18
  client.userTasks
23
- .query(query, { identity: engine.identity })
19
+ .query(query)
24
20
  .then((matchingFlowNodes) => {
25
21
  if (config.sendtype === 'array') {
26
22
  msg.payload = { userTasks: matchingFlowNodes.userTasks || [] };
@@ -36,7 +32,7 @@ module.exports = function (RED) {
36
32
  } else node.log(`No user tasks found for query: ${JSON.stringify(query)}`);
37
33
  })
38
34
  .catch((error) => {
39
- node.error(error);
35
+ node.error(JSON.stringify(error));
40
36
  });
41
37
  });
42
38
  }
@@ -9,22 +9,22 @@ module.exports = function (RED) {
9
9
 
10
10
  const userTaskResult = RED.util.evaluateNodeProperty(config.result, config.result_type, node, msg);
11
11
 
12
- const engine = RED.nodes.getNode(config.engine);
12
+ node.engine = RED.nodes.getNode(config.engine);
13
13
 
14
- const client = engine.engineClient;
14
+ const client = node.engine.engineClient;
15
15
 
16
16
  if (!client) {
17
17
  node.error('No engine configured.');
18
18
  return;
19
19
  }
20
-
20
+
21
21
  client.userTasks
22
- .finishUserTask(flowNodeInstanceId, userTaskResult, engine.identity)
22
+ .finishUserTask(flowNodeInstanceId, userTaskResult)
23
23
  .then(() => {
24
24
  node.send(msg);
25
25
  })
26
26
  .catch((error) => {
27
- node.error(error);
27
+ node.error(JSON.stringify(error));
28
28
  });
29
29
  } else {
30
30
  node.error(`No UserTask found in message: ${JSON.stringify(msg.payload)}`);
@@ -6,7 +6,6 @@ module.exports = function (RED) {
6
6
  node.engine = RED.nodes.getNode(config.engine);
7
7
 
8
8
  let subscription = null;
9
- let currentIdentity = node.engine.identity;
10
9
  let subscribe = null;
11
10
 
12
11
  node.on('input', async function (msg) {
@@ -19,35 +18,30 @@ module.exports = function (RED) {
19
18
 
20
19
  const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
21
20
 
22
- subscription = await client.userTasks.onUserTaskWaiting(
23
- async (userTaskWaitingNotification) => {
24
- const newQuery = {
25
- flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
26
- ...query,
27
- };
28
-
29
- try {
30
- const matchingFlowNodes = await client.userTasks.query(newQuery, {
31
- identity: currentIdentity,
32
- });
33
-
34
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
35
- // remove subscription
36
- client.userTasks.removeSubscription(subscription, currentIdentity);
37
-
38
- const userTask = matchingFlowNodes.userTasks[0];
39
-
40
- msg.payload = { userTask: userTask };
41
- node.send(msg);
42
- } else {
43
- // nothing todo - wait for next notification
44
- }
45
- } catch (error) {
46
- node.error(error);
21
+ subscription = await client.userTasks.onUserTaskWaiting(async (userTaskWaitingNotification) => {
22
+ const newQuery = {
23
+ flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
24
+ ...query,
25
+ };
26
+
27
+ try {
28
+ const matchingFlowNodes = await client.userTasks.query(newQuery);
29
+
30
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
31
+ // remove subscription
32
+ client.userTasks.removeSubscription(subscription);
33
+
34
+ const userTask = matchingFlowNodes.userTasks[0];
35
+
36
+ msg.payload = { userTask: userTask };
37
+ node.send(msg);
38
+ } else {
39
+ // nothing todo - wait for next notification
47
40
  }
48
- },
49
- { identity: currentIdentity }
50
- );
41
+ } catch (error) {
42
+ node.error(JSON.stringify(error));
43
+ }
44
+ });
51
45
 
52
46
  node.log({ 'Handling old userTasks config.only_for_new': config.only_for_new });
53
47
 
@@ -59,9 +53,7 @@ module.exports = function (RED) {
59
53
  };
60
54
 
61
55
  try {
62
- const matchingFlowNodes = await client.userTasks.query(suspendedQuery, {
63
- identity: currentIdentity,
64
- });
56
+ const matchingFlowNodes = await client.userTasks.query(suspendedQuery);
65
57
 
66
58
  if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
67
59
  const userTask = matchingFlowNodes.userTasks[0];
@@ -70,12 +62,12 @@ module.exports = function (RED) {
70
62
  node.send(msg);
71
63
 
72
64
  // remove subscription
73
- client.userTasks.removeSubscription(subscription, currentIdentity);
65
+ client.userTasks.removeSubscription(subscription);
74
66
  } else {
75
67
  // let the *currentIdentity* be active
76
68
  }
77
69
  } catch (error) {
78
- node.error(error);
70
+ node.error(JSON.stringify(error));
79
71
  }
80
72
  }
81
73
  };
@@ -83,19 +75,9 @@ module.exports = function (RED) {
83
75
  subscribe();
84
76
  });
85
77
 
86
- node.engine.registerOnIdentityChanged(async (identity) => {
87
- if (subscription) {
88
- client.userTasks.removeSubscription(subscription, currentIdentity);
89
- currentIdentity = identity;
90
- subscribe();
91
- } else {
92
- currentIdentity = identity;
93
- }
94
- });
95
-
96
78
  node.on('close', async () => {
97
79
  if (client != null && subscription != null) {
98
- client.userTasks.removeSubscription(subscription, currentIdentity);
80
+ client.userTasks.removeSubscription(subscription);
99
81
  }
100
82
  });
101
83
  }