@5minds/node-red-contrib-processcube 0.15.0-fix-error-in-process-instance-query-8fa811-lz054xqa → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,19 +27,19 @@
27
27
  </script>
28
28
 
29
29
  <script type="text/markdown" data-help-name="externaltask-error">
30
- Used for reporting errors in the processing of external tasks. The error
31
- code `Error` in the configuration is forwarded to the ProcessCube engine for
32
- handling within *Error-Boundary-Events*.
30
+ Used for reporting errors in the processing of external tasks. The error
31
+ code `Error` in the configuration is forwarded to the ProcessCube engine for
32
+ handling within _Error-Boundary-Events_.
33
33
 
34
- ## Inputs
34
+ ## Inputs
35
35
 
36
- : msg (Object) : Passed as `ErrorDetails` to the engine
37
- : Error (string) : From the configuration
38
- : Message (string) : The caught exception message
39
- : StackTrace (string) : The stack trace of the exception
36
+ : msg (Object) : Passed as `ErrorDetails` to the engine
37
+ : Error (string) : From the configuration
38
+ : Message (string) : The caught exception message
39
+ : StackTrace (string) : The stack trace of the exception
40
40
 
41
- ### References
41
+ ### References
42
42
 
43
- - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
44
- - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
43
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
44
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
45
45
  </script>
@@ -12,7 +12,7 @@ module.exports = function (RED) {
12
12
  let msgError = msg.error;
13
13
 
14
14
  if (msgError === undefined) {
15
- msgError.message = "An error occurred";
15
+ msgError.message = 'An error occurred';
16
16
  }
17
17
 
18
18
  const error = new Error(msgError.message);
@@ -23,7 +23,7 @@ module.exports = function (RED) {
23
23
  msg.errorMessage = msgError.message;
24
24
 
25
25
  eventEmitter.emit(`handle-${flowNodeInstanceId}`, error, true);
26
-
26
+
27
27
  node.send(msg);
28
28
  });
29
29
  }
@@ -32,22 +32,22 @@
32
32
  </script>
33
33
 
34
34
  <script type="text/markdown" data-help-name="externaltask-input">
35
- Waiting for external tasks that correspond to the `Topic` configured in
36
- the connected ProcessCube Engine for processing.
35
+ Waiting for external tasks that correspond to the `Topic` configured in
36
+ the connected ProcessCube Engine for processing.
37
37
 
38
- ## Outputs
38
+ ## Outputs
39
39
 
40
- : payload (string) : Defines the input of the external task token
41
- : task (object) : The external task object
42
- : flowNodeInstanceId : The Id of the external task, which is needed to complete the task
40
+ : payload (string) : Defines the input of the external task token
41
+ : task (object) : The external task object
42
+ : flowNodeInstanceId : The Id of the external task, which is needed to complete the task
43
43
 
44
- ### Details
44
+ ### Details
45
45
 
46
- - To finish the external task the `externaltask-output` node is required.
47
- - For handling a error while executing a flow as external task the `externaltask-error` node is required.
46
+ - To finish the external task the `externaltask-output` node is required.
47
+ - For handling a error while executing a flow as external task the `externaltask-error` node is required.
48
48
 
49
- ### References
49
+ ### References
50
50
 
51
- - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; Plattform
52
- - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED Integration in ProcessCube&copy;
51
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; Plattform
52
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED Integration in ProcessCube&copy;
53
53
  </script>
@@ -2,9 +2,9 @@ const EventEmitter = require('node:events');
2
2
 
3
3
  function showStatus(node, msgCounter) {
4
4
  if (msgCounter >= 1) {
5
- node.status({ fill: 'blue', shape: 'dot', text: `handling tasks ${msgCounter}` });
5
+ node.status({ fill: 'blue', shape: 'dot', text: `handling tasks ${msgCounter}.` });
6
6
  } else {
7
- node.status({ fill: 'blue', shape: 'ring', text: `subcribed ${msgCounter}` });
7
+ node.status({ fill: 'blue', shape: 'ring', text: `subcribed.` });
8
8
  }
9
9
  }
