@5minds/node-red-contrib-processcube 1.1.4-feature-bc1698-m0kn1ci4 → 1.1.4-feature-db7b89-m14muv3d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@
8
8
  },
9
9
  inputs: 1,
10
10
  outputs: 1,
11
+ align: 'right',
11
12
  icon: 'externaltask_error.svg',
12
13
  label: function () {
13
14
  return this.name || 'externaltask-error';
@@ -45,6 +45,11 @@ A node which listens for events triggered by externaltasks
45
45
 
46
46
  ## Outputs
47
47
 
48
+ : flowNodeInstanceId (string): The unique identifier for the flow node instance.
49
+ : externalTaskEvent (Object): An Object containing the event data returned by the engine.
50
+ : action (string): The event that occured.
51
+ : type (string): The target of the event.
52
+
48
53
  ### References
49
54
 
50
55
  - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
@@ -31,27 +31,21 @@ module.exports = function (RED) {
31
31
  }
32
32
 
33
33
  async function subscribe() {
34
- const eventHandlers = {
35
- created: () =>
36
- client.notification.onExternalTaskCreated(externalTaskCallback('created'), {
34
+ switch (config.eventtype) {
35
+ case 'created':
36
+ return await client.notification.onExternalTaskCreated(externalTaskCallback(), {
37
37
  identity: currentIdentity,
38
- }),
39
- locked: () =>
40
- client.notification.onExternalTaskLocked(externalTaskCallback('locked'), {
38
+ });
39
+ case 'locked':
40
+ return await client.notification.onExternalTaskLocked(externalTaskCallback(), {
41
41
  identity: currentIdentity,
42
- }),
43
- unlocked: () =>
44
- client.notification.onExternalTaskUnlocked(externalTaskCallback('unlocked'), {
42
+ });
43
+ case 'unlocked':
44
+ return await client.notification.onExternalTaskUnlocked(externalTaskCallback(), {
45
45
  identity: currentIdentity,
46
- }),
47
- };
48
-
49
- const handler = eventHandlers[config.eventtype];
50
-
51
- if (handler) {
52
- return await handler();
53
- } else {
54
- console.error('No such event: ' + config.eventtype);
46
+ });
47
+ default:
48
+ console.error('no such event: ' + config.eventtype);
55
49
  }
56
50
  }
57
51
 
@@ -6,6 +6,7 @@
6
6
  name: { value: '' },
7
7
  engine: { value: '', type: 'processcube-engine-config' },
8
8
  topic: { value: '' },
9
+ workerConfig: { value: '', type: 'json' },
9
10
  },
10
11
  inputs: 0,
11
12
  outputs: 1,
@@ -13,6 +14,15 @@
13
14
  label: function () {
14
15
  return this.name || 'externaltask-input';
15
16
  },
17
+ oneditprepare: function () {
18
+ $('#node-input-workerConfig').typedInput({
19
+ default: 'json',
20
+ types: ['json'],
21
+ });
22
+ },
23
+ oneditsave: function () {
24
+ this.workerConfig = $('#node-input-workerConfig').typedInput('value');
25
+ },
16
26
  });
17
27
  </script>
18
28
 
@@ -29,6 +39,10 @@
29
39
  <label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
30
40
  <input type="text" id="node-input-topic" placeholder="Topic of ExternalTask" />
31
41
  </div>
42
+ <div class="form-row"></div>
43
+ <label for="node-input-workerConfig"><i class="fa fa-tag"></i> Worker Config</label>
44
+ <input type="text" id="node-input-workerConfig" />
45
+ </div>
32
46
  </script>
33
47
 
34
48
  <script type="text/markdown" data-help-name="externaltask-input">
@@ -37,9 +51,9 @@ the connected ProcessCube Engine for processing.
37
51
 
38
52
  ## Outputs
39
53
 
40
- : payload (string) : Defines the input of the external task token
54
+ : payload (string) : The payload the external task was started with.
41
55
  : task (object) : The external task object
42
- : flowNodeInstanceId : The Id of the external task, which is needed to complete the task
56
+ : flowNodeInstanceId : The unique identifier of the external task, which is needed to complete the task
43
57
 
44
58
  ### Details
45
59
 
