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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/Dockerfile +2 -0
  2. package/endevent-finished-listener.html +50 -0
  3. package/endevent-finished-listener.js +52 -0
  4. package/examples/Definition-Query-Sample.json +215 -0
  5. package/examples/External-Task-Sample.json +142 -1
  6. package/examples/Instance-Query-Sample.json +110 -0
  7. package/examples/User-Task-Sample.json +231 -0
  8. package/externaltask-error.html +8 -8
  9. package/externaltask-error.js +2 -2
  10. package/externaltask-input.html +7 -7
  11. package/externaltask-input.js +112 -98
  12. package/externaltask-output.html +3 -3
  13. package/externaltask-output.js +4 -5
  14. package/message-event-trigger.html +14 -2
  15. package/message-event-trigger.js +10 -5
  16. package/nodered/node-red-contrib-processcube-flows.json +364 -20
  17. package/nodered/settings.js +2 -1
  18. package/nodered/static/ProcessCube_Logo.svg +53 -0
  19. package/package.json +3 -5
  20. package/process-start.html +16 -13
  21. package/process-start.js +18 -6
  22. package/processcube-engine-config.html +16 -0
  23. package/processcube-engine-config.js +11 -14
  24. package/processdefinition-query.html +16 -2
  25. package/processdefinition-query.js +10 -19
  26. package/processes/User-Task-Sample.bpmn +57 -0
  27. package/processinstance-query.html +13 -2
  28. package/processinstance-query.js +9 -21
  29. package/signal-event-trigger.html +14 -2
  30. package/signal-event-trigger.js +14 -7
  31. package/usertask-finished-listener.html +15 -14
  32. package/usertask-finished-listener.js +26 -37
  33. package/usertask-input.html +15 -2
  34. package/usertask-input.js +20 -25
  35. package/usertask-new-listener.html +15 -14
  36. package/usertask-new-listener.js +18 -21
  37. package/usertask-output.html +13 -2
  38. package/usertask-output.js +11 -19
  39. package/processes/GetProcessModels.bpmn +0 -58
  40. package/processes/HelloWorld.bpmn +0 -124
