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

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.` });
7
+ node.status({ fill: 'blue', shape: 'ring', text: `subcribed ${msgCounter}` });
8
8
  }
9
9
  }
10
10
 
@@ -27,130 +27,121 @@ module.exports = function (RED) {
27
27
  eventEmitter = flowContext.get('emitter');
28
28
  }
29
29
 
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}`);
37
- }
38
- };
30
+ client.externalTasks.subscribeToExternalTaskTopic(config.topic, async (payload, externalTask) => {
39
31
 
40
- return await new Promise((resolve, reject) => {
41
- const handleFinishTask = (msg) => {
42
- let result = RED.util.encodeObject(msg.payload);
32
+ const saveHandleCallback = (data, callback) => {
33
+ try {
34
+ callback(data);
35
+ } catch (error) {
36
+ node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
37
+ }
38
+ };
43
39
 
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
- );
40
+ return await new Promise((resolve, reject) => {
47
41
 
48
- if (externalTask.flowNodeInstanceId) {
49
- delete started_external_tasks[externalTask.flowNodeInstanceId];
50
- }
42
+ const handleFinishTask = (msg) => {
43
+ let result = RED.util.encodeObject(msg.payload);
51
44
 
52
- showStatus(node, Object.keys(started_external_tasks).length);
45
+ node.log(`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`);
53
46
 
54
- //resolve(result);
55
- saveHandleCallback(result, resolve);
56
- };
47
+ if (externalTask.flowNodeInstanceId) {
48
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
49
+ }
57
50
 
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
- );
51
+ showStatus(node, Object.keys(started_external_tasks).length);
62
52
 
63
- if (externalTask.flowNodeInstanceId) {
64
- delete started_external_tasks[externalTask.flowNodeInstanceId];
65
- }
66
53
 
67
- showStatus(node, Object.keys(started_external_tasks).length);
54
+ //resolve(result);
55
+ saveHandleCallback(result, resolve)
56
+ };
68
57
 
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
- });
58
+ const handleErrorTask = (msg) => {
87
59
 
88
- started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
60
+ node.log(`handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`);
89
61
 
90
- showStatus(node, Object.keys(started_external_tasks).length);
62
+ if (externalTask.flowNodeInstanceId) {
63
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
64
+ }
91
65
 
92
- let msg = {
93
- _msgid: RED.util.generateId(),
94
- task: RED.util.encodeObject(externalTask),
95
- payload: payload,
96
- flowNodeInstanceId: externalTask.flowNodeInstanceId,
97
- };
66
+ showStatus(node, Object.keys(started_external_tasks).length);
98
67
 
99
- node.log(
100
- `Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`,
101
- );
102
68
 
103
- node.send(msg);
104
- });
105
- })
106
- .then(async (externalTaskWorker) => {
107
- node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
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
+ };
108
75
 
109
- externalTaskWorker.identity = node.server.identity;
110
- node.server.registerOnIdentityChanged((identity) => {
111
- externalTaskWorker.identity = identity;
112
- });
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}'`);
113
78
 
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;
79
+ if (isError) {
80
+ handleErrorTask(msg);
81
+ } else {
82
+ handleFinishTask(msg);
133
83
  }
134
84
  });
135
85
 
136
- try {
137
- externalTaskWorker.start();
138
- } catch (error) {
139
- node.error(`Worker start 'externalTaskWorker.start' failed: ${error.message}`);
86
+ started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
87
+
88
+ showStatus(node, Object.keys(started_external_tasks).length);
89
+
90
+ let msg = {
91
+ _msgid: RED.util.generateId(),
92
+ task: RED.util.encodeObject(externalTask),
93
+ payload: payload,
94
+ flowNodeInstanceId: externalTask.flowNodeInstanceId
95
+ };
96
+
97
+ node.log(`Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`);
98
+
99
+ node.send(msg);
100
+ });
101
+ })
102
+ .then(async (externalTaskWorker) => {
103
+ node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
104
+
105
+ externalTaskWorker.identity = node.server.identity;
106
+ node.server.registerOnIdentityChanged((identity) => {
107
+ externalTaskWorker.identity = identity;
108
+ });
109
+
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}`);
117
+
118
+ if (externalTask) {
119
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
120
+ }
121
+
122
+ showStatus(node, Object.keys(started_external_tasks).length);
123
+ break;
124
+ default:
125
+ node.error(`Worker error ${errorType}: ${error.message}`);
126
+ break;
140
127
  }
128
+ });
141
129
 
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}`);
130
+ try {
131
+ externalTaskWorker.start();
132
+ } catch (error) {
133
+ node.error(`Worker start 'externalTaskWorker.start' failed: ${error.message}`);
134
+ }
135
+
136
+ node.on("close", () => {
137
+ try {
138
+ externalTaskWorker.stop();
139
+ } catch {
140
+ node.error('Client close failed');
141
+ }
152
142
  });
