@5minds/node-red-contrib-processcube 1.1.4-feature-80090b-m06aaj19 → 1.1.4-feature-285569-m0c23so4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('externaltask-event-listener', {
3
+ category: 'ProcessCube Events',
4
+ color: '#02AFD6',
5
+ defaults: {
6
+ name: { value: '' },
7
+ engine: { value: '', type: 'processcube-engine-config' },
8
+ externaltask: { value: '', required: false },
9
+ eventtype: { value: '', required: true },
10
+ },
11
+ inputs: 0,
12
+ outputs: 1,
13
+ icon: 'font-awesome/fa-sign-in',
14
+ label: function () {
15
+ return this.name || 'externaltask-event-listener';
16
+ },
17
+ });
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="externaltask-event-listener">
21
+ <div class="form-row">
22
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-input-name" placeholder="Name" />
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
27
+ <input type="text" id="node-input-engine" placeholder="http://engine:8000" />
28
+ </div>
29
+ <div class="form-row">
30
+ <label for="node-input-externaltask"><i class="fa fa-tag"></i> Externaltask</label>
31
+ <input type="text" id="node-input-externaltask" placeholder="ID of Externaltask" />
32
+ </div>
33
+ <div class="form-row">
34
+ <label for="node-input-eventtype"><i class="fa fa-sliders"></i> Event</label>
35
+ <select id="node-input-eventtype" style="width: 70%;">
36
+ <option value="created">created</option>
37
+ <option value="locked">locked</option>
38
+ <option value="unlocked">unlocked</option>
39
+ </select>
40
+ </div>
41
+ </script>
42
+
43
+ <script type="text/markdown" data-help-name="externaltask-event-listener">
44
+ A node which listens for events triggered by externaltasks
45
+
46
+ ## Outputs
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
+ </script>
@@ -0,0 +1,108 @@
1
+ module.exports = function (RED) {
2
+ function ExternalTaskEventListener(config) {
3
+ RED.nodes.createNode(this, config);
4
+ var node = this;
5
+ node.engine = RED.nodes.getNode(config.engine);
6
+
7
+ const register = async () => {
8
+ let currentIdentity = node.engine.identity;
9
+
10
+ const client = node.engine.engineClient;
11
+
12
+ if (!client) {
13
+ node.error('No engine configured.');
14
+ return;
15
+ }
16
+
17
+ let subscription;
18
+
19
+ async function subscribe() {
20
+ switch (config.eventtype) {
21
+ case 'created':
22
+ return await client.notification.onExternalTaskCreated(
23
+ (externalTaskNotification) => {
24
+ if (
25
+ config.externaltask != '' &&
26
+ config.externaltask != externalTaskNotification.flowNodeId
27
+ )
28
+ return;
29
+ node.send({
30
+ payload: {
31
+ flowNodeInstanceId: externalTaskNotification.flowNodeInstanceId,
32
+ externalTaskEvent: externalTaskNotification,
33
+ action: 'created',
34
+ type: 'externaltask',
35
+ },
36
+ });
37
+ },
38
+ { identity: currentIdentity }
39
+ );
40
+ case 'locked':
41
+ return await client.notification.onExternalTaskLocked(
42
+ (externalTaskNotification) => {
43
+ if (
44
+ config.externaltask != '' &&
45
+ config.externaltask != externalTaskNotification.flowNodeId
46
+ )
47
+ return;
48
+ node.send({
49
+ payload: {
50
+ flowNodeInstanceId: externalTaskNotification.flowNodeInstanceId,
51
+ externalTaskEvent: externalTaskNotification,
52
+ action: 'locked',
53
+ type: 'externaltask',
54
+ },
55
+ });
56
+ },
57
+ { identity: currentIdentity }
58
+ );
59
+ case 'unlocked':
60
+ return await client.notification.onExternalTaskUnlocked(
61
+ (externalTaskNotification) => {
62
+ if (
63
+ config.externaltask != '' &&
64
+ config.externaltask != externalTaskNotification.flowNodeId
65
+ )
66
+ return;
67
+ node.send({
68
+ payload: {
69
+ flowNodeInstanceId: externalTaskNotification.flowNodeInstanceId,
70
+ externalTaskEvent: externalTaskNotification,
71
+ action: 'unlocked',
72
+ type: 'externaltask',
73
+ },
74
+ });
75
+ },
76
+ { identity: currentIdentity }
77
+ );
78
+ default:
79
+ console.error('no such event: ' + config.eventtype);
80
+ }
81
+ }
82
+
83
+ if (node.engine.isIdentityReady()) {
84
+ subscription = subscribe();
85
+ }
86
+
87
+ node.engine.registerOnIdentityChanged(async (identity) => {
88
+ if (subscription) {
89
+ client.notification.removeSubscription(subscription, currentIdentity);
90
+ }
91
+ currentIdentity = identity;
92
+
93
+ subscription = subscribe();
94
+ });
95
+
96
+ node.on('close', async () => {
97
+ if (node.engine && node.engine.engineClient && client) {
98
+ client.notification.removeSubscription(subscription, currentIdentity);
99
+ }
100
+ });
101
+ };
102
+
103
+ if (node.engine) {
104
+ register();
105
+ }
106
+ }
107
+ RED.nodes.registerType('externaltask-event-listener', ExternalTaskEventListener);
108
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.1.4-feature-80090b-m06aaj19",
3
+ "version": "1.1.4-feature-285569-m0c23so4",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -39,14 +39,15 @@
39
39
  "externaltaskInput": "externaltask-input.js",
40
40
  "externaltaskOutput": "externaltask-output.js",
41
41
  "externaltaskError": "externaltask-error.js",
42
+ "externaltaskEventListener": "externaltask-event-listener.js",
42
43
  "processStart": "process-start.js",
43
- "processTerminate": "process-terminate.js",
44
44
  "processEventListener": "process-event-listener.js",
45
45
  "processcubeEngineConfig": "processcube-engine-config.js",
46
46
  "ProcessinstanceQuery": "processinstance-query.js",
47
47
  "ProcessdefinitionQuery": "processdefinition-query.js",
48
48
  "messageEventTrigger": "message-event-trigger.js",
49
49
  "signalEventTrigger": "signal-event-trigger.js",
50
+ "userTaskEventListener": "usertask-event-listener.js",
50
51
  "UserTaskNewListener": "usertask-new-listener.js",
51
52
  "UserTaskFinishedListener": "usertask-finished-listener.js",
52
53
  "UserTaskInput": "usertask-input.js",
@@ -0,0 +1,75 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('usertask-event-listener', {
3
+ category: 'ProcessCube Events',
4
+ color: '#02AFD6',
5
+ defaults: {
6
+ name: { value: '' },
7
+ engine: { value: '', type: 'processcube-engine-config' },
8
+ usertask: { value: '', required: false },
9
+ eventtype: { value: '', required: true },
10
+ query: { value: '{}' },
11
+ query_type: { value: 'json' },
12
+ },
13
+ inputs: 0,
14
+ outputs: 1,
15
+ icon: 'font-awesome/fa-sign-in',
16
+ label: function () {
17
+ return this.name || 'usertask-event-listener';
18
+ },
19
+ oneditprepare: function () {
20
+ $('#node-input-query').typedInput({
21
+ default: 'json',
22
+ types: ['json'],
23
+ });
24
+
25
+ $('#node-input-query').typedInput('value', this.query);
26
+ $('#node-input-query').typedInput('type', this.query_type);
27
+ },
28
+ oneditsave: function () {
29
+ if ($('#node-input-query').typedInput('value') == '') {
30
+ $('#node-input-query').typedInput('value', '{}')
31
+ }
32
+ (this.query = $('#node-input-query').typedInput('value')),
33
+ (this.query_type = $('#node-input-query').typedInput('type'));
34
+ },
35
+ });
36
+ </script>
37
+
38
+ <script type="text/html" data-template-name="usertask-event-listener">
39
+ <div class="form-row">
40
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
41
+ <input type="text" id="node-input-name" placeholder="Name" />
42
+ </div>
43
+ <div class="form-row">
44
+ <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
45
+ <input type="text" id="node-input-engine" placeholder="http://engine:8000" />
46
+ </div>
47
+ <div class="form-row">
48
+ <label for="node-input-usertask"><i class="fa fa-tag"></i> Usertask</label>
49
+ <input type="text" id="node-input-usertask" placeholder="ID of Usertask" />
50
+ </div>
51
+ <div class="form-row">
52
+ <label for="node-input-eventtype"><i class="fa fa-sliders"></i> Event</label>
53
+ <select id="node-input-eventtype" style="width: 70%;">
54
+ <option value="new">new</option>
55
+ <option value="finished">finished</option>
56
+ <option value="reserved">reserved</option>
57
+ <option value="reservation-canceled">reservation-canceled</option>
58
+ </select>
59
+ </div>
60
+ <div class="form-row">
61
+ <label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
62
+ <input type="text" id="node-input-query" />
63
+ </div>
64
+ </script>
65
+
66
+ <script type="text/markdown" data-help-name="usertask-event-listener">
67
+ A node which listens for events triggered by usertasks
68
+
69
+ ## Outputs
70
+
71
+ ### References
72
+
73
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
74
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
75
+ </script>
@@ -0,0 +1,187 @@
1
+ module.exports = function (RED) {
2
+ function UserTaskEventListener(config) {
3
+ RED.nodes.createNode(this, config);
4
+ var node = this;
5
+ node.engine = RED.nodes.getNode(config.engine);
6
+
7
+ const register = async () => {
8
+ let currentIdentity = node.engine.identity;
9
+
10
+ const client = node.engine.engineClient;
11
+
12
+ if (!client) {
13
+ node.error('No engine configured.');
14
+ return;
15
+ }
16
+
17
+ let subscription;
18
+ const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node);
19
+
20
+ async function filterAndSend(query) {
21
+ const newQuery = {
22
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
23
+ ...query,
24
+ };
25
+
26
+ const matchingFlowNodes = await client.userTasks.query(newQuery, {
27
+ identity: currentIdentity,
28
+ });
29
+
30
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
31
+ const userTask = matchingFlowNodes.userTasks[0];
32
+
33
+ node.send({
34
+ payload: { userTask: userTask },
35
+ });
36
+ }
37
+ }
38
+
39
+ async function subscribe() {
40
+ switch (config.eventtype) {
41
+ case 'new':
42
+ return await client.userTasks.onUserTaskWaiting(
43
+ async (userTaskNotification) => {
44
+ if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
45
+ const newQuery = {
46
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
47
+ ...query,
48
+ };
49
+
50
+ const matchingFlowNodes = await client.userTasks.query(newQuery, {
51
+ identity: currentIdentity,
52
+ });
53
+
54
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
55
+ const userTask = matchingFlowNodes.userTasks[0];
56
+
57
+ node.send({
58
+ payload: {
59
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
60
+ userTaskEvent: userTaskNotification,
61
+ userTask: userTask,
62
+ action: 'new',
63
+ type: 'usertask',
64
+ },
65
+ });
66
+ }
67
+ },
68
+ { identity: currentIdentity }
69
+ );
70
+ case 'finished':
71
+ return await client.userTasks.onUserTaskFinished(
72
+ async (userTaskNotification) => {
73
+ if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
74
+ const newQuery = {
75
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
76
+ ...query,
77
+ };
78
+
79
+ const matchingFlowNodes = await client.userTasks.query(newQuery, {
80
+ identity: currentIdentity,
81
+ });
82
+
83
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
84
+ const userTask = matchingFlowNodes.userTasks[0];
85
+
86
+ node.send({
87
+ payload: {
88
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
89
+ userTaskEvent: userTaskNotification,
90
+ userTask: userTask,
91
+ action: 'finished',
92
+ type: 'usertask',
93
+ },
94
+ });
95
+ }
96
+ },
97
+ { identity: currentIdentity }
98
+ );
99
+ case 'reserved':
100
+ return await client.userTasks.onUserTaskReserved(
101
+ async (userTaskNotification) => {
102
+ if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
103
+ const newQuery = {
104
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
105
+ ...query,
106
+ };
107
+
108
+ const matchingFlowNodes = await client.userTasks.query(newQuery, {
109
+ identity: currentIdentity,
110
+ });
111
+
112
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
113
+ const userTask = matchingFlowNodes.userTasks[0];
114
+
115
+ node.send({
116
+ payload: {
117
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
118
+ userTaskEvent: userTaskNotification,
119
+ userTask: userTask,
120
+ action: 'reserved',
121
+ type: 'usertask',
122
+ },
123
+ });
124
+ }
125
+ },
126
+ { identity: currentIdentity }
127
+ );
128
+ case 'reservation-canceled':
129
+ return await client.userTasks.onUserTaskReservationCanceled(
130
+ async (userTaskNotification) => {
131
+ if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
132
+ const newQuery = {
133
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
134
+ ...query,
135
+ };
136
+
137
+ const matchingFlowNodes = await client.userTasks.query(newQuery, {
138
+ identity: currentIdentity,
139
+ });
140
+
141
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
142
+ const userTask = matchingFlowNodes.userTasks[0];
143
+
144
+ node.send({
145
+ payload: {
146
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
147
+ userTaskEvent: userTaskNotification,
148
+ userTask: userTask,
149
+ action: 'reservation-canceled',
150
+ type: 'usertask',
151
+ },
152
+ });
153
+ }
154
+ },
155
+ { identity: currentIdentity }
156
+ );
157
+ default:
158
+ console.error('no such event: ' + config.eventtype);
159
+ }
160
+ }
161
+
162
+ if (node.engine.isIdentityReady()) {
163
+ subscription = subscribe();
164
+ }
165
+
166
+ node.engine.registerOnIdentityChanged(async (identity) => {
167
+ if (subscription) {
168
+ client.userTasks.removeSubscription(subscription, currentIdentity);
169
+ }
170
+ currentIdentity = identity;
171
+
172
+ subscription = subscribe();
173
+ });
174
+
175
+ node.on('close', async () => {
176
+ if (node.engine && node.engine.engineClient && client) {
177
+ client.userTasks.removeSubscription(subscription, currentIdentity);
178
+ }
179
+ });
180
+ };
181
+
182
+ if (node.engine) {
183
+ register();
184
+ }
185
+ }
186
+ RED.nodes.registerType('usertask-event-listener', UserTaskEventListener);
187
+ };
@@ -1,37 +0,0 @@
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
- ### 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
-
37
- </script>
@@ -1,27 +0,0 @@
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
- };
@@ -1,45 +0,0 @@
1
- <script type="text/javascript">
2
- RED.nodes.registerType('usertask-finished-listener', {
3
- category: 'ProcessCube Events',
4
- color: '#02AFD6',
5
- defaults: {
6
- name: { value: '' },
7
- engine: { value: '', type: 'processcube-engine-config' },
8
- multisend: { value: false },
9
- },
10
- inputs: 0,
11
- outputs: 1,
12
- icon: 'font-awesome/fa-envelope',
13
- label: function () {
14
- return this.name || 'usertask-finished-listener';
15
- },
16
- });
17
- </script>
18
-
19
- <script type="text/html" data-template-name="usertask-finished-listener">
20
- <div class="form-row">
21
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
22
- <input type="text" id="node-input-name" placeholder="Name" />
23
- </div>
24
- <div class="form-row">
25
- <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
26
- <input type="text" id="node-input-engine" placeholder="http://engine:8000" />
27
- </div>
28
- </script>
29
-
30
- <script type="text/markdown" data-help-name="usertask-finished-listener">
31
- A node which listens for finished usertasks in the ProcessCube.
32
-
33
- ## Outputs
34
-
35
- : flowNodeInstanceId (string): The flow node instance id of the finished usertask.
36
- : userTaskEvent (object): The user task event object.
37
- : action (string): The action of the event.
38
- : type (string): The type of the event.
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>
@@ -1,68 +0,0 @@
1
- module.exports = function (RED) {
2
- function UserTaskFinishedListener(config) {
3
- RED.nodes.createNode(this, config);
4
- var node = this;
5
- node.engine = RED.nodes.getNode(config.engine);
6
-
7
- const register = async () => {
8
- let currentIdentity = node.engine.identity;
9
-
10
- const client = node.engine.engineClient;
11
-
12
- if (!client) {
13
- node.error('No engine configured.');
14
- return;
15
- }
16
-
17
- let subscription;
18
-
19
- if (node.engine.isIdentityReady()) {
20
- subscription = await client.userTasks.onUserTaskFinished(
21
- (userTaskFinishedNotification) => {
22
- node.send({
23
- payload: {
24
- flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
25
- userTaskEvent: userTaskFinishedNotification,
26
- action: 'finished',
27
- type: 'usertask',
28
- },
29
- });
30
- },
31
- { identity: currentIdentity },
32
- );
33
- }
34
-
35
- node.engine.registerOnIdentityChanged(async (identity) => {
36
- if (subscription) {
37
- client.userTasks.removeSubscription(subscription, currentIdentity);
38
- }
39
- currentIdentity = identity;
40
-
41
- subscription = await client.userTasks.onUserTaskFinished(
42
- (userTaskFinishedNotification) => {
43
- node.send({
44
- payload: {
45
- flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
46
- userTaskEvent: userTaskFinishedNotification,
47
- action: 'finished',
48
- type: 'usertask',
49
- },
50
- });
51
- },
52
- { identity: currentIdentity },
53
- );
54
- });
55
-
56
- node.on('close', async () => {
57
- if (node.engine && node.engine.engineClient && client) {
58
- client.userTasks.removeSubscription(subscription, currentIdentity);
59
- }
60
- });
61
- };
62
-
63
- if (node.engine) {
64
- register();
65
- }
66
- }
67
- RED.nodes.registerType('usertask-finished-listener', UserTaskFinishedListener);
68
- };
@@ -1,45 +0,0 @@
1
- <script type="text/javascript">
2
- RED.nodes.registerType('usertask-new-listener', {
3
- category: 'ProcessCube Events',
4
- color: '#02AFD6',
5
- defaults: {
6
- name: { value: '' },
7
- engine: { value: '', type: 'processcube-engine-config' },
8
- multisend: { value: false },
9
- },
10
- inputs: 0,
11
- outputs: 1,
12
- icon: 'font-awesome/fa-envelope-open',
13
- label: function () {
14
- return this.name || 'usertask-new-listener';
15
- },
16
- });
17
- </script>
18
-
19
- <script type="text/html" data-template-name="usertask-new-listener">
20
- <div class="form-row">
21
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
22
- <input type="text" id="node-input-name" placeholder="Name" />
23
- </div>
24
- <div class="form-row">
25
- <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
26
- <input type="text" id="node-input-engine" placeholder="http://engine:8000" />
27
- </div>
28
- </script>
29
-
30
- <script type="text/markdown" data-help-name="usertask-new-listener">
31
- A node which listens for new usertasks in the ProcessCube.
32
-
33
- ## Outputs
34
-
35
- : flowNodeInstanceId (string): The flow node instance id of the new usertask.
36
- : userTaskEvent (string) : The user task event object.
37
- : action (string) : The action of the event.
38
- : type (string) : The type of the event.
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>
@@ -1,69 +0,0 @@
1
- module.exports = function (RED) {
2
- function UserTaskNewListener(config) {
3
- RED.nodes.createNode(this, config);
4
- var node = this;
5
- node.engine = RED.nodes.getNode(config.engine);
6
-
7
- const register = async () => {
8
- const client = node.engine.engineClient;
9
-
10
- if (!client) {
11
- node.error('No engine configured.');
12
- return;
13
- }
14
-
15
- let currentIdentity = node.engine.identity;
16
-
17
- let subscription;
18
-
19
- if (node.engine.isIdentityReady()) {
20
- subscription = await client.userTasks.onUserTaskWaiting(
21
- (userTaskWaitingNotification) => {
22
- node.send({
23
- payload: {
24
- flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
25
- userTaskEvent: userTaskWaitingNotification,
26
- action: 'new',
27
- type: 'usertask',
28
- },
29
- });
30
- },
31
- { identity: currentIdentity },
32
- );
33
- }
34
-
35
- node.engine.registerOnIdentityChanged(async (identity) => {
36
- if (subscription) {
37
- client.userTasks.removeSubscription(subscription, currentIdentity);
38
- }
39
-
40
- currentIdentity = identity;
41
-
42
- subscription = await client.userTasks.onUserTaskWaiting(
43
- (userTaskWaitingNotification) => {
44
- node.send({
45
- payload: {
46
- flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
47
- userTaskEvent: userTaskWaitingNotification,
48
- action: 'new',
49
- type: 'usertask',
50
- },
51
- });
52
- },
53
- { identity: currentIdentity },
54
- );
55
- });
56
-
57
- node.on('close', () => {
58
- if (node.engine && node.engine.engineClient && client) {
59
- client.userTasks.removeSubscription(subscription, currentIdentity);
60
- }
61
- });
62
- };
63
-
64
- if (node.engine) {
65
- register();
66
- }
67
- }
68
- RED.nodes.registerType('usertask-new-listener', UserTaskNewListener);
69
- };