10
10
 
@@ -27,121 +27,130 @@ module.exports = function (RED) {
27
27
  eventEmitter = flowContext.get('emitter');
28
28
  }
29
29
 
30
- client.externalTasks.subscribeToExternalTaskTopic(config.topic, async (payload, externalTask) => {
31
-
32
- const saveHandleCallback = (data, callback) => {
33
- try {
34
- callback(data);
35
- } catch (error) {
36
- node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
37
- }
38
- };
39
-
40
- return await new Promise((resolve, reject) => {
41
-
42
- const handleFinishTask = (msg) => {
43
- let result = RED.util.encodeObject(msg.payload);
44
-
45
- node.log(`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`);
46
-
47
- if (externalTask.flowNodeInstanceId) {
48
- delete started_external_tasks[externalTask.flowNodeInstanceId];
30
+ client.externalTasks
31
+ .subscribeToExternalTaskTopic(config.topic, async (payload, externalTask) => {
32
+ const saveHandleCallback = (data, callback) => {
33
+ try {
34
+ callback(data);
35
+ } catch (error) {
36
+ node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
49
37
  }
50
-
51
- showStatus(node, Object.keys(started_external_tasks).length);
52
-
53
-
54
- //resolve(result);
55
- saveHandleCallback(result, resolve)
56
38
  };
57
39
 
58
- const handleErrorTask = (msg) => {
59
-
60
- node.log(`handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`);
61
-
62
- if (externalTask.flowNodeInstanceId) {
63
- delete started_external_tasks[externalTask.flowNodeInstanceId];
64
- }
40
+ return await new Promise((resolve, reject) => {
41
+ const handleFinishTask = (msg) => {
42
+ let result = RED.util.encodeObject(msg.payload);
65
43
 
66
- showStatus(node, Object.keys(started_external_tasks).length);
44
+ node.log(
45
+ `handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`,
46
+ );
67
47
 
48
+ if (externalTask.flowNodeInstanceId) {
49
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
50
+ }
68
51
 
69
- // TODO: with reject, the default error handling is proceed
70
- // SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
71
- // reject(result);
72
- //resolve(msg);
73
- saveHandleCallback(msg, resolve);
74
- };
52
+ showStatus(node, Object.keys(started_external_tasks).length);
75
53
 
76
- eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
77
- node.log(`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`);
54
+ //resolve(result);
55
+ saveHandleCallback(result, resolve);
56
+ };
78
57
 
79
- if (isError) {
80
- handleErrorTask(msg);
81
- } else {
82
- handleFinishTask(msg);
83
- }
84
- });
58
+ const handleErrorTask = (msg) => {
59
+ node.log(
60
+ `handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`,
61
+ );
85
62
 
86
- started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
63
+ if (externalTask.flowNodeInstanceId) {
64
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
65
+ }
87
66
 
88
- showStatus(node, Object.keys(started_external_tasks).length);
67
+ showStatus(node, Object.keys(started_external_tasks).length);
89
68
 
90
- let msg = {
91
- _msgid: RED.util.generateId(),
92
- task: RED.util.encodeObject(externalTask),
93
- payload: payload,
94
- flowNodeInstanceId: externalTask.flowNodeInstanceId
95
- };
69
+ // TODO: with reject, the default error handling is proceed
70
+ // SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
71
+ // reject(result);
72
+ //resolve(msg);
73
+ saveHandleCallback(msg, resolve);
74
+ };
75
+
76
+ eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
77
+ node.log(
78
+ `handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`,
79
+ );
80
+
81
+ if (isError) {
82
+ handleErrorTask(msg);
83
+ } else {
84
+ handleFinishTask(msg);
85
+ }
86
+ });
96
87
 
97
- node.log(`Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`);
88
+ started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
98
89
 
99
- node.send(msg);
100
- });
101
- })
102
- .then(async (externalTaskWorker) => {
103
- node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
90
+ showStatus(node, Object.keys(started_external_tasks).length);
104
91
 
105
- externalTaskWorker.identity = node.server.identity;
106
- node.server.registerOnIdentityChanged((identity) => {
107
- externalTaskWorker.identity = identity;
108
- });
92
+ let msg = {
93
+ _msgid: RED.util.generateId(),
94
+ task: RED.util.encodeObject(externalTask),
95
+ payload: payload,
96
+ flowNodeInstanceId: externalTask.flowNodeInstanceId,
97
+ };
109
98
 
110
- // export type WorkerErrorHandler = (errorType: 'fetchAndLock' | 'extendLock' | 'processExternalTask' | 'finishExternalTask', error: Error, externalTask?: ExternalTask<any>) => void;
111
- externalTaskWorker.onWorkerError((errorType, error, externalTask) => {
112
- switch (errorType) {
113
- case 'extendLock':
114
- case 'finishExternalTask':
115
- case 'processExternalTask':
116
- node.error(`Worker error ${errorType} for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}': ${error.message}`);
99
+ node.log(
100
+ `Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`,
101
+ );
117
102
 
118
- if (externalTask) {
119
- delete started_external_tasks[externalTask.flowNodeInstanceId];
120
- }
103
+ node.send(msg);
104
+ });
105
+ })
106
+ .then(async (externalTaskWorker) => {
107
+ node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
121
108
 
122
- showStatus(node, Object.keys(started_external_tasks).length);
123
- break;
124
- default:
125
- node.error(`Worker error ${errorType}: ${error.message}`);
126
- break;
127
- }
128
- });
109
+ externalTaskWorker.identity = node.server.identity;
110
+ node.server.registerOnIdentityChanged((identity) => {
111
+ externalTaskWorker.identity = identity;
112
+ });
129
113
 
130
- try {
131
- externalTaskWorker.start();
132
- } catch (error) {
133
- node.error(`Worker start 'externalTaskWorker.start' failed: ${error.message}`);
134
- }
114
+ // export type WorkerErrorHandler = (errorType: 'fetchAndLock' | 'extendLock' | 'processExternalTask' | 'finishExternalTask', error: Error, externalTask?: ExternalTask<any>) => void;
115
+ externalTaskWorker.onWorkerError((errorType, error, externalTask) => {
116
+ switch (errorType) {
117
+ case 'extendLock':
118
+ case 'finishExternalTask':
119
+ case 'processExternalTask':
120
+ node.error(
121
+ `Worker error ${errorType} for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}': ${error.message}`,
122
+ );
123
+
124
+ if (externalTask) {
125
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
126
+ }
127
+
128
+ showStatus(node, Object.keys(started_external_tasks).length);
129
+ break;
130
+ default:
131
+ node.error(`Worker error ${errorType}: ${error.message}`);
132
+ break;
133
+ }
134
+ });
135
135
 
136
- node.on("close", () => {
137
136
  try {
138
- externalTaskWorker.stop();
139
- } catch {
140
- node.error('Client close failed');
137
+ externalTaskWorker.start();
138
+ } catch (error) {
139
+ node.error(`Worker start 'externalTaskWorker.start' failed: ${error.message}`);
141
140
  }
141
+
142
+ node.on('close', () => {
143
+ try {
144
+ externalTaskWorker.stop();
145
+ } catch {
146
+ node.error('Client close failed');
147
+ }
148
+ });
149
+ })
150
+ .catch((error) => {
151
+ node.error(`Error in subscribeToExternalTaskTopic: ${error.message}`);
142
152
  });
143
- });
144
153
  }