143
+ });
153
144
  }
154
145
 
155
- RED.nodes.registerType('externaltask-input', ExternalTaskInput);
156
- };
146
+ RED.nodes.registerType("externaltask-input", ExternalTaskInput);
147
+ }
@@ -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,15 +6,16 @@ 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) {
9
+ node.on('input', function(msg) {
10
+
10
11
  const flowNodeInstanceId = msg.flowNodeInstanceId;
11
12
 
12
13
  if (!flowNodeInstanceId) {
13
- node.error('Error: The message did not contain the required external task id.', msg);
14
- }
14
+ node.error('Error: The message did not contain the required external task id.', msg);
15
+ }
15
16
 
16
17
  eventEmitter.emit(`handle-${flowNodeInstanceId}`, msg, false);
17
- });
18
+ });
18
19
  }
19
20
  RED.nodes.registerType('externaltask-output', ExternalTaskOutput);
20
21
  };
@@ -1,7 +1,3 @@
1
- const process = require('process');
2
-
3
- const engine_client = require('@5minds/processcube_engine_client');
4
-
5
1
  module.exports = function (RED) {
6
2
  function MessageEventTrigger(config) {
7
3
  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-feature-2d3c96-lz0zm47e",
3
+ "version": "0.15.0-fix-error-in-process-instance-query-8fa811-lz054xqa",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -61,5 +61,8 @@
61
61
  "workflow",
62
62
  "bpmn",
63
63
  "low-code"
64
- ]
64
+ ],
65
+ "devDependencies": {
66
+ "prettier": "^3.3.3"
67
+ }
65
68
  }