@@ -0,0 +1,231 @@
1
+ [
2
+ {
3
+ "id": "fd3c725340de4f74",
4
+ "type": "tab",
5
+ "label": "UserTasks",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "887f3fb69ad1d1fb",
12
+ "type": "group",
13
+ "z": "fd3c725340de4f74",
14
+ "style": {
15
+ "stroke": "#999999",
16
+ "stroke-opacity": "1",
17
+ "fill": "none",
18
+ "fill-opacity": "1",
19
+ "label": true,
20
+ "label-position": "nw",
21
+ "color": "#a4a4a4"
22
+ },
23
+ "nodes": [
24
+ "f7a9604a17188737",
25
+ "020d34cd4ab43900",
26
+ "1db0ae57c1b8486b",
27
+ "127bc6e092c5724e"
28
+ ],
29
+ "x": 34,
30
+ "y": 19,
31
+ "w": 452,
32
+ "h": 202
33
+ },
34
+ {
35
+ "id": "72d3db13edc2486b",
36
+ "type": "group",
37
+ "z": "fd3c725340de4f74",
38
+ "style": {
39
+ "stroke": "#999999",
40
+ "stroke-opacity": "1",
41
+ "fill": "none",
42
+ "fill-opacity": "1",
43
+ "label": true,
44
+ "label-position": "nw",
45
+ "color": "#a4a4a4"
46
+ },
47
+ "nodes": [
48
+ "ae0583e83c762956",
49
+ "f7c7682e3a6adaaa",
50
+ "a2fb6369b16c12fa",
51
+ "8ef39e83173d41e3",
52
+ "f524b8cc35d56849",
53
+ "9fb4017c1d0ac7c9"
54
+ ],
55
+ "x": 34,
56
+ "y": 259,
57
+ "w": 652,
58
+ "h": 262
59
+ },
60
+ {
61
+ "id": "f7a9604a17188737",
62
+ "type": "usertask-new-listener",
63
+ "z": "fd3c725340de4f74",
64
+ "d": true,
65
+ "g": "887f3fb69ad1d1fb",
66
+ "name": "New User Task",
67
+ "engine": "42e6796dddd9d4db",
68
+ "multisend": false,
69
+ "x": 160,
70
+ "y": 120,
71
+ "wires": [
72
+ [
73
+ "020d34cd4ab43900"
74
+ ]
75
+ ]
76
+ },
77
+ {
78
+ "id": "020d34cd4ab43900",
79
+ "type": "debug",
80
+ "z": "fd3c725340de4f74",
81
+ "g": "887f3fb69ad1d1fb",
82
+ "name": "Show User Task",
83
+ "active": true,
84
+ "tosidebar": true,
85
+ "console": false,
86
+ "tostatus": false,
87
+ "complete": "payload",
88
+ "targetType": "msg",
89
+ "statusVal": "",
90
+ "statusType": "auto",
91
+ "x": 360,
92
+ "y": 120,
93
+ "wires": []
94
+ },
95
+ {
96
+ "id": "1db0ae57c1b8486b",
97
+ "type": "usertask-finished-listener",
98
+ "z": "fd3c725340de4f74",
99
+ "g": "887f3fb69ad1d1fb",
100
+ "name": "Finished User Task",
101
+ "engine": "42e6796dddd9d4db",
102
+ "multisend": false,
103
+ "x": 150,
104
+ "y": 180,
105
+ "wires": [
106
+ [
107
+ "020d34cd4ab43900"
108
+ ]
109
+ ]
110
+ },
111
+ {
112
+ "id": "127bc6e092c5724e",
113
+ "type": "comment",
114
+ "z": "fd3c725340de4f74",
115
+ "g": "887f3fb69ad1d1fb",
116
+ "name": "User Task Events",
117
+ "info": "",
118
+ "x": 140,
119
+ "y": 60,
120
+ "wires": []
121
+ },
122
+ {
123
+ "id": "ae0583e83c762956",
124
+ "type": "usertask-new-listener",
125
+ "z": "fd3c725340de4f74",
126
+ "d": true,
127
+ "g": "72d3db13edc2486b",
128
+ "name": "",
129
+ "engine": "42e6796dddd9d4db",
130
+ "multisend": true,
131
+ "x": 160,
132
+ "y": 360,
133
+ "wires": [
134
+ [
135
+ "a2fb6369b16c12fa"
136
+ ]
137
+ ]
138
+ },
139
+ {
140
+ "id": "f7c7682e3a6adaaa",
141
+ "type": "usertask-input",
142
+ "z": "fd3c725340de4f74",
143
+ "g": "72d3db13edc2486b",
144
+ "name": "",
145
+ "engine": "42e6796dddd9d4db",
146
+ "query": "payload",
147
+ "query_type": "msg",
148
+ "force_send_array": false,
149
+ "multisend": false,
150
+ "x": 380,
151
+ "y": 420,
152
+ "wires": [
153
+ [
154
+ "8ef39e83173d41e3"
155
+ ]
156
+ ]
157
+ },
158
+ {
159
+ "id": "a2fb6369b16c12fa",
160
+ "type": "function",
161
+ "z": "fd3c725340de4f74",
162
+ "g": "72d3db13edc2486b",
163
+ "name": "query",
164
+ "func": "msg.payload = {\n flowNodeInstanceId: msg.payload.flowNodeInstanceId,\n flowNodeId: \"user_task\"\n};\n\nreturn msg;",
165
+ "outputs": 1,
166
+ "timeout": 0,
167
+ "noerr": 0,
168
+ "initialize": "",
169
+ "finalize": "",
170
+ "libs": [],
171
+ "x": 210,
172
+ "y": 420,
173
+ "wires": [
174
+ [
175
+ "f7c7682e3a6adaaa"
176
+ ]
177
+ ]
178
+ },
179
+ {
180
+ "id": "8ef39e83173d41e3",
181
+ "type": "function",
182
+ "z": "fd3c725340de4f74",
183
+ "g": "72d3db13edc2486b",
184
+ "name": "build result",
185
+ "func": "msg.payload.result = {\n \"field_01\": \"value 01\",\n \"field_02\": \"value 02\"\n}\nreturn msg;",
186
+ "outputs": 1,
187
+ "timeout": 0,
188
+ "noerr": 0,
189
+ "initialize": "",
190
+ "finalize": "",
191
+ "libs": [],
192
+ "x": 390,
193
+ "y": 480,
194
+ "wires": [
195
+ [
196
+ "f524b8cc35d56849"
197
+ ]
198
+ ]
199
+ },
200
+ {
201
+ "id": "f524b8cc35d56849",
202
+ "type": "usertask-output",
203
+ "z": "fd3c725340de4f74",
204
+ "g": "72d3db13edc2486b",
205
+ "name": "",
206
+ "engine": "42e6796dddd9d4db",
207
+ "result": "payload.result",
208
+ "result_type": "msg",
209
+ "x": 580,
210
+ "y": 480,
211
+ "wires": [
212
+ []
213
+ ]
214
+ },
215
+ {
216
+ "id": "9fb4017c1d0ac7c9",
217
+ "type": "comment",
218
+ "z": "fd3c725340de4f74",
219
+ "g": "72d3db13edc2486b",
220
+ "name": "Demo to listen on a new usertask an finish them",
221
+ "info": "",
222
+ "x": 240,
223
+ "y": 300,
224
+ "wires": []
225
+ },
226
+ {
227
+ "id": "42e6796dddd9d4db",
228
+ "type": "processcube-engine-config",
229
+ "url": "http://engine:8000"
230
+ }
231
+ ]
@@ -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
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
36
+ : msg (Object) : Passed as `ErrorDetails` to the engine
37
+ : Error (string) : From the configuration
38
+ : Message (string) : The caught exception message
39
39
  : StackTrace (string) : The stack trace of the exception