145
154
 
146
- RED.nodes.registerType("externaltask-input", ExternalTaskInput);
147
- }
155
+ RED.nodes.registerType('externaltask-input', ExternalTaskInput);
156
+ };
@@ -22,15 +22,15 @@
22
22
  </script>
23
23
 
24
24
  <script type="text/markdown" data-help-name="externaltask-output">
25
- Used to complete the external task. The `msg.payload` is returned to the ProcessCube
26
- engine as the result of the external task.
25
+ Used to complete the external task. The `msg.payload` is returned to the ProcessCube
26
+ engine as the result of the external task.
27
27
 
28
- ## Inputs
28
+ ## Inputs
29
29
 
30
- : payload (Object) : Returned to the ProcessCube engine as the result of the external task
30
+ : payload (Object) : Returned to the ProcessCube engine as the result of the external task
31
31
 
32
- ### References
32
+ ### References
33
33
 
34
- - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
35
- - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
34
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
35
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
36
36
  </script>
@@ -6,16 +6,15 @@ module.exports = function (RED) {
6
6
  var flowContext = node.context().flow;
7
7
  var eventEmitter = flowContext.get('emitter');
8
8
 
9
- node.on('input', function(msg) {
10
-
9
+ node.on('input', function (msg) {
11
10
  const flowNodeInstanceId = msg.flowNodeInstanceId;
12
11
 
13
12
  if (!flowNodeInstanceId) {
14
- node.error('Error: The message did not contain the required external task id.', msg);
15
- }
13
+ node.error('Error: The message did not contain the required external task id.', msg);
14
+ }
16
15
 
17
16
  eventEmitter.emit(`handle-${flowNodeInstanceId}`, msg, false);
18
- });
17
+ });
19
18
  }
