@5minds/node-red-contrib-processcube 0.14.0-feature-ef048b-lyy1ngi6 → 0.14.0-feature-197b34-lyzwc8zw

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,7 @@ services:
5
5
  context: .
6
6
  ports:
7
7
  - "1880:1880"
8
+ - "9229:9229"
8
9
  environment:
9
10
  - TZ=Europe/Berlin
10
11
  - ENGINE_URL=http://engine:8000
@@ -26,6 +26,20 @@
26
26
  </div>
27
27
  </script>
28
28
 
29
- <script type="text/html" data-help-name="externaltask-error">
30
- <p>A node which error response to an External Task of https://processcube.io</p>
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*.
33
+
34
+ ## Inputs
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
40
+
41
+ ### References
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;
31
45
  </script>
@@ -16,15 +16,12 @@ module.exports = function(RED) {
16
16
  msgError.message = "An error occurred";
17
17
  }
18
18
 
19
+ const error = new Error(msgError.message);
20
+ error.errorCode = config.error;
21
+ error.errorDetails = RED.util.encodeObject(msg);
22
+
19
23
  msg.errorCode = config.error;
20
24
  msg.errorMessage = msgError.message;
21
- //msg.errorDetails = RED.util.encodeObject(msg); // circular structure
22
-
23
- const error = new Error(msg.errorMessage);
24
- error.errorCode = config.error;
25
-
26
- // TODO: hack cause https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
27
- error.stack = RED.util.encodeObject(msg);
28
25
 
29
26
  eventEmitter.emit(`handle-${flowNodeInstanceId}`, error, true);
30
27
 
@@ -31,6 +31,23 @@
31
31
  </div>
32
32
  </script>
33
33
 
34
- <script type="text/html" data-help-name="externaltask-input">
35
- <p>A node which subscribes to an External Task Topic of https://processcube.io</p>
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.
37
+
38
+ ## Outputs
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
43
+
44
+ ### Details
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.
48
+
49
+ ### References
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;
36
53
  </script>
@@ -117,8 +117,6 @@ module.exports = function(RED) {
117
117
  case 'processExternalTask':
118
118
  node.error(`Worker error ${errorType} for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}': ${error.message}`);
119
119
 
120
- externalTaskWorker.stop();
121
-
122
120
  if (externalTask) {
123
121
  delete started_external_tasks[externalTask.flowNodeInstanceId];
124
122
  }
@@ -141,11 +139,11 @@ module.exports = function(RED) {
141
139
  try {
142
140
  externalTaskWorker.stop();
143
141
  } catch {
144
- console.warn('Client close failed');
142
+ node.error('Client close failed');
145
143
  }
146
144
  });
147
145
  }
148
- ).error((error) => {
146
+ ).catch((error) => {
149
147
  node.error(`Error in subscribeToExternalTaskTopic: ${error.message}`);
150
148
  });
151
149
  }
@@ -21,6 +21,16 @@
21
21
  </div>
22
22
  </script>
23
23
 
24
- <script type="text/html" data-help-name="externaltask-output">
25
- <p>A node which response to an External Task of https://processcube.io</p>
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.
27
+
28
+ ## Inputs
29
+
30
+ : payload (Object) : Returned to the ProcessCube engine as the result of the external task
31
+
32
+ ### References
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;
26
36
  </script>
@@ -1,45 +1,37 @@
1
- const process = require('process');
1
+ const process = require("process");
2
2
 
3
- const engine_client = require('@5minds/processcube_engine_client');
3
+ const engine_client = require("@5minds/processcube_engine_client");
4
4
 