40
40
 
41
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
35
+ Waiting for external tasks that correspond to the `Topic` configured in
36
36
  the connected ProcessCube Engine for processing.
37
37
 
38
38
  ## Outputs
39
39
 
40
- : payload (string) : Defines the input of the external task token
41
- : task (object) : The external task object
40
+ : payload (string) : Defines the input of the external task token
41
+ : task (object) : The external task object
42
42
  : flowNodeInstanceId : The Id of the external task, which is needed to complete the task
43
43
 
44
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
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
 
@@ -16,9 +16,14 @@ module.exports = function (RED) {
16
16
  var node = this;
17
17
  var flowContext = node.context().flow;
18
18
 
19
- this.engine = this.server = RED.nodes.getNode(config.engine);
19
+ const engine = RED.nodes.getNode(config.engine);
20
20
 
21
- const client = this.engine.getEngineClient();
21
+ const client = engine.engineClient;
22
+
23
+ if (!client) {
24
+ node.error('No engine configured.');
25
+ return;
26
+ }
22
27
 
23
28
  var eventEmitter = flowContext.get('emitter');
24
29
 
@@ -27,121 +32,130 @@ module.exports = function (RED) {
27
32
  eventEmitter = flowContext.get('emitter');
28
33
  }
29
34
 
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];
35
+ client.externalTasks
36
+ .subscribeToExternalTaskTopic(config.topic, async (payload, externalTask) => {
37
+ const saveHandleCallback = (data, callback) => {
38
+ try {
39
+ callback(data);
40
+ } catch (error) {
41
+ node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
49
42
  }
50
-
51
- showStatus(node, Object.keys(started_external_tasks).length);
52
-
53
-
54
- //resolve(result);
55
- saveHandleCallback(result, resolve)
56
43
  };
57
44
 
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}'.`);
45
+ return await new Promise((resolve, reject) => {
46
+ const handleFinishTask = (msg) => {
47
+ let result = RED.util.encodeObject(msg.payload);
61
48
 
62
- if (externalTask.flowNodeInstanceId) {
63
- delete started_external_tasks[externalTask.flowNodeInstanceId];
64
- }
65
-
66
- showStatus(node, Object.keys(started_external_tasks).length);
49
+ node.log(
50
+ `handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`,
51
+ );
67
52
 
53
+ if (externalTask.flowNodeInstanceId) {
54
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
55
+ }
68
56
 
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
- };
57
+ showStatus(node, Object.keys(started_external_tasks).length);
75
58
 
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}'`);
59
+ //resolve(result);
60
+ saveHandleCallback(result, resolve);
61
+ };
78
62
 
79
- if (isError) {
80
- handleErrorTask(msg);
81
- } else {
82
- handleFinishTask(msg);
83
- }
84
- });
63
+ const handleErrorTask = (msg) => {
64
+ node.log(
65
+ `handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`,
66
+ );
85
67
 
86
- started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
68
+ if (externalTask.flowNodeInstanceId) {
69
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
70
+ }
87
71
 
88
- showStatus(node, Object.keys(started_external_tasks).length);
72
+ showStatus(node, Object.keys(started_external_tasks).length);
89
73
 
90
- let msg = {
91
- _msgid: RED.util.generateId(),
92
- task: RED.util.encodeObject(externalTask),
93
- payload: payload,
94
- flowNodeInstanceId: externalTask.flowNodeInstanceId
95
- };
74
+ // TODO: with reject, the default error handling is proceed
75
+ // SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
76
+ // reject(result);
77
+ //resolve(msg);
78
+ saveHandleCallback(msg, resolve);
79
+ };
80
+
81
+ eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
82
+ node.log(
83
+ `handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`,
84
+ );
85
+
86
+ if (isError) {
87
+ handleErrorTask(msg);
88
+ } else {
89
+ handleFinishTask(msg);
90
+ }
91
+ });
96
92
 
97
- node.log(`Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`);
93
+ started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
98
94
 