20
19
  RED.nodes.registerType('externaltask-output', ExternalTaskOutput);
21
20
  };
@@ -1,3 +1,7 @@
1
+ const process = require('process');
2
+
3
+ const engine_client = require('@5minds/processcube_engine_client');
4
+
1
5
  module.exports = function (RED) {
2
6
  function MessageEventTrigger(config) {
3
7
  RED.nodes.createNode(this, config);
@@ -382,7 +382,7 @@ module.exports = {
382
382
  //tours: false,
383
383
 
384
384
  header: {
385
- title: 'Node-RED powered by ProcessCube &copy;',
385
+ title: 'Node-RED powered by ProcessCube&copy;',
386
386
  url: 'https://processcube.io', // optional url to make the header text/image a link to this url
387
387
  },
388
388
  palette: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "0.15.0-fix-error-in-process-instance-query-8fa811-lz054xqa",
3
+ "version": "0.15.0",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -61,8 +61,5 @@
61
61
  "workflow",
62
62
  "bpmn",
63
63
  "low-code"
64
- ],
65
- "devDependencies": {
66
- "prettier": "^3.3.3"
67
- }
64
+ ]
68
65
  }
package/process-start.js CHANGED
@@ -1,3 +1,6 @@
1
+ const process = require('process');
2
+ const engine_client = require('@5minds/processcube_engine_client');
3
+
1
4
  module.exports = function (RED) {
2
5
  function ProcessStart(config) {
3
6
  RED.nodes.createNode(this, config);
@@ -20,7 +23,11 @@ module.exports = function (RED) {
20
23
  msg.payload = result;
21
24
 
22
25
  node.send(msg);
23
- node.status({ fill: 'blue', shape: 'dot', text: `started ${result.processInstanceId}` });
26
+ node.status({
27
+ fill: 'blue',
28
+ shape: 'dot',
29
+ text: `started ${result.processInstanceId}`,
30
+ });
24
31
  })
25
32
  .catch((error) => {
26
33
  node.error(error);
@@ -14,6 +14,7 @@ module.exports = function (RED) {
14
14
  this.registerOnIdentityChanged = function (callback) {
15
15
  identityChangedCallbacks.push(callback);
16
16
  };
17
+
17
18
  this.setIdentity = (identity) => {
18
19
  this.identity = identity;
19
20
 
@@ -31,7 +32,7 @@ module.exports = function (RED) {
31
32
  if (!client) {
32
33
  nodeContext.set('client', new engine_client.EngineClient(engineUrl));
33
34
  client = nodeContext.get('client');
34
- }
35
+ }
35
36
 
36
37
  return client;
37
38
  };
@@ -1,4 +1,7 @@
1
- const EventEmitter = require("node:events");
1
+ const process = require('process');
2
+ const EventEmitter = require('node:events');
3
+
4
+ const engine_client = require('@5minds/processcube_engine_client');
2
5
 
3
6
  module.exports = function (RED) {
4
7
  function ProcessdefinitionQuery(config) {
@@ -10,11 +13,11 @@ module.exports = function (RED) {
10
13
 
11
14
  const client = this.engine.getEngineClient();
12
15
 
13
- var eventEmitter = flowContext.get("emitter");
16
+ var eventEmitter = flowContext.get('emitter');
14
17
 
15
18
  if (!eventEmitter) {
16
- flowContext.set("emitter", new EventEmitter());
17
- eventEmitter = flowContext.get("emitter");
19
+ flowContext.set('emitter', new EventEmitter());
20
+ eventEmitter = flowContext.get('emitter');
18
21
  }
19
22
 
20
23
  node.on('close', async () => {
@@ -51,6 +54,5 @@ module.exports = function (RED) {
51
54
  });
52
55
  });
53
56
  }
54
-
55
57
  RED.nodes.registerType('processdefinition-query', ProcessdefinitionQuery);
56
58
  };
@@ -1,4 +1,7 @@
1
- const EventEmitter = require("node:events");
1
+ const process = require('process');
2
+ const EventEmitter = require('node:events');
3
+
4
+ const engine_client = require('@5minds/processcube_engine_client');
2
5
 
3
6
  module.exports = function (RED) {
4
7
  function ProcessinstanceQuery(config) {
@@ -10,11 +13,11 @@ module.exports = function (RED) {
10
13
 
11
14
  const client = this.engine.getEngineClient();
12
15
 
13
- var eventEmitter = flowContext.get("emitter");
16
+ var eventEmitter = flowContext.get('emitter');
14
17
 
15
18
  if (!eventEmitter) {
16
- flowContext.set("emitter", new EventEmitter());
17
- eventEmitter = flowContext.get("emitter");
19
+ flowContext.set('emitter', new EventEmitter());
20
+ eventEmitter = flowContext.get('emitter');
18
21
  }
19
22
 
20
23
  node.on('close', async () => {
@@ -37,6 +40,5 @@ module.exports = function (RED) {
37
40
  });
38
41
  });
39
42
  }
40
-
41
43
  RED.nodes.registerType('processinstance-query', ProcessinstanceQuery);
42
44
  };
@@ -1,3 +1,6 @@
1
+ const process = require('process');
2
+
3
+ const engine_client = require('@5minds/processcube_engine_client');
1
4
 
2
5
  module.exports = function (RED) {
3
6
  function SignalEventTrigger(config) {
@@ -19,13 +22,16 @@ module.exports = function (RED) {
19
22
  msg.payload = result;
20
23
 
21
24
  node.send(msg);
22
- node.status({ fill: 'blue', shape: 'dot', text: `signal event triggered` });
25
+ node.status({
26
+ fill: 'blue',
27
+ shape: 'dot',
28
+ text: `signal event triggered`,
29
+ });
23
30
  })
24
31
  .catch((error) => {
25
32
  node.error(error);
26
33
  });
27
34
  });
28
35
  }
29
-
30
36
  RED.nodes.registerType('signal-event-trigger', SignalEventTrigger);
31
37
  };
@@ -1,4 +1,7 @@
1
- const EventEmitter = require("node:events");
1
+ const process = require('process');
2
+ const EventEmitter = require('node:events');
3
+
4
+ const engine_client = require('@5minds/processcube_engine_client');
2
5
 
3
6
  module.exports = function (RED) {
4
7
  function UserTaskFinishedListener(config) {
@@ -10,11 +13,11 @@ module.exports = function (RED) {
10
13
 
11
14
  const client = this.engine.getEngineClient();
12
15
 
13
- var eventEmitter = flowContext.get("emitter");
16
+ var eventEmitter = flowContext.get('emitter');
14
17
 
15
18
  if (!eventEmitter) {
16
- flowContext.set("emitter", new EventEmitter());
17
- eventEmitter = flowContext.get("emitter");
19
+ flowContext.set('emitter', new EventEmitter());
20
+ eventEmitter = flowContext.get('emitter');
18
21
  }
19
22
 
20
23
  const register = async () => {
@@ -23,43 +26,35 @@ module.exports = function (RED) {
23
26
  (userTaskFinishedNotification) => {
24
27
  node.send({
25
28
  payload: {
26
- flowNodeInstanceId:
27
- userTaskFinishedNotification.flowNodeInstanceId,
28
- action: "finished",
29
- type: "usertask",
29
+ flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
30
+ action: 'finished',
31
+ type: 'usertask',
30
32
  },
31
33
  });
32
34
  },
33
- { identity: currentIdentity }
35
+ { identity: currentIdentity },
34
36
  );
35
37
 
36
38
  node.server.registerOnIdentityChanged(async (identity) => {
37
- client.userTasks.removeSubscription(
38
- subscription,
39
- currentIdentity
40
- );
39
+ client.userTasks.removeSubscription(subscription, currentIdentity);
41
40
  currentIdentity = identity;
42
41
 
43
42
  subscription = await client.userTasks.onUserTaskFinished(
44
43
  (userTaskFinishedNotification) => {
45
44
  node.send({
46
45
  payload: {
47
- flowNodeInstanceId:
48
- userTaskFinishedNotification.flowNodeInstanceId,
49
- action: "finished",
50
- type: "usertask",
46
+ flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
47
+ action: 'finished',
48
+ type: 'usertask',
51
49
  },
52
50
  });
53
51
  },
54
- { identity: currentIdentity }
52
+ { identity: currentIdentity },
55
53
  );
56
54
  });
57
55
 
58
- node.on("close", async () => {
59
- client.userTasks.removeSubscription(
60
- subscription,
61
- currentIdentity
62
- );
56
+ node.on('close', async () => {
57
+ client.userTasks.removeSubscription(subscription, currentIdentity);
63
58
  client.dispose();
64
59
  client = null;
65
60
  });
package/usertask-input.js CHANGED
@@ -1,20 +1,40 @@
1
- const EventEmitter = require("node:events");
1
+ const process = require('process');
2
+ const EventEmitter = require('node:events');
3
+
4
+ const engine_client = require('@5minds/processcube_engine_client');
5
+
6
+ function showStatus(node, msgCounter) {
7
+ if (msgCounter >= 1) {
8
+ node.status({
9
+ fill: 'blue',
10
+ shape: 'dot',
11
+ text: `handling tasks ${msgCounter}`,
12
+ });
13
+ } else {
14
+ node.status({
15
+ fill: 'blue',
16
+ shape: 'ring',
17
+ text: `subcribed ${msgCounter}`,
18
+ });
19
+ }
20
+ }
2
21
 
3
22
  module.exports = function (RED) {
4
23
  function UserTaskInput(config) {
5
24
  RED.nodes.createNode(this, config);
6
25
  var node = this;
26
+ var msgCounter = 0;
7
27
  var flowContext = node.context().flow;
8
28
 
9
29
  this.engine = this.server = RED.nodes.getNode(config.engine);
10
30
 
11
31
  const client = this.engine.getEngineClient();
12
32
 
13
- var eventEmitter = flowContext.get("emitter");
33
+ var eventEmitter = flowContext.get('emitter');
14
34
 
15
35
  if (!eventEmitter) {
16
- flowContext.set("emitter", new EventEmitter());
17
- eventEmitter = flowContext.get("emitter");
36
+ flowContext.set('emitter', new EventEmitter());
37
+ eventEmitter = flowContext.get('emitter');
18
38
  }
19
39
 
20
40
  node.on('close', async () => {
@@ -24,12 +44,10 @@ module.exports = function (RED) {
24
44
 
25
45
  node.on('input', function (msg) {
26
46
  let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
27
-
28
47
  query = {
29
48
  ...query,
30
49
  identity: node.server.identity,
31
50
  };
32
-
33
51
  client.userTasks.query(query).then((matchingFlowNodes) => {
34
52
  if (
35
53
  !config.force_send_array &&
@@ -43,21 +61,21 @@ module.exports = function (RED) {
43
61
  node.send(msg);
44
62
  } else {
45
63
  if (!config.force_send_array) {
46
- if (
47
- config.multisend &&
48
- matchingFlowNodes.userTasks &&
49
- matchingFlowNodes.userTasks.length > 1
50
- ) {
64
+ if (config.multisend && matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length > 1) {
51
65
  matchingFlowNodes.userTasks.forEach((userTask) => {
52
66
  msg.payload = { userTask: userTask };
53
67
  node.send(msg);
54
68
  });
55
69
  } else {
56
- msg.payload = { userTasks: matchingFlowNodes.userTasks };
70
+ msg.payload = {
71
+ userTasks: matchingFlowNodes.userTasks,
72
+ };
57
73
  node.send(msg);
58
74
  }
59
75
  } else {
60
- msg.payload = { userTasks: matchingFlowNodes.userTasks || [] };
76
+ msg.payload = {
77
+ userTasks: matchingFlowNodes.userTasks || [],
78
+ };
61
79
  node.send(msg);
62
80
  }
63
81
  }
@@ -1,4 +1,7 @@
1
- const EventEmitter = require("node:events");
1
+ const process = require('process');
2
+ const EventEmitter = require('node:events');
3
+
4
+ const engine_client = require('@5minds/processcube_engine_client');
2
5
 
3
6
  module.exports = function (RED) {
4
7
  function UserTaskNewListener(config) {
@@ -10,11 +13,11 @@ module.exports = function (RED) {
10
13
 
11
14
  const client = this.engine.getEngineClient();
12
15
 
13
- var eventEmitter = flowContext.get("emitter");
16
+ var eventEmitter = flowContext.get('emitter');
14
17
 
15
18
  if (!eventEmitter) {
16
- flowContext.set("emitter", new EventEmitter());
17
- eventEmitter = flowContext.get("emitter");
19
+ flowContext.set('emitter', new EventEmitter());
20
+ eventEmitter = flowContext.get('emitter');
18
21
  }
19
22
 
20
23
  const register = async () => {
@@ -1,4 +1,7 @@
1
- const EventEmitter = require("node:events");
1
+ const process = require('process');
2
+ const EventEmitter = require('node:events');
3
+
4
+ const engine_client = require('@5minds/processcube_engine_client');
2
5
 
3
6
  module.exports = function (RED) {
4
7
  function UserTaskOutput(config) {
@@ -11,11 +14,11 @@ module.exports = function (RED) {
11
14
 
12
15
  const client = this.engine.getEngineClient();
13
16
 
14
- var eventEmitter = flowContext.get("emitter");
17
+ var eventEmitter = flowContext.get('emitter');
15
18
 
16
19
  if (!eventEmitter) {
17
- flowContext.set("emitter", new EventEmitter());
18
- eventEmitter = flowContext.get("emitter");
20
+ flowContext.set('emitter', new EventEmitter());
21
+ eventEmitter = flowContext.get('emitter');
19
22
  }
20
23
 
21
24
  node.on('input', function (msg) {
@@ -33,9 +36,7 @@ module.exports = function (RED) {
33
36
  node.error(error);
34
37
  });
35
38
  } else {
36
- node.error(
37
- `No UserTask found in message: ${JSON.stringify(msg.payload)}`
38
- );
39
+ node.error(`No UserTask found in message: ${JSON.stringify(msg.payload)}`);
39
40
  }
40
41
  });
41
42
  }