@5minds/node-red-contrib-processcube 1.7.5 → 1.7.6-feature-15fc67-m6qi3ii3

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/README.md CHANGED
@@ -25,13 +25,19 @@ To install and run the Node-RED flows, follow these steps:
25
25
  cd processcube_nodered
26
26
  ```
27
27
 
28
- 3. Build the Docker containers:
28
+ 3. Install the dependencies of the package `@5minds/node-red-contrib-processcube`:
29
+
30
+ ```bash
31
+ npm install
32
+ ```
33
+
34
+ 4. Build the Docker containers:
29
35
 
30
36
  ```bash
31
37
  docker-compose build
32
38
  ```
33
39
 
34
- 4. Start the Docker containers:
40
+ 5. Start the Docker containers:
35
41
 
36
42
  ```bash
37
43
  docker-compose up -d
@@ -6,6 +6,8 @@ module.exports = function (RED) {
6
6
  node.on('input', function (msg) {
7
7
  node.engine = RED.nodes.getNode(config.engine);
8
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
13
  node.error('No engine configured.', msg);
@@ -16,6 +18,7 @@ module.exports = function (RED) {
16
18
  .triggerMessageEvent(config.messagename, {
17
19
  processInstanceId: msg.processinstanceid,
18
20
  payload: msg.payload,
21
+ identity: userIdentity
19
22
  })
20
23
  .then((result) => {
21
24
  msg.payload = result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.7.5",
3
+ "version": "1.7.6-feature-15fc67-m6qi3ii3",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
package/process-start.js CHANGED
@@ -40,8 +40,11 @@ module.exports = function (RED) {
40
40
  return;
41
41
  }
42
42
 
43
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
44
+ const identity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
45
+
43
46
  client.processDefinitions
44
- .startProcessInstance(startParameters)
47
+ .startProcessInstance(startParameters, identity)
45
48
  .then((result) => {
46
49
  msg.payload = result;
47
50
 
@@ -6,6 +6,8 @@ module.exports = function (RED) {
6
6
  node.on('input', function (msg) {
7
7
  node.engine = RED.nodes.getNode(config.engine);
8
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
13
  node.error('No engine configured.', msg);
@@ -13,7 +15,7 @@ module.exports = function (RED) {
13
15
  }
14
16
 
15
17
  client.processInstances
16
- .terminateProcessInstance(msg.payload)
18
+ .terminateProcessInstance(msg.payload, userIdentity)
17
19
  .then(() => {
18
20
  node.send(msg);
19
21
  })
@@ -1,6 +1,4 @@
1
1
  const engine_client = require('@5minds/processcube_engine_client');
2
- const jwt = require('jwt-decode');
3
- const oidc = require('openid-client');
4
2
 
5
3
  module.exports = function (RED) {
6
4
  function ProcessCubeEngineNode(n) {
@@ -6,6 +6,8 @@ module.exports = function (RED) {
6
6
  node.on('input', function (msg) {
7
7
  node.engine = RED.nodes.getNode(config.engine);
8
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
13
  node.error('No engine configured.');
@@ -13,7 +15,7 @@ module.exports = function (RED) {
13
15
  }
14
16
 
15
17
  client.processDefinitions
16
- .persistProcessDefinitions(msg.payload, { overwriteExisting: true })
18
+ .persistProcessDefinitions(msg.payload, { overwriteExisting: true, identity: userIdentity })
17
19
  .then(() => {
18
20
  node.send(msg);
19
21
  })
@@ -16,6 +16,10 @@ module.exports = function (RED) {
16
16
 
17
17
  node.log(`Querying process definitions with query: ${JSON.stringify(query)}`);
18
18
 
19
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
20
+ const identity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
21
+ query.identity = identity;
22
+
19
23
  client.processDefinitions
20
24
  .getAll(query)
21
25
  .then((matchingProcessDefinitions) => {
@@ -7,6 +7,9 @@ module.exports = function (RED) {
7
7
  node.engine = RED.nodes.getNode(config.engine);
8
8
  const client = node.engine ? node.engine.engineClient : null;
9
9
 
10
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
11
+ const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
12
+
10
13
  if (!client || !client.processInstances) {
11
14
  node.error('No engine or processInstances API configured.', msg);
12
15
  return;
@@ -64,7 +67,10 @@ module.exports = function (RED) {
64
67
  state: ['finished', 'error', 'terminated'],
65
68
  limit: batchSize,
66
69
  },
67
- { includeXml: false }
70
+ {
71
+ includeXml: false,
72
+ identity: userIdentity
73
+ }
68
74
  );
69
75
 
70
76
  const processInstances = result.processInstances || [];
@@ -77,7 +83,7 @@ module.exports = function (RED) {
77
83
  const ids = processInstances.map((obj) => obj.processInstanceId);
78
84
 
79
85
  try {
80
- await client.processInstances.deleteProcessInstances(ids, true);
86
+ await client.processInstances.deleteProcessInstances(ids, true, userIdentity);
81
87
  msg.payload.successfulDeletions.push(...ids);
82
88
  sumSuccessful += ids.length;
83
89
  } catch (deleteError) {
@@ -8,6 +8,8 @@ module.exports = function (RED) {
8
8
 
9
9
  node.engine = RED.nodes.getNode(config.engine);
10
10
  const client = node.engine.engineClient;
11
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
12
+ const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
11
13
 
12
14
  if (!client) {
13
15
  node.error('No engine configured.', msg);
@@ -15,7 +17,7 @@ module.exports = function (RED) {
15
17
  }
16
18
 
17
19
  client.processInstances
18
- .query(query)
20
+ .query(query, { identity: userIdentity })
19
21
  .then((matchingInstances) => {
20
22
  msg.payload = matchingInstances;
21
23
 
@@ -7,6 +7,8 @@ module.exports = function (RED) {
7
7
  node.engine = RED.nodes.getNode(config.engine);
8
8
 
9
9
  const client = node.engine.engineClient;
10
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
11
+ const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
10
12
 
11
13
  if (!client) {
12
14
  node.error('No engine configured.', msg);
@@ -17,6 +19,7 @@ module.exports = function (RED) {
17
19
  .triggerSignalEvent(config.signalname, {
18
20
  processInstanceId: msg.processinstanceid,
19
21
  payload: msg.payload,
22
+ identity: userIdentity
20
23
  })
21
24
  .then((result) => {
22
25
  msg.payload = result;
package/usertask-input.js CHANGED
@@ -7,6 +7,8 @@ module.exports = function (RED) {
7
7
  node.engine = RED.nodes.getNode(config.engine);
8
8
 
9
9
  const client = node.engine.engineClient;
10
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
11
+ const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
10
12
 
11
13
  if (!client) {
12
14
  node.error('No engine configured.', msg);
@@ -16,7 +18,7 @@ module.exports = function (RED) {
16
18
  let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
17
19
 
18
20
  client.userTasks
19
- .query(query)
21
+ .query(query, {identity: userIdentity})
20
22
  .then((matchingFlowNodes) => {
21
23
  if (config.sendtype === 'array') {
22
24
  msg.payload = { userTasks: matchingFlowNodes.userTasks || [] };
@@ -17,6 +17,8 @@ module.exports = function (RED) {
17
17
  node.engine = RED.nodes.getNode(config.engine);
18
18
 
19
19
  const client = node.engine.engineClient;
20
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
21
+ const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
20
22
 
21
23
  if (!client) {
22
24
  node.error('No engine configured.', msg);
@@ -24,7 +26,7 @@ module.exports = function (RED) {
24
26
  }
25
27
 
26
28
  client.userTasks
27
- .finishUserTask(flowNodeInstanceId, userTaskResult)
29
+ .finishUserTask(flowNodeInstanceId, userTaskResult, userIdentity)
28
30
  .then(() => {
29
31
  node.send(msg);
30
32
  })
@@ -10,6 +10,8 @@ module.exports = function (RED) {
10
10
 
11
11
  node.on('input', async function (msg) {
12
12
  const client = node.engine.engineClient;
13
+ const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
14
+ const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
13
15
  subscribe = async () => {
14
16
  if (!client) {
15
17
  node.error('No engine configured.', msg);
@@ -25,11 +27,11 @@ module.exports = function (RED) {
25
27
  };
26
28
 
27
29
  try {
28
- const matchingFlowNodes = await client.userTasks.query(newQuery);
30
+ const matchingFlowNodes = await client.userTasks.query(newQuery, {identity: userIdentity});
29
31
 
30
32
  if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
31
33
  // remove subscription
32
- client.userTasks.removeSubscription(subscription);
34
+ client.userTasks.removeSubscription(subscription, userIdentity);
33
35
 
34
36
  const userTask = matchingFlowNodes.userTasks[0];
35
37
 
@@ -41,6 +43,8 @@ module.exports = function (RED) {
41
43
  } catch (error) {
42
44
  node.error(error, msg);
43
45
  }
46
+ },{
47
+ identity: userIdentity,
44
48
  });
45
49
 
46
50
  node.log({ 'Handling old userTasks config.only_for_new': config.only_for_new });
@@ -53,7 +57,7 @@ module.exports = function (RED) {
53
57
  };
54
58
 
55
59
  try {
56
- const matchingFlowNodes = await client.userTasks.query(suspendedQuery);
60
+ const matchingFlowNodes = await client.userTasks.query(suspendedQuery, {identity: userIdentity});
57
61
 
58
62
  if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
59
63
  const userTask = matchingFlowNodes.userTasks[0];
@@ -62,7 +66,7 @@ module.exports = function (RED) {
62
66
  node.send(msg);
63
67
 
64
68
  // remove subscription
65
- client.userTasks.removeSubscription(subscription);
69
+ client.userTasks.removeSubscription(subscription, userIdentity);
66
70
  } else {
67
71
  // let the *currentIdentity* be active
68
72
  }