package/process-start.js CHANGED
@@ -1,6 +1,3 @@
1
- const process = require('process');
2
- const engine_client = require('@5minds/processcube_engine_client');
3
-
4
1
  module.exports = function (RED) {
5
2
  function ProcessStart(config) {
6
3
  RED.nodes.createNode(this, config);
@@ -23,11 +20,7 @@ module.exports = function (RED) {
23
20
  msg.payload = result;
24
21
 
25
22
  node.send(msg);
26
- node.status({
27
- fill: 'blue',
28
- shape: 'dot',
29
- text: `started ${result.processInstanceId}`,
30
- });
23
+ node.status({ fill: 'blue', shape: 'dot', text: `started ${result.processInstanceId}` });
31
24
  })
32
25
  .catch((error) => {
33
26
  node.error(error);
@@ -14,7 +14,6 @@ module.exports = function (RED) {
14
14
  this.registerOnIdentityChanged = function (callback) {
15
15
  identityChangedCallbacks.push(callback);
16
16
  };
17
-
18
17
  this.setIdentity = (identity) => {
19
18
  this.identity = identity;
20
19
 
@@ -32,7 +31,7 @@ module.exports = function (RED) {
32
31
  if (!client) {
33
32
  nodeContext.set('client', new engine_client.EngineClient(engineUrl));
34
33
  client = nodeContext.get('client');
35
- }
34
+ }
36
35
 
37
36
  return client;
38
37
  };
@@ -1,7 +1,4 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
3
-
4
- const engine_client = require('@5minds/processcube_engine_client');
1
+ const EventEmitter = require("node:events");
5
2
 
6
3
  module.exports = function (RED) {
7
4
  function ProcessdefinitionQuery(config) {
@@ -13,11 +10,11 @@ module.exports = function (RED) {
13
10
 
14
11
  const client = this.engine.getEngineClient();
15
12
 
16
- var eventEmitter = flowContext.get('emitter');
13
+ var eventEmitter = flowContext.get("emitter");
17
14
 
18
15
  if (!eventEmitter) {
19
- flowContext.set('emitter', new EventEmitter());
20
- eventEmitter = flowContext.get('emitter');
16
+ flowContext.set("emitter", new EventEmitter());
17
+ eventEmitter = flowContext.get("emitter");
21
18
  }
22
19
 
23
20
  node.on('close', async () => {
@@ -54,5 +51,6 @@ module.exports = function (RED) {
54
51
  });
55
52
  });
56
53
  }
54
+
57
55
  RED.nodes.registerType('processdefinition-query', ProcessdefinitionQuery);
58
56
  };
@@ -1,7 +1,4 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
3
-
4
- const engine_client = require('@5minds/processcube_engine_client');
1
+ const EventEmitter = require("node:events");
5
2
 
6
3
  module.exports = function (RED) {
7
4
  function ProcessinstanceQuery(config) {
@@ -13,11 +10,11 @@ module.exports = function (RED) {
13
10
 
14
11
  const client = this.engine.getEngineClient();
15
12
 
16
- var eventEmitter = flowContext.get('emitter');
13
+ var eventEmitter = flowContext.get("emitter");
17
14
 
18
15
  if (!eventEmitter) {
19
- flowContext.set('emitter', new EventEmitter());
20
- eventEmitter = flowContext.get('emitter');
16
+ flowContext.set("emitter", new EventEmitter());
17
+ eventEmitter = flowContext.get("emitter");
21
18
  }
22
19
 
23
20
  node.on('close', async () => {
@@ -40,5 +37,6 @@ module.exports = function (RED) {
40
37
  });
41
38
  });
42
39
  }
40
+
43
41
  RED.nodes.registerType('processinstance-query', ProcessinstanceQuery);
44
42
  };
@@ -1,6 +1,3 @@
1
- const process = require('process');
2
-
3
- const engine_client = require('@5minds/processcube_engine_client');
4
1
 
5
2
  module.exports = function (RED) {
6
3
  function SignalEventTrigger(config) {
@@ -22,16 +19,13 @@ module.exports = function (RED) {
22
19
  msg.payload = result;
23
20
 
24
21
  node.send(msg);
25
- node.status({
26
- fill: 'blue',
27
- shape: 'dot',
28
- text: `signal event triggered`,
29
- });
22
+ node.status({ fill: 'blue', shape: 'dot', text: `signal event triggered` });
30
23
  })
31
24
  .catch((error) => {
32
25
  node.error(error);
33
26
  });
34
27
  });
35
28
  }
29
+
36
30
  RED.nodes.registerType('signal-event-trigger', SignalEventTrigger);
37
31
  };
@@ -1,7 +1,4 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
3
-
4
- const engine_client = require('@5minds/processcube_engine_client');
1
+ const EventEmitter = require("node:events");
5
2
 
6
3
  module.exports = function (RED) {
7
4
  function UserTaskFinishedListener(config) {
@@ -13,11 +10,11 @@ module.exports = function (RED) {
13
10
 
14
11
  const client = this.engine.getEngineClient();
15
12
 
16
- var eventEmitter = flowContext.get('emitter');
13
+ var eventEmitter = flowContext.get("emitter");
17
14
 
18
15
  if (!eventEmitter) {
19
- flowContext.set('emitter', new EventEmitter());
20
- eventEmitter = flowContext.get('emitter');
16
+ flowContext.set("emitter", new EventEmitter());
17
+ eventEmitter = flowContext.get("emitter");
21
18
  }
22
19
 
23
20
  const register = async () => {
@@ -26,35 +23,43 @@ module.exports = function (RED) {
26
23
  (userTaskFinishedNotification) => {
27
24
  node.send({
28
25
  payload: {
29
- flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
30
- action: 'finished',
31
- type: 'usertask',
26
+ flowNodeInstanceId:
27
+ userTaskFinishedNotification.flowNodeInstanceId,
28
+ action: "finished",
29
+ type: "usertask",
32
30
  },
33
31
  });
34
32
  },
35
- { identity: currentIdentity },
33
+ { identity: currentIdentity }
36
34
  );
37
35
 
38
36
  node.server.registerOnIdentityChanged(async (identity) => {
39
- client.userTasks.removeSubscription(subscription, currentIdentity);
37
+ client.userTasks.removeSubscription(
38
+ subscription,
39
+ currentIdentity
40
+ );
40
41
  currentIdentity = identity;
41
42
 
42
43
  subscription = await client.userTasks.onUserTaskFinished(
43
44
  (userTaskFinishedNotification) => {
44
45
  node.send({
45
46
  payload: {
46
- flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
47
- action: 'finished',
48
- type: 'usertask',
47
+ flowNodeInstanceId:
48
+ userTaskFinishedNotification.flowNodeInstanceId,
49
+ action: "finished",
50
+ type: "usertask",
49
51
  },
50
52
  });
51
53
  },
52
- { identity: currentIdentity },
54
+ { identity: currentIdentity }
53
55
  );
54
56
  });
55
57
 
56
- node.on('close', async () => {
57
- client.userTasks.removeSubscription(subscription, currentIdentity);
58
+ node.on("close", async () => {
59
+ client.userTasks.removeSubscription(
60
+ subscription,
61
+ currentIdentity
62
+ );
58
63
  client.dispose();
59
64
  client = null;
60
65
  });
package/usertask-input.js CHANGED
@@ -1,40 +1,20 @@
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
- }
1
+ const EventEmitter = require("node:events");
21
2
 
22
3
  module.exports = function (RED) {
23
4
  function UserTaskInput(config) {
24
5
  RED.nodes.createNode(this, config);
25
6
  var node = this;
26
- var msgCounter = 0;
27
7
  var flowContext = node.context().flow;
28
8
 
29
9
  this.engine = this.server = RED.nodes.getNode(config.engine);
30
10
 
31
11
  const client = this.engine.getEngineClient();
32
12
 
33
- var eventEmitter = flowContext.get('emitter');
13
+ var eventEmitter = flowContext.get("emitter");
34
14
 
35
15
  if (!eventEmitter) {
36
- flowContext.set('emitter', new EventEmitter());
37
- eventEmitter = flowContext.get('emitter');
16
+ flowContext.set("emitter", new EventEmitter());
17
+ eventEmitter = flowContext.get("emitter");
38
18
  }
39
19
 
40
20
  node.on('close', async () => {
@@ -44,10 +24,12 @@ module.exports = function (RED) {
44
24
 
45
25
  node.on('input', function (msg) {
46
26
  let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
27
+
47
28
  query = {
48
29
  ...query,
49
30
  identity: node.server.identity,
50
31
  };
32
+
51
33
  client.userTasks.query(query).then((matchingFlowNodes) => {
52
34
  if (
53
35
  !config.force_send_array &&
@@ -61,21 +43,21 @@ module.exports = function (RED) {
61
43
  node.send(msg);
62
44
  } else {
63
45
  if (!config.force_send_array) {
64
- if (config.multisend && matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length > 1) {
46
+ if (
47
+ config.multisend &&
48
+ matchingFlowNodes.userTasks &&
49
+ matchingFlowNodes.userTasks.length > 1
50
+ ) {
65
51
  matchingFlowNodes.userTasks.forEach((userTask) => {
66
52
  msg.payload = { userTask: userTask };
67
53
  node.send(msg);
68
54
  });
69
55
  } else {
70
- msg.payload = {
71
- userTasks: matchingFlowNodes.userTasks,
72
- };
56
+ msg.payload = { userTasks: matchingFlowNodes.userTasks };
73
57
  node.send(msg);
74
58
  }
75
59
  } else {
76
- msg.payload = {
77
- userTasks: matchingFlowNodes.userTasks || [],
78
- };
60
+ msg.payload = { userTasks: matchingFlowNodes.userTasks || [] };
79
61
  node.send(msg);
80
62
  }
81
63
  }
@@ -1,7 +1,4 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
3
-
4
- const engine_client = require('@5minds/processcube_engine_client');
1
+ const EventEmitter = require("node:events");
5
2
 
6
3
  module.exports = function (RED) {
7
4
  function UserTaskNewListener(config) {
@@ -13,11 +10,11 @@ module.exports = function (RED) {
13
10
 
14
11
  const client = this.engine.getEngineClient();
15
12
 
16
- var eventEmitter = flowContext.get('emitter');
13
+ var eventEmitter = flowContext.get("emitter");
17
14
 
18
15
  if (!eventEmitter) {
19
- flowContext.set('emitter', new EventEmitter());
20
- eventEmitter = flowContext.get('emitter');
16
+ flowContext.set("emitter", new EventEmitter());
17
+ eventEmitter = flowContext.get("emitter");
21
18
  }
22
19
 
23
20
  const register = async () => {
@@ -1,7 +1,4 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
3
-
4
- const engine_client = require('@5minds/processcube_engine_client');
1
+ const EventEmitter = require("node:events");
5
2
 
6
3
  module.exports = function (RED) {
7
4
  function UserTaskOutput(config) {
@@ -14,11 +11,11 @@ module.exports = function (RED) {
14
11
 
15
12
  const client = this.engine.getEngineClient();
16
13
 
17
- var eventEmitter = flowContext.get('emitter');
14
+ var eventEmitter = flowContext.get("emitter");
18
15
 
19
16
  if (!eventEmitter) {
20
- flowContext.set('emitter', new EventEmitter());
21
- eventEmitter = flowContext.get('emitter');
17
+ flowContext.set("emitter", new EventEmitter());
18
+ eventEmitter = flowContext.get("emitter");
22
19
  }
23
20
 
24
21
  node.on('input', function (msg) {
@@ -36,7 +33,9 @@ module.exports = function (RED) {
36
33
  node.error(error);
37
34
  });
38
35
  } else {
39
- node.error(`No UserTask found in message: ${JSON.stringify(msg.payload)}`);
36
+ node.error(
37
+ `No UserTask found in message: ${JSON.stringify(msg.payload)}`
38
+ );
40
39
  }
41
40
  });
42
41
  }