@5minds/node-red-contrib-processcube 0.14.0-feature-7cec87-lyytfjz9 → 0.14.0-fix-error-in-process-instance-query-9aeac9-lyzi0gix

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/.prettierrc.json +6 -0
  2. package/Dockerfile +1 -1
  3. package/docker-compose.yml +0 -12
  4. package/externaltask-error.html +12 -26
  5. package/externaltask-error.js +20 -19
  6. package/externaltask-input.html +14 -31
  7. package/externaltask-input.js +55 -107
  8. package/externaltask-output.html +10 -20
  9. package/externaltask-output.js +11 -12
  10. package/message-event-trigger.html +14 -14
  11. package/message-event-trigger.js +21 -25
  12. package/nodered/node-red-contrib-processcube-flows.json +132 -216
  13. package/nodered/package.json +0 -1
  14. package/nodered/settings.js +82 -92
  15. package/package.json +9 -3
  16. package/process-start.html +19 -23
  17. package/process-start.js +18 -18
  18. package/processcube-engine-config.html +10 -10
  19. package/processcube-engine-config.js +22 -30
  20. package/processdefinition-query.html +29 -23
  21. package/processdefinition-query.js +12 -16
  22. package/processes/CheckError.bpmn +78 -0
  23. package/processes/NodeRedExternalTask.bpmn +77 -0
  24. package/processes/SampleUserTask.bpmn +95 -0
  25. package/processinstance-query.html +19 -20
  26. package/processinstance-query.js +17 -12
  27. package/signal-event-trigger.html +14 -14
  28. package/signal-event-trigger.js +21 -25
  29. package/usertask-finished-listener.html +17 -12
  30. package/usertask-finished-listener.js +34 -16
  31. package/usertask-input.html +40 -27
  32. package/usertask-input.js +19 -18
  33. package/usertask-new-listener.html +17 -12
  34. package/usertask-new-listener.js +35 -18
  35. package/usertask-output.html +23 -24
  36. package/usertask-output.js +12 -12
  37. package/examples/External-Task-Sample.json +0 -252
  38. package/processes/External-Task-Sample.bpmn +0 -94
@@ -0,0 +1,6 @@
1
+ {
2
+ "singleQuote": true,
3
+ "printWidth": 120,
4
+ "arrowParens": "always",
5
+ "tabWidth": 4
6
+ }
package/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM node:20 AS builder
1
+ FROM node:20 as builder
2
2
 
3
3
  COPY ./ /src/node-red-contrib-processcube
4
4
 
@@ -5,17 +5,12 @@ services:
5
5
  context: .
6
6
  ports:
7
7
  - "1880:1880"
8
- - "9229:9229"
9
8
  environment:
10
9
  - TZ=Europe/Berlin
11
10
  - ENGINE_URL=http://engine:8000
12
11
  - FLOWS=/nodered/node-red-contrib-processcube-flows.json
13
12
  volumes:
14
13
  - ./nodered/:/nodered/
15
- - ./examples/:/examples/
16
- depends_on:
17
- - engine
18
- - authority
19
14
 
20
15
  engine:
21
16
  image: 5minds/processcube_engine:2024-1
@@ -24,16 +19,9 @@ services:
24
19
  volumes:
25
20
  - ./processes:/processes:ro
26
21
  environment:
27
- application__name: Engine for Node-RED contrib
28
22
  iam__baseUrl: http://authority:11560
29
23
  iam__allowAnonymousRootAccess: true
30
24
  command: --seed-dir=/processes --port 8000
31
- depends_on:
32
- - authority
33
- healthcheck:
34
- test: bash -c "[ -f /tmp/healthy ]"
35
- timeout: 1s
36
- retries: 20
37
25
 
38
26
  authority:
39
27
  image: 5minds/processcube_authority:3.0.4
