@5minds/node-red-contrib-processcube 1.1.4-feature-19cce1-m0gp9iou → 1.1.4-feature-e7d879-m0jyro4t
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/externaltask-event-listener.js +25 -60
- package/package.json +1 -1
- package/usertask-event-listener.js +39 -118
@@ -16,67 +16,32 @@ module.exports = function (RED) {
|
|
16
16
|
|
17
17
|
let subscription;
|
18
18
|
|
19
|
+
function externalTaskCallback() {
|
20
|
+
return (externalTaskNotification) => {
|
21
|
+
if (config.externaltask != '' && config.externaltask != externalTaskNotification.flowNodeId) return;
|
22
|
+
node.send({
|
23
|
+
payload: {
|
24
|
+
flowNodeInstanceId: externalTaskNotification.flowNodeInstanceId,
|
25
|
+
externalTaskEvent: externalTaskNotification,
|
26
|
+
action: config.eventtype,
|
27
|
+
type: 'externaltask',
|
28
|
+
},
|
29
|
+
});
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
19
33
|
async function subscribe() {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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);
|
34
|
+
const eventHandlers = {
|
35
|
+
created: client.notification.onExternalTaskCreated,
|
36
|
+
locked: client.notification.onExternalTaskLocked,
|
37
|
+
unlocked: client.notification.onExternalTaskUnlocked,
|
38
|
+
};
|
39
|
+
|
40
|
+
const handler = eventHandlers[config.eventtype];
|
41
|
+
if (handler) {
|
42
|
+
return await handler(externalTaskCallback(), { identity: currentIdentity });
|
43
|
+
} else {
|
44
|
+
console.error('no such event: ' + config.eventtype);
|
80
45
|
}
|
81
46
|
}
|
82
47
|
|
package/package.json
CHANGED
@@ -17,126 +17,47 @@ module.exports = function (RED) {
|
|
17
17
|
let subscription;
|
18
18
|
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node);
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
userTask: userTask,
|
43
|
-
action: 'new',
|
44
|
-
type: 'usertask',
|
45
|
-
},
|
46
|
-
});
|
47
|
-
}
|
20
|
+
function userTaskCallback() {
|
21
|
+
return async (userTaskNotification) => {
|
22
|
+
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
23
|
+
const newQuery = {
|
24
|
+
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
25
|
+
...query,
|
26
|
+
};
|
27
|
+
|
28
|
+
const matchingFlowNodes = await client.userTasks.query(newQuery, {
|
29
|
+
identity: currentIdentity,
|
30
|
+
});
|
31
|
+
|
32
|
+
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
33
|
+
const userTask = matchingFlowNodes.userTasks[0];
|
34
|
+
|
35
|
+
node.send({
|
36
|
+
payload: {
|
37
|
+
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
38
|
+
userTaskEvent: userTaskNotification,
|
39
|
+
userTask: userTask,
|
40
|
+
action: config.eventtype,
|
41
|
+
type: 'usertask',
|
48
42
|
},
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
async (userTaskNotification) => {
|
54
|
-
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
55
|
-
const newQuery = {
|
56
|
-
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
57
|
-
...query,
|
58
|
-
};
|
59
|
-
|
60
|
-
const matchingFlowNodes = await client.userTasks.query(newQuery, {
|
61
|
-
identity: currentIdentity,
|
62
|
-
});
|
63
|
-
|
64
|
-
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
65
|
-
const userTask = matchingFlowNodes.userTasks[0];
|
66
|
-
|
67
|
-
node.send({
|
68
|
-
payload: {
|
69
|
-
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
70
|
-
userTaskEvent: userTaskNotification,
|
71
|
-
userTask: userTask,
|
72
|
-
action: 'finished',
|
73
|
-
type: 'usertask',
|
74
|
-
},
|
75
|
-
});
|
76
|
-
}
|
77
|
-
},
|
78
|
-
{ identity: currentIdentity }
|
79
|
-
);
|
80
|
-
case 'reserved':
|
81
|
-
return await client.userTasks.onUserTaskReserved(
|
82
|
-
async (userTaskNotification) => {
|
83
|
-
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
84
|
-
const newQuery = {
|
85
|
-
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
86
|
-
...query,
|
87
|
-
};
|
88
|
-
|
89
|
-
const matchingFlowNodes = await client.userTasks.query(newQuery, {
|
90
|
-
identity: currentIdentity,
|
91
|
-
});
|
92
|
-
|
93
|
-
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
94
|
-
const userTask = matchingFlowNodes.userTasks[0];
|
95
|
-
|
96
|
-
node.send({
|
97
|
-
payload: {
|
98
|
-
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
99
|
-
userTaskEvent: userTaskNotification,
|
100
|
-
userTask: userTask,
|
101
|
-
action: 'reserved',
|
102
|
-
type: 'usertask',
|
103
|
-
},
|
104
|
-
});
|
105
|
-
}
|
106
|
-
},
|
107
|
-
{ identity: currentIdentity }
|
108
|
-
);
|
109
|
-
case 'reservation-canceled':
|
110
|
-
return await client.userTasks.onUserTaskReservationCanceled(
|
111
|
-
async (userTaskNotification) => {
|
112
|
-
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
113
|
-
const newQuery = {
|
114
|
-
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
115
|
-
...query,
|
116
|
-
};
|
117
|
-
|
118
|
-
const matchingFlowNodes = await client.userTasks.query(newQuery, {
|
119
|
-
identity: currentIdentity,
|
120
|
-
});
|
121
|
-
|
122
|
-
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
123
|
-
const userTask = matchingFlowNodes.userTasks[0];
|
43
|
+
});
|
44
|
+
}
|
45
|
+
};
|
46
|
+
}
|
124
47
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
default:
|
139
|
-
console.error('no such event: ' + config.eventtype);
|
48
|
+
async function subscribe() {
|
49
|
+
const eventHandlers = {
|
50
|
+
new: client.userTasks.onUserTaskWaiting,
|
51
|
+
finished: client.userTasks.onUserTaskFinished,
|
52
|
+
reserved: client.userTasks.onUserTaskReserved,
|
53
|
+
'reservation-canceled': client.userTasks.onUserTaskReservationCanceled,
|
54
|
+
};
|
55
|
+
|
56
|
+
const handler = eventHandlers[config.eventtype];
|
57
|
+
if (handler) {
|
58
|
+
return await handler(userTaskCallback(), { identity: currentIdentity });
|
59
|
+
} else {
|
60
|
+
console.error('no such event: ' + config.eventtype);
|
140
61
|
}
|
141
62
|
}
|
142
63
|
|