@@ -16,7 +16,7 @@ module.exports = function (RED) {
16
16
  var node = this;
17
17
  var flowContext = node.context().flow;
18
18
 
19
- const engine = RED.nodes.getNode(config.engine);
19
+ const engine = RED.nodes.getNode(config.engine);
20
20
 
21
21
  const client = engine.engineClient;
22
22
 
@@ -32,82 +32,84 @@ module.exports = function (RED) {
32
32
  eventEmitter = flowContext.get('emitter');
33
33
  }
34
34
 
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}`);
42
- }
43
- };
35
+ const etwCallback = async (payload, externalTask) => {
36
+ const saveHandleCallback = (data, callback) => {
37
+ try {
38
+ callback(data);
39
+ } catch (error) {
40
+ node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
41
+ }
42
+ };
44
43
 
45
- return await new Promise((resolve, reject) => {
46
- const handleFinishTask = (msg) => {
47
- let result = RED.util.encodeObject(msg.payload);
44
+ return await new Promise((resolve, reject) => {
45
+ const handleFinishTask = (msg) => {
46
+ let result = RED.util.encodeObject(msg.payload);
48
47
 
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
- );
48
+ node.log(
49
+ `handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`
50
+ );
52
51
 
53
- if (externalTask.flowNodeInstanceId) {
54
- delete started_external_tasks[externalTask.flowNodeInstanceId];
55
- }
52
+ if (externalTask.flowNodeInstanceId) {
53
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
54
+ }
56
55
 
57
- showStatus(node, Object.keys(started_external_tasks).length);
56
+ showStatus(node, Object.keys(started_external_tasks).length);
58
57
 
59
- //resolve(result);
60
- saveHandleCallback(result, resolve);
61
- };
58
+ //resolve(result);
59
+ saveHandleCallback(result, resolve);
60
+ };
61
+
62
+ const handleErrorTask = (msg) => {
63
+ node.log(
64
+ `handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`
65
+ );
62
66
 
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
- );
67
+ if (externalTask.flowNodeInstanceId) {
68
+ delete started_external_tasks[externalTask.flowNodeInstanceId];
69
+ }
67
70
 
68
- if (externalTask.flowNodeInstanceId) {
69
- delete started_external_tasks[externalTask.flowNodeInstanceId];
70
- }
71
+ showStatus(node, Object.keys(started_external_tasks).length);
71
72
 
72
- showStatus(node, Object.keys(started_external_tasks).length);
73
+ // TODO: with reject, the default error handling is proceed
74
+ // SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
75
+ // reject(result);
76
+ //resolve(msg);
77
+ saveHandleCallback(msg, resolve);
78
+ };
73
79
 
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
+ eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
81
+ node.log(
82
+ `handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`
83
+ );
80
84
 
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
+ if (isError) {
86
+ handleErrorTask(msg);
87
+ } else {
88
+ handleFinishTask(msg);
89
+ }
90
+ });
85
91
 
86
- if (isError) {
87
- handleErrorTask(msg);
88
- } else {
89
- handleFinishTask(msg);
90
- }
91
- });
92
+ started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
92
93
 
93
- started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
94
+ showStatus(node, Object.keys(started_external_tasks).length);
94
95
 
95
- showStatus(node, Object.keys(started_external_tasks).length);
96
+ let msg = {
97
+ _msgid: RED.util.generateId(),
98
+ task: RED.util.encodeObject(externalTask),
99
+ payload: payload,
100
+ flowNodeInstanceId: externalTask.flowNodeInstanceId,
101
+ };
96
102
 
97
- let msg = {
98
- _msgid: RED.util.generateId(),
99
- task: RED.util.encodeObject(externalTask),
100
- payload: payload,
101
- flowNodeInstanceId: externalTask.flowNodeInstanceId,
102
- };
103
+ node.log(
104
+ `Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`
105
+ );
103
106
 
104
- node.log(
105
- `Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`,
106
- );
107
+ node.send(msg);
108
+ });
109
+ };
107
110
 
108
- node.send(msg);
109
- });
110
- })
111
+ client.externalTasks
112
+ .subscribeToExternalTaskTopic(config.topic, etwCallback, config.workerConfig)
111
113
  .then(async (externalTaskWorker) => {
112
114
  node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
113
115
 
@@ -6,7 +6,6 @@
6
6
  name: { value: '' },
7
7
  engine: { value: '', type: 'processcube-engine-config' },
8
8
  messagename: { value: '', required: true },
9
- processInstanceId: { value: '' },
10
9
  },
11
10
  inputs: 1,
12
11
  outputs: 1,
@@ -30,24 +29,21 @@
30
29
  <label for="node-input-messagename"><i class="fa fa-tag"></i> Message Name</label>
31
30
  <input type="text" id="node-input-messagename" placeholder="Name of the Message-Event" />
32
31
  </div>
33
- <div class="form-row">
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" />
36
- </div>
37
32
  </script>
38
33
 
39
34
  <script type="text/markdown" data-help-name="externaltask-input">
40
- A Message event to an intermediate message event can be triggert.
35
+ A node to trigger an event that will be send to the corresponding intermediate message event in the connected ProcessCube Engine.
41
36
 
42
37
  From the config the `messagename` and the `processInstanceId` must be set.
43
38
 
44
39
  ## Inputs
45
40
 
46
- : payload (Object) : Will sent to the event and used an new token payload.
41
+ : payload (Object) : The payload will be sent to the message event and be used as a new token payload.
42
+ : processInstanceId (string) : The process instance where the message event should be triggered.
47
43
 
48
44
  ### References
49
45
 
50
46
  - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
51
47
  - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
52
-
48
+
53
49
  </script>
@@ -15,7 +15,7 @@ module.exports = function (RED) {
15
15
 
16
16
  engine.engineClient.events
17
17
  .triggerMessageEvent(config.messagename, {
18
- processInstanceId: config.processinstanceid,
18
+ processInstanceId: msg.processinstanceid,
19
19
  payload: msg.payload,
20
20
  identity: engine.identity,
21
21
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.1.4-feature-bc1698-m0kn1ci4",
3
+ "version": "1.1.4-feature-db7b89-m14muv3d",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -41,6 +41,7 @@
41
41
  "externaltaskError": "externaltask-error.js",
42
42
  "externaltaskEventListener": "externaltask-event-listener.js",
43
43
  "processStart": "process-start.js",
44
+ "processTerminate": "process-terminate.js",
44
45
  "processEventListener": "process-event-listener.js",
45
46
  "processcubeEngineConfig": "processcube-engine-config.js",
46
47
  "ProcessinstanceQuery": "processinstance-query.js",
@@ -75,6 +75,95 @@ A node which listens for events triggered by processes
75
75
 
76
76
  ## Outputs
77
77
 
78
+ ### starting
79
+
80
+ : processInstanceId (string): The unique identifier for the process instance.
81
+ : processModelId (string): The id of the process model.
82
+ : processInstance (Object): An Object representing the process instance data.
83
+ : action (string): The event that occured.
84
+ : type (string): The target of the event.
85
+
86
+ ### started
87
+
88
+ : processInstanceId (string): The unique identifier for the process instance.
89
+ : processModelId (string): The id of the process model.
90
+ : flowNodeId (string): The id of the flowNode the process was started with.
91
+ : token (Object): The start token of the process instance.
92
+ : processInstance (Object): An Object representing the process instance data.
93
+ : action (string): The event that occured.
94
+ : type (string): The target of the event.
95
+
96
+ ### resumed
97
+
98
+ : processInstanceId (string): The unique identifier for the process instance.
99
+ : processModelId (string): The id of the process model.
100
+ : token (Object): The current token of the process instance.
101
+ : processInstance (Object): An Object representing the process instance data.
102
+ : action (string): The event that occured.
103
+ : type (string): The target of the event.
104
+
105
+ ### finished
106
+
107
+ : processInstanceId (string): The unique identifier for the process instance.
108
+ : processModelId (string): The id of the process model.
109
+ : flowNodeId (string): The id of the flowNode the process was finished with.
110
+ : token (Object): The end token of the process instance.
111
+ : processInstance (Object): An Object representing the process instance data.
112
+ : action (string): The event that occured.
113
+ : type (string): The target of the event.
114
+
115
+ ### terminated
116
+
117
+ : processInstanceId (string): The unique identifier for the process instance.
118
+ : processModelId (string): The id of the process model.
119
+ : token (Object): The current token of the process instance.
120
+ : processInstance (Object): An Object representing the process instance data.
121
+ : action (string): The event that occured.
122
+ : type (string): The target of the event.
123
+
124
+ ### error
125
+
126
+ : processInstanceId (string): The unique identifier for the process instance.
127
+ : processModelId (string): The id of the process model.
128
+ : token (Object): The current token of the process instance.
129
+ : processInstance (Object): An Object representing the process instance data.
130
+ : action (string): The event that occured.
131
+ : type (string): The target of the event.
132
+
133
+ ### owner-changed
134
+
135
+ : processInstanceId (string): The unique identifier for the process instance.
136
+ : processModelId (string): The id of the process model.
137
+ : processInstance (Object): An Object representing the process instance data.
138
+ : action (string): The event that occured.
139
+ : type (string): The target of the event.
140
+
141
+ ### instances-deleted
142
+
143
+ : processInstanceId (string): The unique identifier for the process instance.
144
+ : processModelId (string): The id of the process model.
145
+ : processInstance (Object): An Object representing the process instance data.
146
+ : action (string): The event that occured.
147
+ : type (string): The target of the event.
148
+
149
+ ### is-executable-changed
150
+
151
+ : processModelId (string): The id of the process model.
152
+ : action (string): The event that occured.
153
+ : type (string): The target of the event.
154
+
155
+ ### deployed
156
+
157
+ : processModelId (string): The id of the process model.
158
+ : action (string): The event that occured.
159
+ : type (string): The target of the event.
160
+
161
+ ### undeployed
162
+
163
+ : processModelId (string): The id of the process model.
164
+ : action (string): The event that occured.
165
+ : type (string): The target of the event.
166
+
78
167
  ### References
79
168
 
80
169
  - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
@@ -43,10 +43,15 @@ The `processModelId` and `startEventId` can be set in the message object to over
43
43
 
44
44
  ## Inputs
45
45
 
46
- : payload (Object) : Will be used as the input for the process.
46
+ : payload (Object) : Will be used as the start token for the process.
47
47
  : processModelId (String) : Will be used as the process model and override the configured `Processmodel`.
48
48
  : startEventId (String) : Will be used as the start event and override the configured `Startevent`.
49
49
 
50
+ ## Outputs
51
+
52
+ : processInstanceId (string) : The unique identifier of the started process instance.
53
+ : correlationId (string) : The unique correlation identifier of the started process instance.
54
+
50
55
  ### References
51
56
 
52
57
  - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
@@ -0,0 +1,45 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('process-terminate', {
3
+ category: 'ProcessCube',
4
+ color: '#02AFD6',
5
+ defaults: {
6
+ name: { value: '' },
7
+ engine: { value: '', type: 'processcube-engine-config' },
8
+ },
9
+ inputs: 1,
10
+ outputs: 1,
11
+ icon: 'font-awesome/fa-sign-in',
12
+ label: function () {
13
+ return this.name || 'process-terminate';
14
+ },
15
+ });
16
+ </script>
17
+
18
+ <script type="text/html" data-template-name="process-terminate">
19
+ <div class="form-row">
20
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
21
+ <input type="text" id="node-input-name" placeholder="Name" />
22
+ </div>
23
+ <div class="form-row">
24
+ <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
25
+ <input type="text" id="node-input-engine" placeholder="Engine-URL" />
26
+ </div>
27
+ </script>
28
+
29
+ <script type="text/markdown" data-help-name="process-terminate">
30
+ Terminate an instance of a process model in the ProcessCube.
31
+
32
+ ## Inputs
33
+
34
+ : payload (string): The id of the processinstance that is going to be terminated.
35
+
36
+ ## Outputs
37
+
38
+ : payload (string): The id of the processinstance that was terminated.
39
+
40
+ ### References
41
+
42
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
43
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
44
+
45
+ </script>
@@ -0,0 +1,27 @@
1
+ module.exports = function (RED) {
2
+ function ProcessTerminate(config) {
3
+ RED.nodes.createNode(this, config);
4
+ var node = this;
5
+
6
+ node.on('input', function (msg) {
7
+ const engine = RED.nodes.getNode(config.engine);
8
+ const client = engine.engineClient;
9
+
10
+ if (!client) {
11
+ node.error('No engine configured.');
12
+ return;
13
+ }
14
+
15
+ client.processInstances
16
+ .terminateProcessInstance(msg.payload, engine.identity)
17
+ .then(() => {
18
+ node.send(msg);
19
+ })
20
+ .catch((error) => {
21
+ node.error(error);
22
+ });
23
+ });
24
+ }
25
+
26
+ RED.nodes.registerType('process-terminate', ProcessTerminate);
27
+ };
@@ -61,7 +61,7 @@
61
61
  </script>
62
62
 
63
63
  <script type="text/markdown" data-help-name="processdefinition-query">
64
- Query process definitions or process models from the ProcessCube engine.
64
+ A node to query process definition on the ProcessCube Engine.
65
65
 
66
66
  The `query` can be given a direkt query field from the configutation or a message property.
67
67
 
@@ -71,6 +71,11 @@ Only models can be queried by setting the `models_only` flag.
71
71
 
72
72
  : payload (Object | JSON) : Will be used as the input for the query or can be directly set as JSON.
73
73
 
74
+ ## Outputs
75
+
76
+ : processDefinitions / models (Array) : The processDefinitions / models that matched the query.
77
+ : totalCount (number) : The number of matches.
78
+
74
79
  ### References
75
80
 
76
81
  - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
@@ -46,12 +46,17 @@
46
46
  </script>
47
47
 
48
48
  <script type="text/markdown" data-help-name="processinstance-query">
49
- Query a process instance in the ProcessCube.
49
+ A node to query process instances on the ProcessCube Engine.
50
50
 
51
51
  ## Inputs
52
52
 
53
53
  : payload (Object | JSON) : Will be used as the input for the query or can be directly set as JSON.
54
54
 
55
+ ## Outputs
56
+
57
+ : processInstances (Array) : The process instances that matched the query.
58
+ : totalCount (number) : The number of matches.
59
+
55
60
  ### References
56
61
 
57
62
  - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
@@ -6,7 +6,6 @@
6
6
  name: { value: '' },
7
7
  engine: { value: '', type: 'processcube-engine-config' },
8
8
  signalname: { value: '', required: true },
9
- processInstanceId: { value: '' },
10
9
  },
11
10
  inputs: 1,
12
11
  outputs: 1,
@@ -30,10 +29,7 @@
30
29
  <label for="node-input-signalname"><i class="fa fa-tag"></i> Signal Name</label>
31
30
  <input type="text" id="node-input-signalname" placeholder="Name of the Signal" />
32
31
  </div>
33
- <div class="form-row">
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" />
36
- </div>
32
+
37
33
  </script>
38
34
 
39
35
  <script type="text/markdown" data-help-name="signal-event-trigger">
@@ -44,6 +40,7 @@ From the config the `signalname` and the `processInstanceId` must be set.
44
40
  ## Inputs
45
41
 
46
42
  : payload (Object) : Will sent to the event and used an new token payload.
43
+ : processInstanceId (string) : The process instance where the signal event should be triggered.
47
44
 
48
45
  ### References
49
46
 
@@ -15,7 +15,7 @@ module.exports = function (RED) {
15
15
 
16
16
  client.events
17
17
  .triggerSignalEvent(config.signalname, {
18
- processInstanceId: config.processinstanceid,
18
+ processInstanceId: msg.processinstanceid,
19
19
  payload: msg.payload,
20
20
  identity: engine.identity,
21
21
  })
@@ -68,6 +68,12 @@ A node which listens for events triggered by usertasks
68
68
 
69
69
  ## Outputs
70
70
 
71
+ : flowNodeInstanceId (string): The unique identifier for the usertask instance.
72
+ : userTaskEvent (Object): An Object representing the event returned by the engine.
73
+ : processInstance (Object): An Object representing the process instance data.
74
+ : action (string): The event that occured.
75
+ : type (string): The target of the event.
76
+
71
77
  ### References
72
78
 
73
79
  - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
@@ -46,23 +46,25 @@ module.exports = function (RED) {
46
46
  }
47
47
 
48
48
  async function subscribe() {
49
- const eventHandlers = {
50
- new: () => client.userTasks.onUserTaskWaiting(userTaskCallback(), { identity: currentIdentity }),
51
- finished: () =>
52
- client.userTasks.onUserTaskFinished(userTaskCallback(), { identity: currentIdentity }),
53
- reserved: () =>
54
- client.userTasks.onUserTaskReserved(userTaskCallback(), { identity: currentIdentity }),
55
- 'reservation-canceled': () =>
56
- client.userTasks.onUserTaskReservationCanceled(userTaskCallback(), {
49
+ switch (config.eventtype) {
50
+ case 'new':
51
+ return await client.userTasks.onUserTaskWaiting(userTaskCallback(), {
57
52
  identity: currentIdentity,
58
- }),
59
- };
60
-
61
- const handler = eventHandlers[config.eventtype];
62
- if (handler) {
63
- return await handler();
64
- } else {
65
- console.error('no such event: ' + config.eventtype);
53
+ });
54
+ case 'finished':
55
+ return await client.userTasks.onUserTaskFinished(userTaskCallback(), {
56
+ identity: currentIdentity,
57
+ });
58
+ case 'reserved':
59
+ return await client.userTasks.onUserTaskReserved(userTaskCallback(), {
60
+ identity: currentIdentity,
61
+ });
62
+ case 'reservation-canceled':
63
+ return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback(), {
64
+ identity: currentIdentity,
65
+ });
66
+ default:
67
+ console.error('no such event: ' + config.eventtype);
66
68
  }
67
69
  }
68
70
 
@@ -10,6 +10,7 @@
10
10
  },
11
11
  inputs: 1,
12
12
  outputs: 1,
13
+ align: 'right',
13
14
  icon: 'usertask_output.svg',
14
15
  label: function () {
15
16
  return this.name || 'usertask-output';
@@ -55,7 +56,6 @@ A node which sends the result of a usertask to the ProcessCube.
55
56
 
56
57
  ### References
57
58
 
58
- - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
59
- - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
60
-
59
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
60
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
61
61
  </script>