@@ -1,45 +1,31 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('externaltask-error',{
2
+ RED.nodes.registerType('externaltask-error', {
3
3
  category: 'ProcessCube',
4
4
  color: '#F6A923',
5
5
  defaults: {
6
- name: {value:""},
7
- error: {value:""}
6
+ name: { value: '' },
7
+ error: { value: '' },
8
8
  },
9
9
  inputs: 1,
10
10
  outputs: 1,
11
- icon: "font-awesome/fa-exclamation-triangle",
12
- label: function() {
13
- return this.name || "externaltask-error";
14
- }
11
+ icon: 'font-awesome/fa-exclamation-triangle',
12
+ label: function () {
13
+ return this.name || 'externaltask-error';
14
+ },
15
15
  });
16
16
  </script>
17
17
 
18
18
  <script type="text/html" data-template-name="externaltask-error">
19
19
  <div class="form-row">
20
20
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
21
- <input type="text" id="node-input-name" placeholder="Name">
21
+ <input type="text" id="node-input-name" placeholder="Name" />
22
22
  </div>
23
23
  <div class="form-row">
24
24
  <label for="node-input-error"><i class="fa fa-tag"></i> Error Code</label>
25
- <input type="text" id="node-input-error" placeholder="Error Code of ExternalTask">
25
+ <input type="text" id="node-input-error" placeholder="Error Code of ExternalTask" />
26
26
  </div>
27
27
  </script>
28
28
 
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;
45
- </script>
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>
31
+ </script>
@@ -1,32 +1,33 @@
1
- module.exports = function(RED) {
1
+ module.exports = function (RED) {
2
2
  function ExternalTaskError(config) {
3
- RED.nodes.createNode(this,config);
3
+ RED.nodes.createNode(this, config);
4
4
  var node = this;
5
5
 
6
6
  var flowContext = node.context().flow;
7
- var eventEmitter = flowContext.get('emitter');
7
+ var eventEmitter = flowContext.get('emitter');
8
8
 
9
- node.on('input', function(msg) {
9
+ node.on('input', function (msg) {
10
+ const externalTaskId = msg.externalTaskId;
10
11
 
11
- const flowNodeInstanceId = msg.flowNodeInstanceId;
12
+ let error = msg.error;
12
13
 
13
- let msgError = msg.error;
14
-
15
- if (msgError === undefined) {
16
- msgError.message = "An error occurred";
14
+ if (error === undefined) {
15
+ error.message = 'An error occurred';
16
+ error.source = msg.payload;
17
17
  }
18
18
 
19
- const error = new Error(msgError.message);
20
- error.errorCode = config.error;
21
- error.errorDetails = RED.util.encodeObject(msg);
19
+ msg.payload = {
20
+ error: {
21
+ errorCode: config.error,
22
+ errorMessage: error.message,
23
+ errorDetails: error.source,
24
+ },
25
+ };
22
26
 
23
- msg.errorCode = config.error;
24
- msg.errorMessage = msgError.message;
27
+ eventEmitter.emit(`error-${externalTaskId}`, msg.payload);
25
28
 
26
- eventEmitter.emit(`handle-${flowNodeInstanceId}`, error, true);
27
-
28
29
  node.send(msg);
29
- });
30
+ });
30
31
  }
31
- RED.nodes.registerType("externaltask-error", ExternalTaskError);
32
- }
32
+ RED.nodes.registerType('externaltask-error', ExternalTaskError);
33
+ };
@@ -1,53 +1,36 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('externaltask-input',{
2
+ RED.nodes.registerType('externaltask-input', {
3
3
  category: 'ProcessCube',
4
4
  color: '#02AFD6',
5
5
  defaults: {
6
- name: {value: ""},
7
- engine: {value: "", type: "processcube-engine-config"},
8
- topic: {value: ""}
6
+ name: { value: '' },
7
+ engine: { value: '', type: 'processcube-engine-config' },
8
+ topic: { value: '' },
9
9
  },
10
10
  inputs: 0,
11
11
  outputs: 1,
12
- icon: "font-awesome/fa-envelope-open",
13
- label: function() {
14
- return this.name||"externaltask-input";
15
- }
12
+ icon: 'font-awesome/fa-envelope-open',
13
+ label: function () {
14
+ return this.name || 'externaltask-input';
15
+ },
16
16
  });
17
17
  </script>
18
18
 
19
19
  <script type="text/html" data-template-name="externaltask-input">
20
20
  <div class="form-row">
21
21
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
22
- <input type="text" id="node-input-name" placeholder="Name">
22
+ <input type="text" id="node-input-name" placeholder="Name" />
23
23
  </div>
24
24
  <div class="form-row">
25
25
  <label for="node-input-engine"><i class="fa fa-tag"></i> Engine</label>
26
- <input type="text" id="node-input-engine" placeholder="Engine">
26
+ <input type="text" id="node-input-engine" placeholder="Engine" />
27
27
  </div>
28
28
  <div class="form-row">
29
29
  <label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
30
- <input type="text" id="node-input-topic" placeholder="Topic of ExternalTask">
30
+ <input type="text" id="node-input-topic" placeholder="Topic of ExternalTask" />
31
31
  </div>
32
32
  </script>
33
33
 
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;
53
- </script>
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>
36
+ </script>
@@ -1,24 +1,44 @@
1
+ const process = require('process');
1
2
  const EventEmitter = require('node:events');
2
3
 
4
+ const engine_client = require('@5minds/processcube_engine_client');
5
+
3
6
  function showStatus(node, msgCounter) {
4
7
  if (msgCounter >= 1) {
5
- node.status({fill: "blue", shape: "dot", text: `handling tasks ${msgCounter}.`});
8
+ node.status({ fill: 'blue', shape: 'dot', text: `handling tasks ${msgCounter}` });
6
9
  } else {
7
- node.status({fill: "blue", shape: "ring", text: `subcribed.`});
10
+ node.status({ fill: 'blue', shape: 'ring', text: `subcribed ${msgCounter}` });
8
11
  }
9
12
  }
10
13
 
11
- const started_external_tasks = {};
14
+ function decrCounter(msgCounter) {
15
+ msgCounter--;
16
+
17
+ if (msgCounter < 0) {
18
+ msgCounter = 0;
19
+ }
12
20
 
13
- module.exports = function(RED) {
21
+ return msgCounter;
22
+ }
23
+
24
+ module.exports = function (RED) {
14
25
  function ExternalTaskInput(config) {
15
- RED.nodes.createNode(this,config);
26
+ RED.nodes.createNode(this, config);
16
27
  var node = this;
28
+ var msgCounter = 0;
17
29
  var flowContext = node.context().flow;
18
-
30
+ var nodeContext = node.context();
31
+
19
32
  this.engine = this.server = RED.nodes.getNode(config.engine);
20
33
 
21
- const client = this.engine.getEngineClient();
34
+ const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
35
+
36
+ var client = nodeContext.get('client');
37
+
38
+ if (!client) {
39
+ nodeContext.set('client', new engine_client.EngineClient(engineUrl));
40
+ client = nodeContext.get('client');
41
+ }
22
42
 
23
43
  var eventEmitter = flowContext.get('emitter');
24
44
 
@@ -27,126 +47,54 @@ module.exports = function(RED) {
27
47
  eventEmitter = flowContext.get('emitter');
28
48
  }
29
49
 
30
- client.externalTasks.subscribeToExternalTaskTopic(
31
- config.topic,
32
- async (payload, externalTask) => {
50
+ client.externalTasks
51
+ .subscribeToExternalTaskTopic(config.topic, async (payload, externalTask) => {
52
+ msgCounter++;
33
53
 
34
- const saveHandleCallback = (data, callback) => {
35
- try {
36
- callback(data);
37
- } catch (error) {
38
- node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
39
- }
40
- };
41
-
42
54
  return await new Promise((resolve, reject) => {
55
+ // TODO: once ist 2x gebunden
56
+ eventEmitter.once(`finish-${externalTask.flowNodeInstanceId}`, (result) => {
57
+ msgCounter = decrCounter(msgCounter);
43
58
 
44
- const handleFinishTask = (msg) => {
45
- let result = RED.util.encodeObject(msg.payload);
46
-
47
- node.log(`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`);
48
-
49
- if (externalTask.flowNodeInstanceId) {
50
- delete started_external_tasks[externalTask.flowNodeInstanceId];
51
- }
52
-
53
- showStatus(node, Object.keys(started_external_tasks).length);
54
-
55
-
56
- //resolve(result);
57
- saveHandleCallback(result, resolve)
58
- };
59
-
60
- const handleErrorTask = (msg) => {
61
-
62
- node.log(`handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`);
63
-
64
- if (externalTask.flowNodeInstanceId) {
65
- delete started_external_tasks[externalTask.flowNodeInstanceId];
66
- }
67
-
68
- showStatus(node, Object.keys(started_external_tasks).length);
69
-
59
+ showStatus(node, msgCounter);
60
+ resolve(result);
61
+ });
70
62
 
71
- // TODO: with reject, the default error handling is proceed
72
- // SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
73
- // reject(result);
74
- //resolve(msg);
75
- saveHandleCallback(msg, resolve);
76
- };
63
+ eventEmitter.once(`error-${externalTask.flowNodeInstanceId}`, (msg) => {
64
+ msgCounter = decrCounter(msgCounter);
65
+ showStatus(node, msgCounter);
77
66
 
78
- eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
79
- node.log(`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`);
67
+ var result = msg.payload ? msg.payload : msg;
80
68
 
81
- if (isError) {
82
- handleErrorTask(msg);
83
- } else {
84
- handleFinishTask(msg);
85
- }
69
+ reject(result);
86
70
  });
87
71
 
88
- started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
89
-
90
- showStatus(node, Object.keys(started_external_tasks).length);
72
+ showStatus(node, msgCounter);
91
73
 
92
- let msg = {
93
- _msgid: RED.util.generateId(),
94
- task: RED.util.encodeObject(externalTask),
74
+ node.send({
75
+ topic: externalTask.topic,
95
76
  payload: payload,
96
- flowNodeInstanceId: externalTask.flowNodeInstanceId
97
- };
98
-
99
- node.log(`Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`);
100
-
101
- node.send(msg);
77
+ externalTaskId: externalTask.flowNodeInstanceId,
78
+ });
102
79
  });
103
- },
104
- ).then(async externalTaskWorker => {
105
- node.status({fill: "blue", shape: "ring", text: "subcribed"});
80
+ })
81
+ .then(async (externalTaskWorker) => {
82
+ node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
106
83
 
107
84
  externalTaskWorker.identity = node.server.identity;
108
85
  node.server.registerOnIdentityChanged((identity) => {
109
86
  externalTaskWorker.identity = identity;
110
- });
111
-
112
- // export type WorkerErrorHandler = (errorType: 'fetchAndLock' | 'extendLock' | 'processExternalTask' | 'finishExternalTask', error: Error, externalTask?: ExternalTask<any>) => void;
113
- externalTaskWorker.onWorkerError((errorType, error, externalTask) => {
114
- switch (errorType) {
115
- case 'extendLock':
116
- case 'finishExternalTask':
117
- case 'processExternalTask':
118
- node.error(`Worker error ${errorType} for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}': ${error.message}`);
119
-
120
- if (externalTask) {
121
- delete started_external_tasks[externalTask.flowNodeInstanceId];
122
- }
123
-
124
- showStatus(node, Object.keys(started_external_tasks).length);
125
- break;
126
- default:
127
- node.error(`Worker error ${errorType}: ${error.message}`);
128
- break;
129
- }
130
87
  });
88
+ await externalTaskWorker.start();
131
89
 
132
- try {
133
- externalTaskWorker.start();
134
- } catch (error) {
135
- node.error(`Worker start 'externalTaskWorker.start' failed: ${error.message}`);
136
- }
137
-
138
- node.on("close", () => {
90
+ node.on('close', async () => {
139
91
  try {
140
92
  externalTaskWorker.stop();
141
93
  } catch {
142
- node.error('Client close failed');
94
+ console.warn('Client close failed');
143
95
  }
144
96
  });
145
- }
146
- ).catch((error) => {
147
- node.error(`Error in subscribeToExternalTaskTopic: ${error.message}`);
148
- });
97
+ });
149
98
  }
150
-
151
- RED.nodes.registerType("externaltask-input", ExternalTaskInput);
152
- }
99
+ RED.nodes.registerType('externaltask-input', ExternalTaskInput);
100
+ };
@@ -1,36 +1,26 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('externaltask-output',{
2
+ RED.nodes.registerType('externaltask-output', {
3
3
  category: 'ProcessCube',
4
4
  color: '#02AFD6',
5
5
  defaults: {
6
- name: {value:""}
6
+ name: { value: '' },
7
7
  },
8
8
  inputs: 1,
9
9
  outputs: 0,
10
- icon: "font-awesome/fa-envelope",
11
- label: function() {
12
- return this.name||"externaltask-output";
13
- }
10
+ icon: 'font-awesome/fa-envelope',
11
+ label: function () {
12
+ return this.name || 'externaltask-output';
13
+ },
14
14
  });
15
15
  </script>
16
16
 
17
17
  <script type="text/html" data-template-name="externaltask-output">
18
18
  <div class="form-row">
19
19
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
20
- <input type="text" id="node-input-name" placeholder="Name">
20
+ <input type="text" id="node-input-name" placeholder="Name" />
21
21
  </div>
22
22
  </script>
23
23
 
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;
36
- </script>
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>
26
+ </script>
@@ -1,21 +1,20 @@
1
- module.exports = function(RED) {
1
+ module.exports = function (RED) {
2
2
  function ExternalTaskOutput(config) {
3
- RED.nodes.createNode(this,config);
3
+ RED.nodes.createNode(this, config);
4
4
  var node = this;
5
5
 
6
6
  var flowContext = node.context().flow;
7
7
  var eventEmitter = flowContext.get('emitter');
8
8
 
9
- node.on('input', function(msg) {
10
-
11
- const flowNodeInstanceId = msg.flowNodeInstanceId;
9
+ node.on('input', function (msg) {
10
+ const externalTaskId = msg.externalTaskId;
12
11
 
13
- if (!flowNodeInstanceId) {
14
- node.error('Error: The message did not contain the required external task id.', msg);
15
- }
12
+ if (!externalTaskId) {
13
+ node.error('Error: The message did not contain the required external task id.', msg);
14
+ }
16
15
 
17
- eventEmitter.emit(`handle-${flowNodeInstanceId}`, msg, false);
18
- });
16
+ eventEmitter.emit(`finish-${externalTaskId}`, msg.payload);
17
+ });
19
18
  }
20
- RED.nodes.registerType("externaltask-output", ExternalTaskOutput);
21
- }
19
+ RED.nodes.registerType('externaltask-output', ExternalTaskOutput);
20
+ };
@@ -1,41 +1,41 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('message-event-trigger',{
2
+ RED.nodes.registerType('message-event-trigger', {
3
3
  category: 'ProcessCube',
4
4
  color: '#02AFD6',
5
5
  defaults: {
6
- name: {value: ""},
7
- engine: {value: "", type: "processcube-engine-config"},
8
- messagename: {value: "", required: true},
9
- processInstanceId: {value:""}
6
+ name: { value: '' },
7
+ engine: { value: '', type: 'processcube-engine-config' },
8
+ messagename: { value: '', required: true },
9
+ processInstanceId: { value: '' },
10
10
  },
11
11
  inputs: 1,
12
12
  outputs: 1,
13
- icon: "font-awesome/fa-envelope-open",
14
- label: function() {
15
- return this.name||"message-event-trigger";
16
- }
13
+ icon: 'font-awesome/fa-envelope-open',
14
+ label: function () {
15
+ return this.name || 'message-event-trigger';
16
+ },
17
17
  });
18
18
  </script>
19
19
 
20
20
  <script type="text/html" data-template-name="message-event-trigger">
21
21
  <div class="form-row">
22
22
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
23
- <input type="text" id="node-input-name" placeholder="Name">
23
+ <input type="text" id="node-input-name" placeholder="Name" />
24
24
  </div>
25
25
  <div class="form-row">
26
26
  <label for="node-input-engine"><i class="fa fa-tag"></i> Engine</label>
27
- <input type="text" id="node-input-engine" placeholder="Engine">
27
+ <input type="text" id="node-input-engine" placeholder="Engine" />
28
28
  </div>
29
29
  <div class="form-row">
30
30
  <label for="node-input-messagename"><i class="fa fa-tag"></i> Message Name</label>
31
- <input type="text" id="node-input-messagename" placeholder="Name of the Message-Event">
31
+ <input type="text" id="node-input-messagename" placeholder="Name of the Message-Event" />
32
32
  </div>
33
33
  <div class="form-row">
34
34
  <label for="node-input-processinstanceid"><i class="fa fa-tag"></i> Process Instance Id</label>
35
- <input type="text" id="node-input-processinstanceid" placeholder="Id of the recipient process instance">
35
+ <input type="text" id="node-input-processinstanceid" placeholder="Id of the recipient process instance" />
36
36
  </div>
37
37
  </script>
38
38
 
39
39
  <script type="text/html" data-help-name="externaltask-input">
40
40
  <p>A node which emmits an message event to the Engine.</p>
41
- </script>
41
+ </script>
@@ -2,7 +2,7 @@ const process = require('process');
2
2
 
3
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;
@@ -17,29 +17,25 @@ module.exports = function(RED) {
17
17
  if (!client) {
18
18
  nodeContext.set('client', new engine_client.EngineClient(engineUrl));
19
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
- });
20
+ }
21
+
22
+ node.on('input', function (msg) {
23
+ client.events
24
+ .triggerMessageEvent(config.messagename, {
25
+ processInstanceId: config.processinstanceid,
26
+ payload: msg.payload,
27
+ identity: node.server.identity,
28
+ })
29
+ .then((result) => {
30
+ msg.payload = result;
31
+
32
+ node.send(msg);
33
+ node.status({ fill: 'blue', shape: 'dot', text: `message event triggered` });
34
+ })
35
+ .catch((error) => {
36
+ node.error(error);
37
+ });
42
38
  });
43
39
  }
44
- RED.nodes.registerType("message-event-trigger", MessageEventTrigger);
45
- }
40
+ RED.nodes.registerType('message-event-trigger', MessageEventTrigger);
41
+ };