@5minds/node-red-contrib-processcube 1.5.10-feature-56c707-m4mkrxn5 → 1.5.10-feature-1d5283-m4mr0aqw
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.
- package/endevent-finished-listener.js +5 -25
- package/externaltask-event-listener.js +5 -24
- package/message-event-trigger.js +0 -2
- package/package.json +1 -1
- package/process-event-listener.js +279 -385
- package/process-start.js +1 -1
- package/process-terminate.js +1 -1
- package/processcube-engine-config.js +6 -21
- package/processdefinition-query.js +23 -27
- package/processinstance-query.js +2 -2
- package/signal-event-trigger.js +1 -2
- package/usertask-event-listener.js +7 -30
- package/usertask-input.js +1 -5
- package/usertask-output.js +2 -2
- package/wait-for-usertask.js +26 -44
@@ -14,31 +14,11 @@ module.exports = function (RED) {
|
|
14
14
|
return;
|
15
15
|
}
|
16
16
|
|
17
|
-
let currentIdentity = node.engine.identity;
|
18
|
-
|
19
17
|
try {
|
20
|
-
subscription = await client.events.onEndEventFinished(
|
21
|
-
(
|
22
|
-
|
23
|
-
|
24
|
-
});
|
25
|
-
},
|
26
|
-
{ identity: currentIdentity }
|
27
|
-
);
|
28
|
-
|
29
|
-
node.engine.registerOnIdentityChanged(async (identity) => {
|
30
|
-
client.events.removeSubscription(subscription, currentIdentity);
|
31
|
-
|
32
|
-
currentIdentity = identity;
|
33
|
-
|
34
|
-
subscription = await client.events.onEndEventFinished(
|
35
|
-
(endEventFinished) => {
|
36
|
-
node.send({
|
37
|
-
payload: endEventFinished,
|
38
|
-
});
|
39
|
-
},
|
40
|
-
{ identity: currentIdentity }
|
41
|
-
);
|
18
|
+
subscription = await client.events.onEndEventFinished((endEventFinished) => {
|
19
|
+
node.send({
|
20
|
+
payload: endEventFinished,
|
21
|
+
});
|
42
22
|
});
|
43
23
|
} catch (error) {
|
44
24
|
node.error(error);
|
@@ -46,7 +26,7 @@ module.exports = function (RED) {
|
|
46
26
|
|
47
27
|
node.on('close', async () => {
|
48
28
|
if (node.engine && node.engine.engineClient && client) {
|
49
|
-
client.events.removeSubscription(subscription
|
29
|
+
client.events.removeSubscription(subscription);
|
50
30
|
}
|
51
31
|
});
|
52
32
|
};
|
@@ -7,8 +7,6 @@ module.exports = function (RED) {
|
|
7
7
|
let subscription;
|
8
8
|
|
9
9
|
const register = async () => {
|
10
|
-
let currentIdentity = node.engine.identity;
|
11
|
-
|
12
10
|
const client = node.engine.engineClient;
|
13
11
|
|
14
12
|
if (!client) {
|
@@ -33,38 +31,21 @@ module.exports = function (RED) {
|
|
33
31
|
async function subscribe() {
|
34
32
|
switch (config.eventtype) {
|
35
33
|
case 'created':
|
36
|
-
return await client.notification.onExternalTaskCreated(externalTaskCallback()
|
37
|
-
identity: currentIdentity,
|
38
|
-
});
|
34
|
+
return await client.notification.onExternalTaskCreated(externalTaskCallback());
|
39
35
|
case 'locked':
|
40
|
-
return await client.notification.onExternalTaskLocked(externalTaskCallback()
|
41
|
-
identity: currentIdentity,
|
42
|
-
});
|
36
|
+
return await client.notification.onExternalTaskLocked(externalTaskCallback());
|
43
37
|
case 'unlocked':
|
44
|
-
return await client.notification.onExternalTaskUnlocked(externalTaskCallback()
|
45
|
-
identity: currentIdentity,
|
46
|
-
});
|
38
|
+
return await client.notification.onExternalTaskUnlocked(externalTaskCallback());
|
47
39
|
default:
|
48
40
|
console.error('no such event: ' + config.eventtype);
|
49
41
|
}
|
50
42
|
}
|
51
43
|
|
52
|
-
|
53
|
-
subscription = subscribe();
|
54
|
-
}
|
55
|
-
|
56
|
-
node.engine.registerOnIdentityChanged(async (identity) => {
|
57
|
-
if (subscription) {
|
58
|
-
client.notification.removeSubscription(subscription, currentIdentity);
|
59
|
-
}
|
60
|
-
currentIdentity = identity;
|
61
|
-
|
62
|
-
subscription = subscribe();
|
63
|
-
});
|
44
|
+
subscription = subscribe();
|
64
45
|
|
65
46
|
node.on('close', async () => {
|
66
47
|
if (node.engine && node.engine.engineClient && client) {
|
67
|
-
client.notification.removeSubscription(subscription
|
48
|
+
client.notification.removeSubscription(subscription);
|
68
49
|
}
|
69
50
|
});
|
70
51
|
};
|
package/message-event-trigger.js
CHANGED
@@ -4,7 +4,6 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
8
7
|
node.engine = RED.nodes.getNode(config.engine);
|
9
8
|
const client = node.engine.engineClient;
|
10
9
|
|
@@ -17,7 +16,6 @@ module.exports = function (RED) {
|
|
17
16
|
.triggerMessageEvent(config.messagename, {
|
18
17
|
processInstanceId: msg.processinstanceid,
|
19
18
|
payload: msg.payload,
|
20
|
-
identity: node.engine.identity,
|
21
19
|
})
|
22
20
|
.then((result) => {
|
23
21
|
msg.payload = result;
|
package/package.json
CHANGED
@@ -14,442 +14,336 @@ module.exports = function (RED) {
|
|
14
14
|
return;
|
15
15
|
}
|
16
16
|
|
17
|
-
let currentIdentity = node.engine.identity;
|
18
|
-
|
19
17
|
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node);
|
20
18
|
|
21
19
|
async function subscribe(eventType) {
|
22
20
|
switch (eventType) {
|
23
21
|
case 'starting':
|
24
|
-
return await client.notification.onProcessStarting(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
return await client.notification.onProcessStarting(async (processNotification) => {
|
23
|
+
if (
|
24
|
+
config.processmodel != '' &&
|
25
|
+
config.processmodel != processNotification.processModelId
|
26
|
+
) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
|
30
|
+
const newQuery = {
|
31
|
+
processInstanceId: processNotification.processInstanceId,
|
32
|
+
...query,
|
33
|
+
};
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
...query,
|
36
|
-
};
|
35
|
+
try {
|
36
|
+
const matchingInstances = await client.processInstances.query(newQuery);
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
if (
|
39
|
+
matchingInstances.processInstances &&
|
40
|
+
matchingInstances.processInstances.length == 1
|
41
|
+
) {
|
42
|
+
const processInstance = matchingInstances.processInstances[0];
|
43
|
+
|
44
|
+
node.send({
|
45
|
+
payload: {
|
46
|
+
processInstanceId: processNotification.processInstanceId,
|
47
|
+
processModelId: processNotification.processModelId,
|
48
|
+
processInstance: processInstance,
|
49
|
+
action: 'starting',
|
50
|
+
type: 'processInstance',
|
51
|
+
},
|
41
52
|
});
|
42
|
-
|
43
|
-
if (
|
44
|
-
matchingInstances.processInstances &&
|
45
|
-
matchingInstances.processInstances.length == 1
|
46
|
-
) {
|
47
|
-
const processInstance = matchingInstances.processInstances[0];
|
48
|
-
|
49
|
-
node.send({
|
50
|
-
payload: {
|
51
|
-
processInstanceId: processNotification.processInstanceId,
|
52
|
-
processModelId: processNotification.processModelId,
|
53
|
-
processInstance: processInstance,
|
54
|
-
action: 'starting',
|
55
|
-
type: 'processInstance',
|
56
|
-
},
|
57
|
-
});
|
58
|
-
}
|
59
|
-
} catch (error) {
|
60
|
-
node.error(error);
|
61
53
|
}
|
62
|
-
}
|
63
|
-
|
64
|
-
|
54
|
+
} catch (error) {
|
55
|
+
node.error(error);
|
56
|
+
}
|
57
|
+
});
|
65
58
|
case 'started':
|
66
|
-
return await client.notification.onProcessStarted(
|
67
|
-
|
59
|
+
return await client.notification.onProcessStarted(async (processNotification) => {
|
60
|
+
if (
|
61
|
+
config.processmodel != '' &&
|
62
|
+
config.processmodel != processNotification.processModelId
|
63
|
+
) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
const newQuery = {
|
68
|
+
processInstanceId: processNotification.processInstanceId,
|
69
|
+
...query,
|
70
|
+
};
|
71
|
+
|
72
|
+
try {
|
73
|
+
const matchingInstances = await client.processInstances.query(newQuery);
|
74
|
+
|
68
75
|
if (
|
69
|
-
|
70
|
-
|
76
|
+
matchingInstances.processInstances &&
|
77
|
+
matchingInstances.processInstances.length == 1
|
71
78
|
) {
|
72
|
-
|
79
|
+
const processInstance = matchingInstances.processInstances[0];
|
80
|
+
node.send({
|
81
|
+
payload: {
|
82
|
+
processInstanceId: processNotification.processInstanceId,
|
83
|
+
processModelId: processNotification.processModelId,
|
84
|
+
flowNodeId: processNotification.flowNodeId,
|
85
|
+
token: processNotification.currentToken,
|
86
|
+
processInstance: processInstance,
|
87
|
+
action: 'started',
|
88
|
+
type: 'processInstance',
|
89
|
+
},
|
90
|
+
});
|
73
91
|
}
|
92
|
+
} catch (error) {
|
93
|
+
node.error(error);
|
94
|
+
}
|
95
|
+
});
|
96
|
+
case 'resumed':
|
97
|
+
return await client.notification.onProcessResumed(async (processNotification) => {
|
98
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
99
|
+
return;
|
74
100
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
101
|
+
const newQuery = {
|
102
|
+
processInstanceId: processNotification.processInstanceId,
|
103
|
+
...query,
|
104
|
+
};
|
79
105
|
|
80
|
-
|
81
|
-
|
82
|
-
identity: currentIdentity,
|
83
|
-
});
|
106
|
+
try {
|
107
|
+
const matchingInstances = await client.processInstances.query(newQuery);
|
84
108
|
|
85
|
-
if (
|
86
|
-
matchingInstances.processInstances &&
|
87
|
-
matchingInstances.processInstances.length == 1
|
88
|
-
) {
|
89
|
-
const processInstance = matchingInstances.processInstances[0];
|
90
|
-
node.send({
|
91
|
-
payload: {
|
92
|
-
processInstanceId: processNotification.processInstanceId,
|
93
|
-
processModelId: processNotification.processModelId,
|
94
|
-
flowNodeId: processNotification.flowNodeId,
|
95
|
-
token: processNotification.currentToken,
|
96
|
-
processInstance: processInstance,
|
97
|
-
action: 'started',
|
98
|
-
type: 'processInstance',
|
99
|
-
},
|
100
|
-
});
|
101
|
-
}
|
102
|
-
} catch (error) {
|
103
|
-
node.error(error);
|
104
|
-
}
|
105
|
-
},
|
106
|
-
{ identity: currentIdentity }
|
107
|
-
);
|
108
|
-
case 'resumed':
|
109
|
-
return await client.notification.onProcessResumed(
|
110
|
-
async (processNotification) => {
|
111
109
|
if (
|
112
|
-
|
113
|
-
|
114
|
-
)
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
110
|
+
matchingInstances.processInstances &&
|
111
|
+
matchingInstances.processInstances.length == 1
|
112
|
+
) {
|
113
|
+
const processInstance = matchingInstances.processInstances[0];
|
114
|
+
node.send({
|
115
|
+
payload: {
|
116
|
+
processInstanceId: processNotification.processInstanceId,
|
117
|
+
processModelId: processNotification.processModelId,
|
118
|
+
token: processNotification.currentToken,
|
119
|
+
processInstance: processInstance,
|
120
|
+
action: 'resumed',
|
121
|
+
type: 'processInstance',
|
122
|
+
},
|
125
123
|
});
|
126
|
-
|
127
|
-
if (
|
128
|
-
matchingInstances.processInstances &&
|
129
|
-
matchingInstances.processInstances.length == 1
|
130
|
-
) {
|
131
|
-
const processInstance = matchingInstances.processInstances[0];
|
132
|
-
node.send({
|
133
|
-
payload: {
|
134
|
-
processInstanceId: processNotification.processInstanceId,
|
135
|
-
processModelId: processNotification.processModelId,
|
136
|
-
token: processNotification.currentToken,
|
137
|
-
processInstance: processInstance,
|
138
|
-
action: 'resumed',
|
139
|
-
type: 'processInstance',
|
140
|
-
},
|
141
|
-
});
|
142
|
-
}
|
143
|
-
} catch (error) {
|
144
|
-
node.error(error);
|
145
124
|
}
|
146
|
-
}
|
147
|
-
|
148
|
-
|
125
|
+
} catch (error) {
|
126
|
+
node.error(error);
|
127
|
+
}
|
128
|
+
});
|
149
129
|
case 'finished':
|
150
|
-
return await client.notification.onProcessEnded(
|
151
|
-
|
130
|
+
return await client.notification.onProcessEnded(async (processNotification) => {
|
131
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
132
|
+
return;
|
133
|
+
|
134
|
+
const newQuery = {
|
135
|
+
processInstanceId: processNotification.processInstanceId,
|
136
|
+
...query,
|
137
|
+
};
|
138
|
+
|
139
|
+
try {
|
140
|
+
const matchingInstances = await client.processInstances.query(newQuery);
|
141
|
+
|
152
142
|
if (
|
153
|
-
|
154
|
-
|
155
|
-
)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
143
|
+
matchingInstances.processInstances &&
|
144
|
+
matchingInstances.processInstances.length == 1
|
145
|
+
) {
|
146
|
+
const processInstance = matchingInstances.processInstances[0];
|
147
|
+
node.send({
|
148
|
+
payload: {
|
149
|
+
processInstanceId: processNotification.processInstanceId,
|
150
|
+
processModelId: processNotification.processModelId,
|
151
|
+
flowNodeId: processNotification.flowNodeId,
|
152
|
+
token: processNotification.currentToken,
|
153
|
+
processInstance: processInstance,
|
154
|
+
action: 'finished',
|
155
|
+
type: 'processInstance',
|
156
|
+
},
|
166
157
|
});
|
167
|
-
|
168
|
-
if (
|
169
|
-
matchingInstances.processInstances &&
|
170
|
-
matchingInstances.processInstances.length == 1
|
171
|
-
) {
|
172
|
-
const processInstance = matchingInstances.processInstances[0];
|
173
|
-
node.send({
|
174
|
-
payload: {
|
175
|
-
processInstanceId: processNotification.processInstanceId,
|
176
|
-
processModelId: processNotification.processModelId,
|
177
|
-
flowNodeId: processNotification.flowNodeId,
|
178
|
-
token: processNotification.currentToken,
|
179
|
-
processInstance: processInstance,
|
180
|
-
action: 'finished',
|
181
|
-
type: 'processInstance',
|
182
|
-
},
|
183
|
-
});
|
184
|
-
}
|
185
|
-
} catch (error) {
|
186
|
-
node.error(error);
|
187
158
|
}
|
188
|
-
}
|
189
|
-
|
190
|
-
|
159
|
+
} catch (error) {
|
160
|
+
node.error(error);
|
161
|
+
}
|
162
|
+
});
|
191
163
|
case 'terminated':
|
192
|
-
return await client.notification.onProcessTerminated(
|
193
|
-
|
164
|
+
return await client.notification.onProcessTerminated(async (processNotification) => {
|
165
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
166
|
+
return;
|
167
|
+
|
168
|
+
const newQuery = {
|
169
|
+
processInstanceId: processNotification.processInstanceId,
|
170
|
+
...query,
|
171
|
+
};
|
172
|
+
|
173
|
+
try {
|
174
|
+
const matchingInstances = await client.processInstances.query(newQuery);
|
194
175
|
if (
|
195
|
-
|
196
|
-
|
197
|
-
)
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
176
|
+
matchingInstances.processInstances &&
|
177
|
+
matchingInstances.processInstances.length == 1
|
178
|
+
) {
|
179
|
+
const processInstance = matchingInstances.processInstances[0];
|
180
|
+
node.send({
|
181
|
+
payload: {
|
182
|
+
processInstanceId: processNotification.processInstanceId,
|
183
|
+
processModelId: processNotification.processModelId,
|
184
|
+
token: processNotification.currentToken,
|
185
|
+
processInstance: processInstance,
|
186
|
+
action: 'terminated',
|
187
|
+
type: 'processInstance',
|
188
|
+
},
|
208
189
|
});
|
209
|
-
if (
|
210
|
-
matchingInstances.processInstances &&
|
211
|
-
matchingInstances.processInstances.length == 1
|
212
|
-
) {
|
213
|
-
const processInstance = matchingInstances.processInstances[0];
|
214
|
-
node.send({
|
215
|
-
payload: {
|
216
|
-
processInstanceId: processNotification.processInstanceId,
|
217
|
-
processModelId: processNotification.processModelId,
|
218
|
-
token: processNotification.currentToken,
|
219
|
-
processInstance: processInstance,
|
220
|
-
action: 'terminated',
|
221
|
-
type: 'processInstance',
|
222
|
-
},
|
223
|
-
});
|
224
|
-
}
|
225
|
-
} catch (error) {
|
226
|
-
node.error(error);
|
227
190
|
}
|
228
|
-
}
|
229
|
-
|
230
|
-
|
191
|
+
} catch (error) {
|
192
|
+
node.error(error);
|
193
|
+
}
|
194
|
+
});
|
231
195
|
case 'error':
|
232
|
-
return await client.notification.onProcessError(
|
233
|
-
|
196
|
+
return await client.notification.onProcessError(async (processNotification) => {
|
197
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
198
|
+
return;
|
199
|
+
|
200
|
+
const newQuery = {
|
201
|
+
processInstanceId: processNotification.processInstanceId,
|
202
|
+
...query,
|
203
|
+
};
|
204
|
+
|
205
|
+
try {
|
206
|
+
const matchingInstances = await client.processInstances.query(newQuery);
|
207
|
+
|
234
208
|
if (
|
235
|
-
|
236
|
-
|
237
|
-
)
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
209
|
+
matchingInstances.processInstances &&
|
210
|
+
matchingInstances.processInstances.length == 1
|
211
|
+
) {
|
212
|
+
const processInstance = matchingInstances.processInstances[0];
|
213
|
+
node.send({
|
214
|
+
payload: {
|
215
|
+
processInstanceId: processNotification.processInstanceId,
|
216
|
+
processModelId: processNotification.processModelId,
|
217
|
+
token: processNotification.currentToken,
|
218
|
+
processInstance: processInstance,
|
219
|
+
action: 'error',
|
220
|
+
type: 'processInstance',
|
221
|
+
},
|
248
222
|
});
|
249
|
-
|
250
|
-
if (
|
251
|
-
matchingInstances.processInstances &&
|
252
|
-
matchingInstances.processInstances.length == 1
|
253
|
-
) {
|
254
|
-
const processInstance = matchingInstances.processInstances[0];
|
255
|
-
node.send({
|
256
|
-
payload: {
|
257
|
-
processInstanceId: processNotification.processInstanceId,
|
258
|
-
processModelId: processNotification.processModelId,
|
259
|
-
token: processNotification.currentToken,
|
260
|
-
processInstance: processInstance,
|
261
|
-
action: 'error',
|
262
|
-
type: 'processInstance',
|
263
|
-
},
|
264
|
-
});
|
265
|
-
}
|
266
|
-
} catch (error) {
|
267
|
-
node.error(error);
|
268
223
|
}
|
269
|
-
}
|
270
|
-
|
271
|
-
|
224
|
+
} catch (error) {
|
225
|
+
node.error(error);
|
226
|
+
}
|
227
|
+
});
|
272
228
|
case 'owner-changed':
|
273
|
-
return await client.notification.onProcessOwnerChanged(
|
274
|
-
|
229
|
+
return await client.notification.onProcessOwnerChanged(async (processNotification) => {
|
230
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
231
|
+
return;
|
232
|
+
|
233
|
+
const newQuery = {
|
234
|
+
processInstanceId: processNotification.processInstanceId,
|
235
|
+
...query,
|
236
|
+
};
|
237
|
+
|
238
|
+
try {
|
239
|
+
const matchingInstances = await client.processInstances.query(newQuery);
|
240
|
+
|
275
241
|
if (
|
276
|
-
|
277
|
-
|
278
|
-
)
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
identity: currentIdentity,
|
242
|
+
matchingInstances.processInstances &&
|
243
|
+
matchingInstances.processInstances.length == 1
|
244
|
+
) {
|
245
|
+
const processInstance = matchingInstances.processInstances[0];
|
246
|
+
node.send({
|
247
|
+
payload: {
|
248
|
+
processInstanceId: processNotification.processInstanceId,
|
249
|
+
processModelId: processNotification.processModelId,
|
250
|
+
processInstance: processInstance,
|
251
|
+
action: 'owner-changed',
|
252
|
+
type: 'processInstance',
|
253
|
+
},
|
289
254
|
});
|
290
|
-
|
291
|
-
if (
|
292
|
-
matchingInstances.processInstances &&
|
293
|
-
matchingInstances.processInstances.length == 1
|
294
|
-
) {
|
295
|
-
const processInstance = matchingInstances.processInstances[0];
|
296
|
-
node.send({
|
297
|
-
payload: {
|
298
|
-
processInstanceId: processNotification.processInstanceId,
|
299
|
-
processModelId: processNotification.processModelId,
|
300
|
-
processInstance: processInstance,
|
301
|
-
action: 'owner-changed',
|
302
|
-
type: 'processInstance',
|
303
|
-
},
|
304
|
-
});
|
305
|
-
}
|
306
|
-
} catch (error) {
|
307
|
-
node.error(error);
|
308
255
|
}
|
309
|
-
}
|
310
|
-
|
311
|
-
|
256
|
+
} catch (error) {
|
257
|
+
node.error(error);
|
258
|
+
}
|
259
|
+
});
|
312
260
|
case 'instances-deleted':
|
313
|
-
return await client.notification.onProcessInstancesDeleted(
|
314
|
-
|
315
|
-
|
316
|
-
config.processmodel != '' &&
|
317
|
-
config.processmodel != processNotification.processModelId
|
318
|
-
)
|
319
|
-
return;
|
320
|
-
|
321
|
-
const newQuery = {
|
322
|
-
processInstanceId: processNotification.processInstanceId,
|
323
|
-
...query,
|
324
|
-
};
|
325
|
-
|
326
|
-
try {
|
327
|
-
const matchingInstances = await client.processInstances.query(newQuery, {
|
328
|
-
identity: currentIdentity,
|
329
|
-
});
|
261
|
+
return await client.notification.onProcessInstancesDeleted(async (processNotification) => {
|
262
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
263
|
+
return;
|
330
264
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
const processInstance = matchingInstances.processInstances[0];
|
336
|
-
node.send({
|
337
|
-
payload: {
|
338
|
-
processInstanceId: processNotification.processInstanceId,
|
339
|
-
processModelId: processNotification.processModelId,
|
340
|
-
processInstance: processInstance,
|
341
|
-
action: 'instances-deleted',
|
342
|
-
type: 'processInstance',
|
343
|
-
},
|
344
|
-
});
|
345
|
-
}
|
346
|
-
} catch (error) {
|
347
|
-
node.error(error);
|
348
|
-
}
|
349
|
-
},
|
350
|
-
{ identity: currentIdentity }
|
351
|
-
);
|
352
|
-
case 'is-executable-changed':
|
353
|
-
return await client.notification.onProcessIsExecutableChanged(
|
354
|
-
(processNotification) => {
|
265
|
+
const newQuery = {
|
266
|
+
processInstanceId: processNotification.processInstanceId,
|
267
|
+
...query,
|
268
|
+
};
|
355
269
|
|
356
|
-
|
270
|
+
try {
|
271
|
+
const matchingInstances = await client.processInstances.query(newQuery);
|
357
272
|
|
358
273
|
if (
|
359
|
-
|
360
|
-
|
361
|
-
)
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
274
|
+
matchingInstances.processInstances &&
|
275
|
+
matchingInstances.processInstances.length == 1
|
276
|
+
) {
|
277
|
+
const processInstance = matchingInstances.processInstances[0];
|
278
|
+
node.send({
|
279
|
+
payload: {
|
280
|
+
processInstanceId: processNotification.processInstanceId,
|
281
|
+
processModelId: processNotification.processModelId,
|
282
|
+
processInstance: processInstance,
|
283
|
+
action: 'instances-deleted',
|
284
|
+
type: 'processInstance',
|
285
|
+
},
|
286
|
+
});
|
287
|
+
}
|
288
|
+
} catch (error) {
|
289
|
+
node.error(error);
|
290
|
+
}
|
291
|
+
});
|
292
|
+
case 'is-executable-changed':
|
293
|
+
return await client.notification.onProcessIsExecutableChanged((processNotification) => {
|
294
|
+
node.log(
|
295
|
+
'processNotification (is-executable-changed): ' + JSON.stringify(processNotification)
|
296
|
+
);
|
297
|
+
|
298
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
299
|
+
return;
|
300
|
+
node.send({
|
301
|
+
payload: {
|
302
|
+
processModelId: processNotification.processModelId,
|
303
|
+
action: 'is-executable-changed',
|
304
|
+
type: 'processModel',
|
305
|
+
},
|
306
|
+
});
|
307
|
+
});
|
373
308
|
case 'deployed':
|
374
|
-
return await client.notification.onProcessDeployed(
|
375
|
-
(processNotification)
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
action: 'deployed',
|
388
|
-
type: 'processModel',
|
389
|
-
},
|
390
|
-
});
|
391
|
-
},
|
392
|
-
{ identity: currentIdentity }
|
393
|
-
);
|
309
|
+
return await client.notification.onProcessDeployed((processNotification) => {
|
310
|
+
node.log('processNotification (deployed): ' + JSON.stringify(processNotification));
|
311
|
+
|
312
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
313
|
+
return;
|
314
|
+
node.send({
|
315
|
+
payload: {
|
316
|
+
processModelId: processNotification.processModelId,
|
317
|
+
action: 'deployed',
|
318
|
+
type: 'processModel',
|
319
|
+
},
|
320
|
+
});
|
321
|
+
});
|
394
322
|
case 'undeployed':
|
395
|
-
return await client.notification.onProcessUndeployed(
|
396
|
-
(processNotification)
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
action: 'undeployed',
|
409
|
-
type: 'processModel',
|
410
|
-
},
|
411
|
-
});
|
412
|
-
},
|
413
|
-
{ identity: currentIdentity }
|
414
|
-
);
|
323
|
+
return await client.notification.onProcessUndeployed((processNotification) => {
|
324
|
+
node.log('processNotification (undeployed): ' + JSON.stringify(processNotification));
|
325
|
+
|
326
|
+
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
327
|
+
return;
|
328
|
+
node.send({
|
329
|
+
payload: {
|
330
|
+
processModelId: processNotification.processModelId,
|
331
|
+
action: 'undeployed',
|
332
|
+
type: 'processModel',
|
333
|
+
},
|
334
|
+
});
|
335
|
+
});
|
415
336
|
default:
|
416
337
|
console.error('no such event: ' + eventType);
|
417
338
|
break;
|
418
339
|
}
|
419
340
|
}
|
420
341
|
|
421
|
-
|
422
|
-
subscription = await subscribe(config.eventtype);
|
423
|
-
}
|
424
|
-
|
425
|
-
node.engine.registerOnIdentityChanged(async (identity) => {
|
426
|
-
if (subscription) {
|
427
|
-
client.notification.removeSubscription(subscription, currentIdentity);
|
428
|
-
}
|
429
|
-
|
430
|
-
currentIdentity = identity;
|
431
|
-
|
432
|
-
subscription = await client.notification.onProcessResumed(
|
433
|
-
(processNotification) => {
|
434
|
-
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
|
435
|
-
return;
|
436
|
-
node.send({
|
437
|
-
payload: {
|
438
|
-
processInstanceId: processNotification.processInstanceId,
|
439
|
-
processModelId: processNotification.processModelId,
|
440
|
-
token: processNotification.currentToken,
|
441
|
-
action: 'resumed',
|
442
|
-
type: 'processInstance',
|
443
|
-
},
|
444
|
-
});
|
445
|
-
},
|
446
|
-
{ identity: currentIdentity }
|
447
|
-
);
|
448
|
-
});
|
342
|
+
subscription = await subscribe(config.eventtype);
|
449
343
|
|
450
344
|
node.on('close', () => {
|
451
345
|
if (node.engine && node.engine.engineClient && client) {
|
452
|
-
client.notification.removeSubscription(subscription
|
346
|
+
client.notification.removeSubscription(subscription);
|
453
347
|
}
|
454
348
|
});
|
455
349
|
};
|
package/process-start.js
CHANGED
package/process-terminate.js
CHANGED
@@ -35,29 +35,14 @@ module.exports = function (RED) {
|
|
35
35
|
}
|
36
36
|
};
|
37
37
|
|
38
|
-
node.log(`luis555: ${node.url}`)
|
39
|
-
|
40
38
|
if (node.credentials.clientId && node.credentials.clientSecret) {
|
41
|
-
node.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
clientSecret: node.credentials.clientSecret,
|
47
|
-
scope: 'engine_etw engine_read engine_write'
|
48
|
-
});
|
49
|
-
node.log("luis7777")
|
50
|
-
}catch (e) {
|
51
|
-
node.error(JSON.stringify(e))
|
52
|
-
}
|
39
|
+
node.engineClient = new engine_client.EngineClient(node.url, {
|
40
|
+
clientId: node.credentials.clientId,
|
41
|
+
clientSecret: node.credentials.clientSecret,
|
42
|
+
scope: 'engine_etw engine_read engine_write',
|
43
|
+
});
|
53
44
|
} else {
|
54
|
-
|
55
|
-
|
56
|
-
node.log("luis999")
|
57
|
-
node.engineClient = new engine_client.EngineClient(node.url);
|
58
|
-
} catch(e) {
|
59
|
-
node.error(JSON.stringify(e))
|
60
|
-
}
|
45
|
+
node.engineClient = new engine_client.EngineClient(node.url);
|
61
46
|
}
|
62
47
|
|
63
48
|
node.on('close', async () => {
|
@@ -4,7 +4,6 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
8
7
|
node.engine = RED.nodes.getNode(config.engine);
|
9
8
|
const client = engine.engineClient;
|
10
9
|
|
@@ -14,37 +13,34 @@ module.exports = function (RED) {
|
|
14
13
|
}
|
15
14
|
|
16
15
|
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
17
|
-
|
18
|
-
query = {
|
19
|
-
...query,
|
20
|
-
identity: node.engine.identity,
|
21
|
-
};
|
22
16
|
|
23
17
|
node.log(`Querying process definitions with query: ${JSON.stringify(query)}`);
|
24
|
-
|
25
|
-
client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
|
26
18
|
|
27
|
-
|
28
|
-
|
19
|
+
client.processDefinitions
|
20
|
+
.getAll(query)
|
21
|
+
.then((matchingProcessDefinitions) => {
|
22
|
+
if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
|
23
|
+
let models = [];
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
matchingProcessDefinitions.processDefinitions.forEach((processDefinition) => {
|
26
|
+
processDefinition.processModels.forEach((model) => {
|
27
|
+
models.push(model);
|
28
|
+
});
|
33
29
|
});
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
30
|
+
|
31
|
+
msg.payload = {
|
32
|
+
models: models,
|
33
|
+
totalCount: models.length,
|
34
|
+
};
|
35
|
+
} else {
|
36
|
+
msg.payload = matchingProcessDefinitions;
|
37
|
+
}
|
38
|
+
|
39
|
+
node.send(msg);
|
40
|
+
})
|
41
|
+
.catch((error) => {
|
42
|
+
node.error(error);
|
43
|
+
});
|
48
44
|
});
|
49
45
|
}
|
50
46
|
RED.nodes.registerType('processdefinition-query', ProcessdefinitionQuery);
|
package/processinstance-query.js
CHANGED
@@ -6,7 +6,7 @@ module.exports = function (RED) {
|
|
6
6
|
node.on('input', function (msg) {
|
7
7
|
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
8
8
|
|
9
|
-
node.engine =
|
9
|
+
node.engine = RED.nodes.getNode(config.engine);
|
10
10
|
const client = node.engine.engineClient;
|
11
11
|
|
12
12
|
if (!client) {
|
@@ -15,7 +15,7 @@ module.exports = function (RED) {
|
|
15
15
|
}
|
16
16
|
|
17
17
|
client.processInstances
|
18
|
-
.query(query
|
18
|
+
.query(query)
|
19
19
|
.then((matchingInstances) => {
|
20
20
|
msg.payload = matchingInstances;
|
21
21
|
|
package/signal-event-trigger.js
CHANGED
@@ -12,12 +12,11 @@ module.exports = function (RED) {
|
|
12
12
|
node.error('No engine configured.');
|
13
13
|
return;
|
14
14
|
}
|
15
|
-
|
15
|
+
|
16
16
|
client.events
|
17
17
|
.triggerSignalEvent(config.signalname, {
|
18
18
|
processInstanceId: msg.processinstanceid,
|
19
19
|
payload: msg.payload,
|
20
|
-
identity: node.engine.identity,
|
21
20
|
})
|
22
21
|
.then((result) => {
|
23
22
|
msg.payload = result;
|
@@ -7,8 +7,6 @@ module.exports = function (RED) {
|
|
7
7
|
let subscription;
|
8
8
|
|
9
9
|
const register = async () => {
|
10
|
-
let currentIdentity = node.engine.identity;
|
11
|
-
|
12
10
|
const client = node.engine.engineClient;
|
13
11
|
|
14
12
|
if (!client) {
|
@@ -28,9 +26,7 @@ module.exports = function (RED) {
|
|
28
26
|
};
|
29
27
|
|
30
28
|
try {
|
31
|
-
const matchingFlowNodes = await client.userTasks.query(newQuery
|
32
|
-
identity: currentIdentity,
|
33
|
-
});
|
29
|
+
const matchingFlowNodes = await client.userTasks.query(newQuery);
|
34
30
|
|
35
31
|
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
36
32
|
const userTask = matchingFlowNodes.userTasks[0];
|
@@ -54,42 +50,23 @@ module.exports = function (RED) {
|
|
54
50
|
async function subscribe() {
|
55
51
|
switch (config.eventtype) {
|
56
52
|
case 'new':
|
57
|
-
return await client.userTasks.onUserTaskWaiting(userTaskCallback()
|
58
|
-
identity: currentIdentity,
|
59
|
-
});
|
53
|
+
return await client.userTasks.onUserTaskWaiting(userTaskCallback());
|
60
54
|
case 'finished':
|
61
|
-
return await client.userTasks.onUserTaskFinished(userTaskCallback()
|
62
|
-
identity: currentIdentity,
|
63
|
-
});
|
55
|
+
return await client.userTasks.onUserTaskFinished(userTaskCallback());
|
64
56
|
case 'reserved':
|
65
|
-
return await client.userTasks.onUserTaskReserved(userTaskCallback()
|
66
|
-
identity: currentIdentity,
|
67
|
-
});
|
57
|
+
return await client.userTasks.onUserTaskReserved(userTaskCallback());
|
68
58
|
case 'reservation-canceled':
|
69
|
-
return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback()
|
70
|
-
identity: currentIdentity,
|
71
|
-
});
|
59
|
+
return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback());
|
72
60
|
default:
|
73
61
|
console.error('no such event: ' + config.eventtype);
|
74
62
|
}
|
75
63
|
}
|
76
64
|
|
77
|
-
|
78
|
-
subscription = subscribe();
|
79
|
-
}
|
80
|
-
|
81
|
-
node.engine.registerOnIdentityChanged(async (identity) => {
|
82
|
-
if (subscription) {
|
83
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
84
|
-
}
|
85
|
-
currentIdentity = identity;
|
86
|
-
|
87
|
-
subscription = subscribe();
|
88
|
-
});
|
65
|
+
subscription = subscribe();
|
89
66
|
|
90
67
|
node.on('close', async () => {
|
91
68
|
if (node.engine && node.engine.engineClient && client) {
|
92
|
-
client.userTasks.removeSubscription(subscription
|
69
|
+
client.userTasks.removeSubscription(subscription);
|
93
70
|
}
|
94
71
|
});
|
95
72
|
};
|
package/usertask-input.js
CHANGED
@@ -15,12 +15,8 @@ module.exports = function (RED) {
|
|
15
15
|
|
16
16
|
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
17
17
|
|
18
|
-
query = {
|
19
|
-
...query,
|
20
|
-
};
|
21
|
-
|
22
18
|
client.userTasks
|
23
|
-
.query(query
|
19
|
+
.query(query)
|
24
20
|
.then((matchingFlowNodes) => {
|
25
21
|
if (config.sendtype === 'array') {
|
26
22
|
msg.payload = { userTasks: matchingFlowNodes.userTasks || [] };
|
package/usertask-output.js
CHANGED
@@ -17,9 +17,9 @@ module.exports = function (RED) {
|
|
17
17
|
node.error('No engine configured.');
|
18
18
|
return;
|
19
19
|
}
|
20
|
-
|
20
|
+
|
21
21
|
client.userTasks
|
22
|
-
.finishUserTask(flowNodeInstanceId, userTaskResult
|
22
|
+
.finishUserTask(flowNodeInstanceId, userTaskResult)
|
23
23
|
.then(() => {
|
24
24
|
node.send(msg);
|
25
25
|
})
|
package/wait-for-usertask.js
CHANGED
@@ -6,7 +6,6 @@ module.exports = function (RED) {
|
|
6
6
|
node.engine = RED.nodes.getNode(config.engine);
|
7
7
|
|
8
8
|
let subscription = null;
|
9
|
-
let currentIdentity = node.engine.identity;
|
10
9
|
let subscribe = null;
|
11
10
|
|
12
11
|
node.on('input', async function (msg) {
|
@@ -19,35 +18,30 @@ module.exports = function (RED) {
|
|
19
18
|
|
20
19
|
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
21
20
|
|
22
|
-
subscription = await client.userTasks.onUserTaskWaiting(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
node.send(msg);
|
42
|
-
} else {
|
43
|
-
// nothing todo - wait for next notification
|
44
|
-
}
|
45
|
-
} catch (error) {
|
46
|
-
node.error(error);
|
21
|
+
subscription = await client.userTasks.onUserTaskWaiting(async (userTaskWaitingNotification) => {
|
22
|
+
const newQuery = {
|
23
|
+
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
24
|
+
...query,
|
25
|
+
};
|
26
|
+
|
27
|
+
try {
|
28
|
+
const matchingFlowNodes = await client.userTasks.query(newQuery);
|
29
|
+
|
30
|
+
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
31
|
+
// remove subscription
|
32
|
+
client.userTasks.removeSubscription(subscription);
|
33
|
+
|
34
|
+
const userTask = matchingFlowNodes.userTasks[0];
|
35
|
+
|
36
|
+
msg.payload = { userTask: userTask };
|
37
|
+
node.send(msg);
|
38
|
+
} else {
|
39
|
+
// nothing todo - wait for next notification
|
47
40
|
}
|
48
|
-
}
|
49
|
-
|
50
|
-
|
41
|
+
} catch (error) {
|
42
|
+
node.error(error);
|
43
|
+
}
|
44
|
+
});
|
51
45
|
|
52
46
|
node.log({ 'Handling old userTasks config.only_for_new': config.only_for_new });
|
53
47
|
|
@@ -59,9 +53,7 @@ module.exports = function (RED) {
|
|
59
53
|
};
|
60
54
|
|
61
55
|
try {
|
62
|
-
const matchingFlowNodes = await client.userTasks.query(suspendedQuery
|
63
|
-
identity: currentIdentity,
|
64
|
-
});
|
56
|
+
const matchingFlowNodes = await client.userTasks.query(suspendedQuery);
|
65
57
|
|
66
58
|
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
|
67
59
|
const userTask = matchingFlowNodes.userTasks[0];
|
@@ -70,7 +62,7 @@ module.exports = function (RED) {
|
|
70
62
|
node.send(msg);
|
71
63
|
|
72
64
|
// remove subscription
|
73
|
-
client.userTasks.removeSubscription(subscription
|
65
|
+
client.userTasks.removeSubscription(subscription);
|
74
66
|
} else {
|
75
67
|
// let the *currentIdentity* be active
|
76
68
|
}
|
@@ -83,19 +75,9 @@ module.exports = function (RED) {
|
|
83
75
|
subscribe();
|
84
76
|
});
|
85
77
|
|
86
|
-
node.engine.registerOnIdentityChanged(async (identity) => {
|
87
|
-
if (subscription) {
|
88
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
89
|
-
currentIdentity = identity;
|
90
|
-
subscribe();
|
91
|
-
} else {
|
92
|
-
currentIdentity = identity;
|
93
|
-
}
|
94
|
-
});
|
95
|
-
|
96
78
|
node.on('close', async () => {
|
97
79
|
if (client != null && subscription != null) {
|
98
|
-
client.userTasks.removeSubscription(subscription
|
80
|
+
client.userTasks.removeSubscription(subscription);
|
99
81
|
}
|
100
82
|
});
|
101
83
|
}
|