99
- node.send(msg);
100
- });
101
- })
102
- .then(async (externalTaskWorker) => {
103
- node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
95
+ showStatus(node, Object.keys(started_external_tasks).length);
104
96
 
105
- externalTaskWorker.identity = node.server.identity;
106
- node.server.registerOnIdentityChanged((identity) => {
107
- externalTaskWorker.identity = identity;
108
- });
97
+ let msg = {
98
+ _msgid: RED.util.generateId(),
99
+ task: RED.util.encodeObject(externalTask),
100
+ payload: payload,
101
+ flowNodeInstanceId: externalTask.flowNodeInstanceId,
102
+ };
109
103
 
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}`);
104
+ node.log(
105
+ `Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`,
106
+ );
117
107
 
118
- if (externalTask) {
119
- delete started_external_tasks[externalTask.flowNodeInstanceId];
120
- }
108
+ node.send(msg);
109
+ });
110
+ })
111
+ .then(async (externalTaskWorker) => {
112
+ node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
121
113
 
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
- });
114
+ externalTaskWorker.identity = engine.identity;
115
+ engine.registerOnIdentityChanged((identity) => {
116
+ externalTaskWorker.identity = identity;
117
+ });
129
118
 
130
- try {
131
- externalTaskWorker.start();
132
- } catch (error) {
133
- node.error(`Worker start 'externalTaskWorker.start' failed: ${error.message}`);
134
- }
119
+ // export type WorkerErrorHandler = (errorType: 'fetchAndLock' | 'extendLock' | 'processExternalTask' | 'finishExternalTask', error: Error, externalTask?: ExternalTask<any>) => void;
120
+ externalTaskWorker.onWorkerError((errorType, error, externalTask) => {
121
+ switch (errorType) {
122
+ case 'extendLock':
123
+ case 'finishExternalTask':
124
+ case 'processExternalTask':
125
+ node.error(
126
+ `Worker error ${errorType} for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}': ${error.message}`
127
+ );
128
+
129
+ if (externalTask) {
130
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
131
+ }
132
+
133
+ showStatus(node, Object.keys(started_external_tasks).length);
134
+ break;
135
+ default:
136
+ node.error(`Worker error ${errorType}: ${error.message}`);
137
+ break;
138
+ }
139
+ });
135
140
 
136
- node.on("close", () => {
137
141
  try {
138
- externalTaskWorker.stop();
139
- } catch {
140
- node.error('Client close failed');
142
+ externalTaskWorker.start();
143
+ } catch (error) {
144
+ node.error(`Worker start 'externalTaskWorker.start' failed: ${error.message}`);
141
145
  }
146
+
147
+ node.on('close', () => {
148
+ try {
149
+ externalTaskWorker.stop();
150
+ } catch {
151
+ node.error('Client close failed');
152
+ }
153
+ });
154
+ })
155
+ .catch((error) => {
156
+ node.error(`Error in subscribeToExternalTaskTopic: ${error.message}`);
142
157
  });
143
- });
144
158
  }
145
159
 
146
- RED.nodes.registerType("externaltask-input", ExternalTaskInput);
147
- }
160
+ RED.nodes.registerType('externaltask-input', ExternalTaskInput);
161
+ };
@@ -22,7 +22,7 @@
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
25
+ Used to complete the external task. The `msg.payload` is returned to the ProcessCube
26
26
  engine as the result of the external task.
27
27
 
28
28
  ## Inputs
@@ -31,6 +31,6 @@ engine as the result of the external task.
31
31
 
32
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
  };
@@ -36,6 +36,18 @@
36
36
  </div>
37
37
  </script>
38
38
 
39
- <script type="text/html" data-help-name="externaltask-input">
40
- <p>A node which emmits an message event to the Engine.</p>
39
+ <script type="text/markdown" data-help-name="externaltask-input">
40
+ A Message event to an intermediate message event can be triggert.
41
+
42
+ From the config the `messagename` and the `processInstanceId` must be set.
43
+
44
+ ## Inputs
45
+
46
+ : payload (Object) : Will sent to the event and used an new token payload.
47
+
48
+ ### References
49
+
50
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
51
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
52
+
41
53
  </script>
@@ -3,16 +3,21 @@ module.exports = function (RED) {
3
3
  RED.nodes.createNode(this, config);
4
4
  var node = this;
5
5
 
6
- this.engine = this.server = RED.nodes.getNode(config.engine);
6
+ node.on('input', function (msg) {
7
7
 
8
- const client = this.engine.getEngineClient();
8
+ const engine = RED.nodes.getNode(config.engine);
9
+ const client = engine.engineClient;
9
10
 
10
- node.on('input', function (msg) {
11
- client.events
11
+ if (!client) {
12
+ node.error('No engine configured.');
13
+ return;
14
+ }
15
+
16
+ engine.engineClient.events
12
17
  .triggerMessageEvent(config.messagename, {
13
18
  processInstanceId: config.processinstanceid,
14
19
  payload: msg.payload,
15
- identity: node.server.identity,
20
+ identity: engine.identity,
16
21
  })
17
22
  .then((result) => {
18
23
  msg.payload = result;