5
- module.exports = function(RED) {
5
+ module.exports = function (RED) {
6
6
  function MessageEventTrigger(config) {
7
7
  RED.nodes.createNode(this, config);
8
8
  var node = this;
9
- var nodeContext = node.context();
10
9
 
11
10
  this.engine = this.server = RED.nodes.getNode(config.engine);
12
11
 
13
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
-
15
- var client = nodeContext.get('client');
16
-
17
- if (!client) {
18
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
19
- client = nodeContext.get('client');
20
- }
21
-
22
- node.on('input', function(msg) {
23
-
24
- client.events.triggerMessageEvent(
25
- config.messagename,
26
- {
27
- processInstanceId: config.processinstanceid,
28
- payload: msg.payload,
29
- identity: node.server.identity
30
- }
31
-
32
- ).then((result) => {
33
-
34
- msg.payload = result;
35
-
36
- node.send(msg);
37
- node.status({fill: "blue", shape: "dot", text: `message event triggered`});
38
-
39
- }).catch((error) => {
40
- node.error(error);
41
- });
12
+ const client = this.engine.getEngineClient();
13
+
14
+ node.on("input", function (msg) {
15
+ client.events
16
+ .triggerMessageEvent(config.messagename, {
17
+ processInstanceId: config.processinstanceid,
18
+ payload: msg.payload,
19
+ identity: node.server.identity,
20
+ })
21
+ .then((result) => {
22
+ msg.payload = result;
23
+
24
+ node.send(msg);
25
+ node.status({
26
+ fill: "blue",
27
+ shape: "dot",
28
+ text: `message event triggered`,
29
+ });
30
+ })
31
+ .catch((error) => {
32
+ node.error(error);
33
+ });
42
34
  });
43
35
  }
44
36
  RED.nodes.registerType("message-event-trigger", MessageEventTrigger);
45
- }
37
+ };
@@ -1,4 +1,12 @@
1
1
  [
2
+ {
3
+ "id": "3f916448523ed12b",
4
+ "type": "tab",
5
+ "label": "Node-Inspector",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
2
10
  {
3
11
  "id": "a23d2e782beb66f4",
4
12
  "type": "tab",
@@ -130,11 +138,112 @@
130
138
  "w": 812,
131
139
  "h": 202
132
140
  },
141
+ {
142
+ "id": "dd43902998ad7630",
143
+ "type": "group",
144
+ "z": "3f916448523ed12b",
145
+ "style": {
146
+ "stroke": "#999999",
147
+ "stroke-opacity": "1",
148
+ "fill": "none",
149
+ "fill-opacity": "1",
150
+ "label": true,
151
+ "label-position": "nw",
152
+ "color": "#a4a4a4"
153
+ },
154
+ "nodes": [
155
+ "3add02d7.7df60e",
156
+ "8cf9f9cd.1a6a88",
157
+ "4b2a8ca1.de70e4",
158
+ "97dbbfedba44a728"
159
+ ],
160
+ "x": 34,
161
+ "y": 59,
162
+ "w": 712,
163
+ "h": 202
164
+ },
133
165
  {
134
166
  "id": "42e6796dddd9d4db",
135
167
  "type": "processcube-engine-config",
136
168
  "url": "http://engine:8000"
137
169
  },
170
+ {
171
+ "id": "3add02d7.7df60e",
172
+ "type": "node-inspector",
173
+ "z": "3f916448523ed12b",
174
+ "g": "dd43902998ad7630",
175
+ "inputField": "payload",
176
+ "host": "0.0.0.0",
177
+ "portNumber": 9229,
178
+ "autoStart": false,
179
+ "name": "",
180
+ "x": 400,
181
+ "y": 160,
182
+ "wires": []
183
+ },
184
+ {
185
+ "id": "8cf9f9cd.1a6a88",
186
+ "type": "inject",
187
+ "z": "3f916448523ed12b",
188
+ "g": "dd43902998ad7630",
189
+ "name": "",
190
+ "props": [
191
+ {
192
+ "p": "payload"
193
+ }
194
+ ],
195
+ "repeat": "",
196
+ "crontab": "",
197
+ "once": false,
198
+ "onceDelay": 0.1,
199
+ "topic": "",
200
+ "payload": "open_inspector",
201
+ "payloadType": "str",
202
+ "x": 160,
203
+ "y": 160,
204
+ "wires": [
205
+ [
206
+ "3add02d7.7df60e"
207
+ ]
208
+ ]
209
+ },
210
+ {
211
+ "id": "4b2a8ca1.de70e4",
212
+ "type": "inject",
213
+ "z": "3f916448523ed12b",
214
+ "g": "dd43902998ad7630",
215
+ "name": "",
216
+ "props": [
217
+ {
218
+ "p": "payload"
219
+ }
220
+ ],
221
+ "repeat": "",
222
+ "crontab": "",
223
+ "once": false,
224
+ "onceDelay": 0.1,
225
+ "topic": "",
226
+ "payload": "close_inspector",
227
+ "payloadType": "str",
228
+ "x": 160,
229
+ "y": 220,
230
+ "wires": [
231
+ [
232
+ "3add02d7.7df60e"
233
+ ]
234
+ ]
235
+ },
236
+ {
237
+ "id": "97dbbfedba44a728",
238
+ "type": "comment",
239
+ "z": "3f916448523ed12b",
240
+ "g": "dd43902998ad7630",
241
+ "name": "Start Node-Inspector on Port 9229 - be sure, that you expose the port from the docker-container",
242
+ "info": "",
243
+ "x": 390,
244
+ "y": 100,
245
+ "wires": []
246
+ },
138
247
  {
139
248
  "id": "2991a5e6df2b87d2",
140
249
  "type": "externaltask-input",
@@ -210,7 +319,7 @@
210
319
  "g": "31cb6729aac0ba46",
211
320
  "name": "",
212
321
  "pauseType": "delay",
213
- "timeout": "15",
322
+ "timeout": "5",
214
323
  "timeoutUnits": "seconds",
215
324
  "rate": "1",
216
325
  "nbRateUnits": "1",
@@ -221,7 +330,7 @@
221
330
  "drop": false,
222
331
  "allowrate": false,
223
332
  "outputs": 1,
224
- "x": 330,
333
+ "x": 320,
225
334
  "y": 360,
226
335
  "wires": [
227
336
  [
@@ -8,6 +8,7 @@
8
8
  "@5minds/node-red-dashboard-2-processcube-usertask-table": "^1.0.7",
9
9
  "@flowfuse/node-red-dashboard": "^1.11.1",
10
10
  "node-red": "^3.1.10",
11
+ "node-red-contrib-inspector": "~1.0.1",
11
12
  "node-red-debugger": "^1.1.1",
12
13
  "openapi-red": "^1.2.5"
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "0.14.0-feature-ef048b-lyy1ngi6",
3
+ "version": "0.14.0-feature-197b34-lyzwc8zw",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "authors": [
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@5minds/processcube_engine_client": "^5.0.0",
51
+ "@5minds/processcube_engine_client": "5.0.0-hotfix-d834af-lyymqumd",
52
52
  "jwt-decode": "^4.0.0",
53
53
  "openid-client": "^5.5.0"
54
54
  },
package/process-start.js CHANGED
@@ -1,43 +1,38 @@
1
- const process = require('process');
2
- const engine_client = require('@5minds/processcube_engine_client');
1
+ const process = require("process");
2
+ const engine_client = require("@5minds/processcube_engine_client");
3
3
 
4
- module.exports = function(RED) {
4
+ module.exports = function (RED) {
5
5
  function ProcessStart(config) {
6
- RED.nodes.createNode(this,config);
6
+ RED.nodes.createNode(this, config);
7
7
  var node = this;
8
- var flowContext = node.context().flow;
9
- var nodeContext = node.context();
10
8
 
11
9
  this.engine = this.server = RED.nodes.getNode(config.engine);
12
10
 
13
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
-
15
- var client = nodeContext.get('client');
16
-
17
- if (!client) {
18
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
19
- client = nodeContext.get('client');
20
- }
21
-
22
- node.on('input', function(msg) {
11
+ const client = this.engine.getEngineClient();
23
12
 
13
+ node.on("input", function (msg) {
24
14
  const startParameters = {
25
15
  processModelId: msg.processModelId || config.processmodel,
26
16
  startEventId: msg.startEventId || config.startevent,
27
- initialToken: msg.payload
17
+ initialToken: msg.payload,
28
18
  };
29
19
 
30
- client.processDefinitions.startProcessInstance(startParameters, node.engine.identity).then((result) => {
31
-
32
- msg.payload = result;
33
-
34
- node.send(msg);
35
- node.status({fill: "blue", shape: "dot", text: `started ${result.processInstanceId}`});
36
-
37
- }).catch((error) => {
38
- node.error(error);
39
- });
20
+ client.processDefinitions
21
+ .startProcessInstance(startParameters, node.engine.identity)
22
+ .then((result) => {
23
+ msg.payload = result;
24
+
25
+ node.send(msg);
26
+ node.status({
27
+ fill: "blue",
28
+ shape: "dot",
29
+ text: `started ${result.processInstanceId}`,
30
+ });
31
+ })
32
+ .catch((error) => {
33
+ node.error(error);
34
+ });
40
35
  });
41
36
  }
42
37
  RED.nodes.registerType("process-start", ProcessStart);
43
- }
38
+ };
@@ -1,31 +1,23 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
- module.exports = function(RED) {
6
+ module.exports = function (RED) {
7
7
  function ProcessdefinitionQuery(config) {
8
- RED.nodes.createNode(this,config);
8
+ RED.nodes.createNode(this, config);
9
9
  var node = this;
10
10
  var flowContext = node.context().flow;
11
- var nodeContext = node.context();
12
11
 
13
12
  this.engine = this.server = RED.nodes.getNode(config.engine);
14
13
 
15
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
+ const client = this.engine.getEngineClient();
16
15
 
17
- var client = nodeContext.get('client');
18
-
19
- if (!client) {
20
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
21
- client = nodeContext.get('client');
22
- }
23
-
24
- var eventEmitter = flowContext.get('emitter');
16
+ var eventEmitter = flowContext.get("emitter");
25
17
 
26
18
  if (!eventEmitter) {
27
- flowContext.set('emitter', new EventEmitter());
28
- eventEmitter = flowContext.get('emitter');
19
+ flowContext.set("emitter", new EventEmitter());
20
+ eventEmitter = flowContext.get("emitter");
29
21
  }
30
22
 
31
23
  node.on("close", async () => {
@@ -33,38 +25,48 @@ module.exports = function(RED) {
33
25
  client = null;
34
26
  });
35
27
 
36
- node.on('input', function(msg) {
37
- let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
28
+ node.on("input", function (msg) {
29
+ let query = RED.util.evaluateNodeProperty(
30
+ config.query,
31
+ config.query_type,
32
+ node,
33
+ msg
34
+ );
38
35
  query = {
39
36
  ...query,
40
- identity: node.server.identity
37
+ identity: node.server.identity,
41
38
  };
42
-
43
- client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
44
-
45
-
46
- if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
47
- let models = [];
48
-
49
- matchingProcessDefinitions.processDefinitions.forEach(processDefinition => {
50
- processDefinition.processModels.forEach(model => {
51
- models.push(model);
52
- });
53
- });
54
-
55
- msg.payload = {
56
- models: models,
57
- totalCount: models.length
58
- };
59
-
60
- } else {
61
- msg.payload = matchingProcessDefinitions;
62
- }
63
-
64
39
 
65
- node.send(msg);
66
- });
40
+ client.processDefinitions
41
+ .getAll(query)
42
+ .then((matchingProcessDefinitions) => {
43
+ if (
44
+ config.models_only &&
45
+ matchingProcessDefinitions.totalCount > 0
46
+ ) {
47
+ let models = [];
48
+
49
+ matchingProcessDefinitions.processDefinitions.forEach(
50
+ (processDefinition) => {
51
+ processDefinition.processModels.forEach(
52
+ (model) => {
53
+ models.push(model);
54
+ }
55
+ );
56
+ }
57
+ );
58
+
59
+ msg.payload = {
60
+ models: models,
61
+ totalCount: models.length,
62
+ };
63
+ } else {
64
+ msg.payload = matchingProcessDefinitions;
65
+ }
66
+
67
+ node.send(msg);
68
+ });
67
69
  });
68
70
  }
69
71
  RED.nodes.registerType("processdefinition-query", ProcessdefinitionQuery);
70
- }
72
+ };
@@ -35,7 +35,7 @@
35
35
  <bpmn:errorEventDefinition id="ErrorEventDefinition_1lr8fha" errorRef="Error_3O8wBFQi" />
36
36
  </bpmn:boundaryEvent>
37
37
  </bpmn:process>
38
- <bpmn:error id="Error_3O8wBFQi" errorCode="ExternalTaskWorkerError" />
38
+ <bpmn:error id="Error_3O8wBFQi" errorCode="MyErrorCode" />
39
39
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
40
40
  <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1cidyxu">
41
41
  <bpmndi:BPMNShape id="Participant_0px403d_di" bpmnElement="Participant_0px403d" isHorizontal="true">
@@ -81,14 +81,14 @@
81
81
  <di:waypoint x="410" y="290" />
82
82
  <di:waypoint x="482" y="290" />
83
83
  </bpmndi:BPMNEdge>
84
- <bpmndi:BPMNEdge id="Association_0ivfgz1_di" bpmnElement="Association_0ivfgz1">
85
- <di:waypoint x="401" y="130" />
86
- <di:waypoint x="413" y="90" />
87
- </bpmndi:BPMNEdge>
88
84
  <bpmndi:BPMNShape id="TextAnnotation_0lbjt7p_di" bpmnElement="TextAnnotation_0lbjt7p">
89
85
  <dc:Bounds x="370" y="50" width="169.99387960829492" height="39.99855990783411" />
90
86
  <bpmndi:BPMNLabel />
91
87
  </bpmndi:BPMNShape>
88
+ <bpmndi:BPMNEdge id="Association_0ivfgz1_di" bpmnElement="Association_0ivfgz1">
89
+ <di:waypoint x="401" y="130" />
90
+ <di:waypoint x="413" y="90" />
91
+ </bpmndi:BPMNEdge>
92
92
  </bpmndi:BPMNPlane>
93
93
  </bpmndi:BPMNDiagram>
94
94
  </bpmn:definitions>
@@ -1,31 +1,23 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
- module.exports = function(RED) {
6
+ module.exports = function (RED) {
7
7
  function ProcessinstanceQuery(config) {
8
- RED.nodes.createNode(this,config);
8
+ RED.nodes.createNode(this, config);
9
9
  var node = this;
10
10
  var flowContext = node.context().flow;
11
- var nodeContext = node.context();
12
11
 
13
12
  this.engine = this.server = RED.nodes.getNode(config.engine);
14
13
 
15
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
+ const client = this.engine.getEngineClient();
16
15
 
17
- var client = nodeContext.get('client');
18
-
19
- if (!client) {
20
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
21
- client = nodeContext.get('client');
22
- }
23
-
24
- var eventEmitter = flowContext.get('emitter');
16
+ var eventEmitter = flowContext.get("emitter");
25
17
 
26
18
  if (!eventEmitter) {
27
- flowContext.set('emitter', new EventEmitter());
28
- eventEmitter = flowContext.get('emitter');
19
+ flowContext.set("emitter", new EventEmitter());
20
+ eventEmitter = flowContext.get("emitter");
29
21
  }
30
22
 
31
23
  node.on("close", async () => {
@@ -33,16 +25,22 @@ module.exports = function(RED) {
33
25
  client = null;
34
26
  });
35
27
 
36
- node.on('input', function(msg) {
37
- let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
38
-
39
- client.processInstances.query(query, { identity: node.server.identity }).then((matchingInstances) => {
40
-
41
- msg.payload = matchingInstances;
42
-
43
- node.send(msg);
44
- });
28
+ node.on("input", function (msg) {
29
+ let query = RED.util.evaluateNodeProperty(
30
+ config.query,
31
+ config.query_type,
32
+ node,
33
+ msg
34
+ );
35
+
36
+ client.processInstances
37
+ .query(query, { identity: node.server.identity })
38
+ .then((matchingInstances) => {
39
+ msg.payload = matchingInstances;
40
+
41
+ node.send(msg);
42
+ });
45
43
  });
46
44
  }
47
45
  RED.nodes.registerType("processinstance-query", ProcessinstanceQuery);
48
- }
46
+ };
@@ -1,45 +1,37 @@
1
- const process = require('process');
1
+ const process = require("process");
2
2
 
3
- const engine_client = require('@5minds/processcube_engine_client');
3
+ const engine_client = require("@5minds/processcube_engine_client");
4
4
 
5
- module.exports = function(RED) {
5
+ module.exports = function (RED) {
6
6
  function SignalEventTrigger(config) {
7
7
  RED.nodes.createNode(this, config);
8
8
  var node = this;
9
- var nodeContext = node.context();
10
9
 
11
10
  this.engine = this.server = RED.nodes.getNode(config.engine);
12
11
 
13
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
-
15
- var client = nodeContext.get('client');
16
-
17
- if (!client) {
18
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
19
- client = nodeContext.get('client');
20
- }
21
-
22
- node.on('input', function(msg) {
23
-
24
- client.events.triggerSignalEvent(
25
- config.signalname,
26
- {
27
- processInstanceId: config.processinstanceid,
28
- payload: msg.payload,
29
- identity: node.server.identity
30
- }
31
-
32
- ).then((result) => {
33
-
34
- msg.payload = result;
35
-
36
- node.send(msg);
37
- node.status({fill: "blue", shape: "dot", text: `signal event triggered`});
38
-
39
- }).catch((error) => {
40
- node.error(error);
41
- });
12
+ const client = this.engine.getEngineClient();
13
+
14
+ node.on("input", function (msg) {
15
+ client.events
16
+ .triggerSignalEvent(config.signalname, {
17
+ processInstanceId: config.processinstanceid,
18
+ payload: msg.payload,
19
+ identity: node.server.identity,
20
+ })
21
+ .then((result) => {
22
+ msg.payload = result;
23
+
24
+ node.send(msg);
25
+ node.status({
26
+ fill: "blue",
27
+ shape: "dot",
28
+ text: `signal event triggered`,
29
+ });
30
+ })
31
+ .catch((error) => {
32
+ node.error(error);
33
+ });
42
34
  });
43
35
  }
44
36
  RED.nodes.registerType("signal-event-trigger", SignalEventTrigger);
45
- }
37
+ };
@@ -1,58 +1,79 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
- module.exports = function(RED) {
6
+ module.exports = function (RED) {
7
7
  function UserTaskFinishedListener(config) {
8
8
  RED.nodes.createNode(this, config);
9
9
  var node = this;
10
10
  var flowContext = node.context().flow;
11
- var nodeContext = node.context();
12
11
 
13
12
  this.engine = this.server = RED.nodes.getNode(config.engine);
14
13
 
15
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
+ const client = this.engine.getEngineClient();
16
15
 
17
- var client = nodeContext.get('client');
18
-
19
- if (!client) {
20
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
21
- client = nodeContext.get('client');
22
- }
23
-
24
- var eventEmitter = flowContext.get('emitter');
16
+ var eventEmitter = flowContext.get("emitter");
25
17
 
26
18
  if (!eventEmitter) {
27
- flowContext.set('emitter', new EventEmitter());
28
- eventEmitter = flowContext.get('emitter');
19
+ flowContext.set("emitter", new EventEmitter());
20
+ eventEmitter = flowContext.get("emitter");
29
21
  }
30
22
 
31
23
  const register = async () => {
32
24
  let currentIdentity = node.server.identity;
33
- let subscription = await client.userTasks.onUserTaskFinished((userTaskFinishedNotification) => {
34
- node.send({ payload: { flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId, action: "finished", type: "usertask" } });
35
- }, { identity: currentIdentity });
36
-
37
- node.server.registerOnIdentityChanged(async (identity) => {
38
- client.userTasks.removeSubscription(subscription, currentIdentity);
25
+ let subscription = await client.userTasks.onUserTaskFinished(
26
+ (userTaskFinishedNotification) => {
27
+ node.send({
28
+ payload: {
29
+ flowNodeInstanceId:
30
+ userTaskFinishedNotification.flowNodeInstanceId,
31
+ action: "finished",
32
+ type: "usertask",
33
+ },
34
+ });
35
+ },
36
+ { identity: currentIdentity }
37
+ );
38
+
39
+ node.server.registerOnIdentityChanged(async (identity) => {
40
+ client.userTasks.removeSubscription(
41
+ subscription,
42
+ currentIdentity
43
+ );
39
44
  currentIdentity = identity;
40
-
41
- subscription = await client.userTasks.onUserTaskFinished((userTaskFinishedNotification) => {
42
- node.send({ payload: { flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId, action: "finished", type: "usertask" } });
43
- }, { identity: currentIdentity });
45
+
46
+ subscription = await client.userTasks.onUserTaskFinished(
47
+ (userTaskFinishedNotification) => {
48
+ node.send({
49
+ payload: {
50
+ flowNodeInstanceId:
51
+ userTaskFinishedNotification.flowNodeInstanceId,
52
+ action: "finished",
53
+ type: "usertask",
54
+ },
55
+ });
56
+ },
57
+ { identity: currentIdentity }
58
+ );
44
59
  });
45
-
60
+
46
61
  node.on("close", async () => {
47
- client.userTasks.removeSubscription(subscription, currentIdentity);
62
+ client.userTasks.removeSubscription(
63
+ subscription,
64
+ currentIdentity
65
+ );
48
66
  client.dispose();
49
67
  client = null;
50
68
  });
51
- }
69
+ };
52
70
 
53
71
  if (node.server) {
54
72
  register();
55
73
  }
56
74
  }
57
- RED.nodes.registerType("usertask-finished-listener", UserTaskFinishedListener);
58
- }
75
+ RED.nodes.registerType(
76
+ "usertask-finished-listener",
77
+ UserTaskFinishedListener
78
+ );
79
+ };
package/usertask-input.js CHANGED
@@ -1,40 +1,40 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
6
  function showStatus(node, msgCounter) {
7
7
  if (msgCounter >= 1) {
8
- node.status({fill: "blue", shape: "dot", text: `handling tasks ${msgCounter}`});
8
+ node.status({
9
+ fill: "blue",
10
+ shape: "dot",
11
+ text: `handling tasks ${msgCounter}`,
12
+ });
9
13
  } else {
10
- node.status({fill: "blue", shape: "ring", text: `subcribed ${msgCounter}`});
14
+ node.status({
15
+ fill: "blue",
16
+ shape: "ring",
17
+ text: `subcribed ${msgCounter}`,
18
+ });
11
19
  }
12
20
  }
13
21
 
14
- module.exports = function(RED) {
22
+ module.exports = function (RED) {
15
23
  function UserTaskInput(config) {
16
- RED.nodes.createNode(this,config);
24
+ RED.nodes.createNode(this, config);
17
25
  var node = this;
18
26
  var msgCounter = 0;
19
27
  var flowContext = node.context().flow;
20
- var nodeContext = node.context();
21
28
 
22
29
  this.engine = this.server = RED.nodes.getNode(config.engine);
23
30
 
24
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
25
-
26
- var client = nodeContext.get('client');
27
-
28
- if (!client) {
29
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
30
- client = nodeContext.get('client');
31
- }
31
+ const client = this.engine.getEngineClient();
32
32
 
33
- var eventEmitter = flowContext.get('emitter');
33
+ var eventEmitter = flowContext.get("emitter");
34
34
 
35
35
  if (!eventEmitter) {
36
- flowContext.set('emitter', new EventEmitter());
37
- eventEmitter = flowContext.get('emitter');
36
+ flowContext.set("emitter", new EventEmitter());
37
+ eventEmitter = flowContext.get("emitter");
38
38
  }
39
39
 
40
40
  node.on("close", async () => {
@@ -42,40 +42,54 @@ module.exports = function(RED) {
42
42
  client = null;
43
43
  });
44
44
 
45
- node.on('input', function(msg) {
46
- let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
45
+ node.on("input", function (msg) {
46
+ let query = RED.util.evaluateNodeProperty(
47
+ config.query,
48
+ config.query_type,
49
+ node,
50
+ msg
51
+ );
47
52
  query = {
48
53
  ...query,
49
- identity: node.server.identity
50
- }
54
+ identity: node.server.identity,
55
+ };
51
56
  client.userTasks.query(query).then((matchingFlowNodes) => {
52
-
53
- if (!config.force_send_array && matchingFlowNodes && matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
57
+ if (
58
+ !config.force_send_array &&
59
+ matchingFlowNodes &&
60
+ matchingFlowNodes.userTasks &&
61
+ matchingFlowNodes.userTasks.length == 1
62
+ ) {
54
63
  userTask = matchingFlowNodes.userTasks[0];
55
64
 
56
65
  msg.payload = { userTask: userTask };
57
66
  node.send(msg);
58
67
  } else {
59
68
  if (!config.force_send_array) {
60
- if (config.multisend && matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length > 1) {
69
+ if (
70
+ config.multisend &&
71
+ matchingFlowNodes.userTasks &&
72
+ matchingFlowNodes.userTasks.length > 1
73
+ ) {
61
74
  matchingFlowNodes.userTasks.forEach((userTask) => {
62
-
63
- msg.payload = { userTask: userTask } ;
75
+ msg.payload = { userTask: userTask };
64
76
  node.send(msg);
65
77
  });
66
78
  } else {
67
-
68
- msg.payload = { userTasks: matchingFlowNodes.userTasks };
79
+ msg.payload = {
80
+ userTasks: matchingFlowNodes.userTasks,
81
+ };
69
82
  node.send(msg);
70
83
  }
71
84
  } else {
72
-
73
- msg.payload = { userTasks: matchingFlowNodes.userTasks || [] };
85
+ msg.payload = {
86
+ userTasks: matchingFlowNodes.userTasks || [],
87
+ };
74
88
  node.send(msg);
75
89
  }
76
- }
90
+ }
77
91
  });
78
92
  });
79
93
  }
80
94
  RED.nodes.registerType("usertask-input", UserTaskInput);
81
- }
95
+ };
@@ -1,59 +1,76 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
- module.exports = function(RED) {
6
+ module.exports = function (RED) {
7
7
  function UserTaskNewListener(config) {
8
8
  RED.nodes.createNode(this, config);
9
9
  var node = this;
10
10
  var flowContext = node.context().flow;
11
- var nodeContext = node.context();
12
11
 
13
12
  this.engine = this.server = RED.nodes.getNode(config.engine);
14
13
 
15
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
+ const client = this.engine.getEngineClient();
16
15
 
17
- var client = nodeContext.get('client');
18
-
19
- if (!client) {
20
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
21
- client = nodeContext.get('client');
22
- }
23
-
24
- var eventEmitter = flowContext.get('emitter');
16
+ var eventEmitter = flowContext.get("emitter");
25
17
 
26
18
  if (!eventEmitter) {
27
- flowContext.set('emitter', new EventEmitter());
28
- eventEmitter = flowContext.get('emitter');
19
+ flowContext.set("emitter", new EventEmitter());
20
+ eventEmitter = flowContext.get("emitter");
29
21
  }
30
-
22
+
31
23
  const register = async () => {
32
24
  let currentIdentity = node.server.identity;
33
- let subscription = await client.userTasks.onUserTaskWaiting((userTaskWaitingNotification) => {
34
- node.send({ payload: { flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId, action: "new", type: "usertask" } });
35
- }, { identity: currentIdentity });
36
-
37
- node.server.registerOnIdentityChanged(async (identity) => {
38
- client.userTasks.removeSubscription(subscription, currentIdentity);
25
+ let subscription = await client.userTasks.onUserTaskWaiting(
26
+ (userTaskWaitingNotification) => {
27
+ node.send({
28
+ payload: {
29
+ flowNodeInstanceId:
30
+ userTaskWaitingNotification.flowNodeInstanceId,
31
+ action: "new",
32
+ type: "usertask",
33
+ },
34
+ });
35
+ },
36
+ { identity: currentIdentity }
37
+ );
38
+
39
+ node.server.registerOnIdentityChanged(async (identity) => {
40
+ client.userTasks.removeSubscription(
41
+ subscription,
42
+ currentIdentity
43
+ );
39
44
  currentIdentity = identity;
40
-
41
- subscription = await client.userTasks.onUserTaskWaiting((userTaskWaitingNotification) => {
42
- node.send({ payload: { flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId, action: "new", type: "usertask" } });
43
- }, { identity: currentIdentity });
45
+
46
+ subscription = await client.userTasks.onUserTaskWaiting(
47
+ (userTaskWaitingNotification) => {
48
+ node.send({
49
+ payload: {
50
+ flowNodeInstanceId:
51
+ userTaskWaitingNotification.flowNodeInstanceId,
52
+ action: "new",
53
+ type: "usertask",
54
+ },
55
+ });
56
+ },
57
+ { identity: currentIdentity }
58
+ );
44
59
  });
45
-
60
+
46
61
  node.on("close", async () => {
47
- client.userTasks.removeSubscription(subscription, currentIdentity);
62
+ client.userTasks.removeSubscription(
63
+ subscription,
64
+ currentIdentity
65
+ );
48
66
  client.dispose();
49
67
  client = null;
50
68
  });
51
- }
69
+ };
52
70
 
53
71
  if (node.server) {
54
72
  register();
55
73
  }
56
-
57
74
  }
58
75
  RED.nodes.registerType("usertask-new-listener", UserTaskNewListener);
59
- }
76
+ };
@@ -1,53 +1,57 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
- module.exports = function(RED) {
6
+ module.exports = function (RED) {
7
7
  function UserTaskOutput(config) {
8
-
9
8
  RED.nodes.createNode(this, config);
10
9
 
11
10
  var node = this;
12
11
  var flowContext = node.context().flow;
13
- var nodeContext = node.context();
14
12
 
15
13
  this.engine = this.server = RED.nodes.getNode(config.engine);
16
14
 
17
- const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
18
-
19
- var client = nodeContext.get('client');
20
-
21
- if (!client) {
22
- nodeContext.set('client', new engine_client.EngineClient(engineUrl));
23
- client = nodeContext.get('client');
24
- }
15
+ const client = this.engine.getEngineClient();
25
16
 
26
- var eventEmitter = flowContext.get('emitter');
17
+ var eventEmitter = flowContext.get("emitter");
27
18
 
28
19
  if (!eventEmitter) {
29
- flowContext.set('emitter', new EventEmitter());
30
- eventEmitter = flowContext.get('emitter');
20
+ flowContext.set("emitter", new EventEmitter());
21
+ eventEmitter = flowContext.get("emitter");
31
22
  }
32
23
 
33
- node.on('input', function(msg) {
24
+ node.on("input", function (msg) {
34
25
  if (msg.payload.userTask) {
35
-
36
- const flowNodeInstanceId = msg.payload.userTask.flowNodeInstanceId;
37
-
38
- const userTaskResult = RED.util.evaluateNodeProperty(config.result, config.result_type, node, msg);
39
-
40
- client.userTasks.finishUserTask(flowNodeInstanceId, userTaskResult, node.server.identity).then(() => {
41
-
42
- node.send(msg);
43
- }).catch(error => {
44
- node.error(error);
45
- });
26
+ const flowNodeInstanceId =
27
+ msg.payload.userTask.flowNodeInstanceId;
28
+
29
+ const userTaskResult = RED.util.evaluateNodeProperty(
30
+ config.result,
31
+ config.result_type,
32
+ node,
33
+ msg
34
+ );
35
+
36
+ client.userTasks
37
+ .finishUserTask(
38
+ flowNodeInstanceId,
39
+ userTaskResult,
40
+ node.server.identity
41
+ )
42
+ .then(() => {
43
+ node.send(msg);
44
+ })
45
+ .catch((error) => {
46
+ node.error(error);
47
+ });
46
48
  } else {
47
- node.error(`No UserTask found in message: ${JSON.stringify(msg.payload)}`);
49
+ node.error(
50
+ `No UserTask found in message: ${JSON.stringify(msg.payload)}`
51
+ );
48
52
  }
49
53
  });
50
54
  }
51
55
 
52
56
  RED.nodes.registerType("usertask-output", UserTaskOutput);
53
- }
57
+ };