@5minds/node-red-contrib-processcube 0.14.0-feature-7cec87-lyytfjz9 → 0.14.0-feature-197b34-lyzwc8zw
Sign up to get free protection for your applications and to get access to all the features.
- package/message-event-trigger.js +26 -34
- package/package.json +1 -1
- package/process-start.js +23 -28
- package/processdefinition-query.js +47 -45
- package/processinstance-query.js +25 -27
- package/signal-event-trigger.js +26 -34
- package/usertask-finished-listener.js +52 -31
- package/usertask-input.js +48 -34
- package/usertask-new-listener.js +49 -32
- package/usertask-output.js +35 -31
package/message-event-trigger.js
CHANGED
@@ -1,45 +1,37 @@
|
|
1
|
-
const process = require(
|
1
|
+
const process = require("process");
|
2
2
|
|
3
|
-
const engine_client = require(
|
3
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
4
4
|
|
5
|
-
module.exports = function(RED) {
|
5
|
+
module.exports = function (RED) {
|
6
6
|
function MessageEventTrigger(config) {
|
7
7
|
RED.nodes.createNode(this, config);
|
8
8
|
var node = this;
|
9
|
-
var nodeContext = node.context();
|
10
9
|
|
11
10
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
12
11
|
|
13
|
-
const
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
node.send(msg);
|
37
|
-
node.status({fill: "blue", shape: "dot", text: `message event triggered`});
|
38
|
-
|
39
|
-
}).catch((error) => {
|
40
|
-
node.error(error);
|
41
|
-
});
|
12
|
+
const client = this.engine.getEngineClient();
|
13
|
+
|
14
|
+
node.on("input", function (msg) {
|
15
|
+
client.events
|
16
|
+
.triggerMessageEvent(config.messagename, {
|
17
|
+
processInstanceId: config.processinstanceid,
|
18
|
+
payload: msg.payload,
|
19
|
+
identity: node.server.identity,
|
20
|
+
})
|
21
|
+
.then((result) => {
|
22
|
+
msg.payload = result;
|
23
|
+
|
24
|
+
node.send(msg);
|
25
|
+
node.status({
|
26
|
+
fill: "blue",
|
27
|
+
shape: "dot",
|
28
|
+
text: `message event triggered`,
|
29
|
+
});
|
30
|
+
})
|
31
|
+
.catch((error) => {
|
32
|
+
node.error(error);
|
33
|
+
});
|
42
34
|
});
|
43
35
|
}
|
44
36
|
RED.nodes.registerType("message-event-trigger", MessageEventTrigger);
|
45
|
-
}
|
37
|
+
};
|
package/package.json
CHANGED
package/process-start.js
CHANGED
@@ -1,43 +1,38 @@
|
|
1
|
-
const process = require(
|
2
|
-
const engine_client = require(
|
1
|
+
const process = require("process");
|
2
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
3
3
|
|
4
|
-
module.exports = function(RED) {
|
4
|
+
module.exports = function (RED) {
|
5
5
|
function ProcessStart(config) {
|
6
|
-
RED.nodes.createNode(this,config);
|
6
|
+
RED.nodes.createNode(this, config);
|
7
7
|
var node = this;
|
8
|
-
var flowContext = node.context().flow;
|
9
|
-
var nodeContext = node.context();
|
10
8
|
|
11
9
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
12
10
|
|
13
|
-
const
|
14
|
-
|
15
|
-
var client = nodeContext.get('client');
|
16
|
-
|
17
|
-
if (!client) {
|
18
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
19
|
-
client = nodeContext.get('client');
|
20
|
-
}
|
21
|
-
|
22
|
-
node.on('input', function(msg) {
|
11
|
+
const client = this.engine.getEngineClient();
|
23
12
|
|
13
|
+
node.on("input", function (msg) {
|
24
14
|
const startParameters = {
|
25
15
|
processModelId: msg.processModelId || config.processmodel,
|
26
16
|
startEventId: msg.startEventId || config.startevent,
|
27
|
-
initialToken: msg.payload
|
17
|
+
initialToken: msg.payload,
|
28
18
|
};
|
29
19
|
|
30
|
-
client.processDefinitions
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
client.processDefinitions
|
21
|
+
.startProcessInstance(startParameters, node.engine.identity)
|
22
|
+
.then((result) => {
|
23
|
+
msg.payload = result;
|
24
|
+
|
25
|
+
node.send(msg);
|
26
|
+
node.status({
|
27
|
+
fill: "blue",
|
28
|
+
shape: "dot",
|
29
|
+
text: `started ${result.processInstanceId}`,
|
30
|
+
});
|
31
|
+
})
|
32
|
+
.catch((error) => {
|
33
|
+
node.error(error);
|
34
|
+
});
|
40
35
|
});
|
41
36
|
}
|
42
37
|
RED.nodes.registerType("process-start", ProcessStart);
|
43
|
-
}
|
38
|
+
};
|
@@ -1,31 +1,23 @@
|
|
1
|
-
const process = require(
|
2
|
-
const EventEmitter = require(
|
1
|
+
const process = require("process");
|
2
|
+
const EventEmitter = require("node:events");
|
3
3
|
|
4
|
-
const engine_client = require(
|
4
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
5
5
|
|
6
|
-
module.exports = function(RED) {
|
6
|
+
module.exports = function (RED) {
|
7
7
|
function ProcessdefinitionQuery(config) {
|
8
|
-
RED.nodes.createNode(this,config);
|
8
|
+
RED.nodes.createNode(this, config);
|
9
9
|
var node = this;
|
10
10
|
var flowContext = node.context().flow;
|
11
|
-
var nodeContext = node.context();
|
12
11
|
|
13
12
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
14
13
|
|
15
|
-
const
|
14
|
+
const client = this.engine.getEngineClient();
|
16
15
|
|
17
|
-
var
|
18
|
-
|
19
|
-
if (!client) {
|
20
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
21
|
-
client = nodeContext.get('client');
|
22
|
-
}
|
23
|
-
|
24
|
-
var eventEmitter = flowContext.get('emitter');
|
16
|
+
var eventEmitter = flowContext.get("emitter");
|
25
17
|
|
26
18
|
if (!eventEmitter) {
|
27
|
-
flowContext.set(
|
28
|
-
eventEmitter = flowContext.get(
|
19
|
+
flowContext.set("emitter", new EventEmitter());
|
20
|
+
eventEmitter = flowContext.get("emitter");
|
29
21
|
}
|
30
22
|
|
31
23
|
node.on("close", async () => {
|
@@ -33,38 +25,48 @@ module.exports = function(RED) {
|
|
33
25
|
client = null;
|
34
26
|
});
|
35
27
|
|
36
|
-
node.on(
|
37
|
-
let query = RED.util.evaluateNodeProperty(
|
28
|
+
node.on("input", function (msg) {
|
29
|
+
let query = RED.util.evaluateNodeProperty(
|
30
|
+
config.query,
|
31
|
+
config.query_type,
|
32
|
+
node,
|
33
|
+
msg
|
34
|
+
);
|
38
35
|
query = {
|
39
36
|
...query,
|
40
|
-
identity: node.server.identity
|
37
|
+
identity: node.server.identity,
|
41
38
|
};
|
42
|
-
|
43
|
-
client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
|
44
|
-
|
45
|
-
|
46
|
-
if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
|
47
|
-
let models = [];
|
48
|
-
|
49
|
-
matchingProcessDefinitions.processDefinitions.forEach(processDefinition => {
|
50
|
-
processDefinition.processModels.forEach(model => {
|
51
|
-
models.push(model);
|
52
|
-
});
|
53
|
-
});
|
54
|
-
|
55
|
-
msg.payload = {
|
56
|
-
models: models,
|
57
|
-
totalCount: models.length
|
58
|
-
};
|
59
|
-
|
60
|
-
} else {
|
61
|
-
msg.payload = matchingProcessDefinitions;
|
62
|
-
}
|
63
|
-
|
64
39
|
|
65
|
-
|
66
|
-
|
40
|
+
client.processDefinitions
|
41
|
+
.getAll(query)
|
42
|
+
.then((matchingProcessDefinitions) => {
|
43
|
+
if (
|
44
|
+
config.models_only &&
|
45
|
+
matchingProcessDefinitions.totalCount > 0
|
46
|
+
) {
|
47
|
+
let models = [];
|
48
|
+
|
49
|
+
matchingProcessDefinitions.processDefinitions.forEach(
|
50
|
+
(processDefinition) => {
|
51
|
+
processDefinition.processModels.forEach(
|
52
|
+
(model) => {
|
53
|
+
models.push(model);
|
54
|
+
}
|
55
|
+
);
|
56
|
+
}
|
57
|
+
);
|
58
|
+
|
59
|
+
msg.payload = {
|
60
|
+
models: models,
|
61
|
+
totalCount: models.length,
|
62
|
+
};
|
63
|
+
} else {
|
64
|
+
msg.payload = matchingProcessDefinitions;
|
65
|
+
}
|
66
|
+
|
67
|
+
node.send(msg);
|
68
|
+
});
|
67
69
|
});
|
68
70
|
}
|
69
71
|
RED.nodes.registerType("processdefinition-query", ProcessdefinitionQuery);
|
70
|
-
}
|
72
|
+
};
|
package/processinstance-query.js
CHANGED
@@ -1,31 +1,23 @@
|
|
1
|
-
const process = require(
|
2
|
-
const EventEmitter = require(
|
1
|
+
const process = require("process");
|
2
|
+
const EventEmitter = require("node:events");
|
3
3
|
|
4
|
-
const engine_client = require(
|
4
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
5
5
|
|
6
|
-
module.exports = function(RED) {
|
6
|
+
module.exports = function (RED) {
|
7
7
|
function ProcessinstanceQuery(config) {
|
8
|
-
RED.nodes.createNode(this,config);
|
8
|
+
RED.nodes.createNode(this, config);
|
9
9
|
var node = this;
|
10
10
|
var flowContext = node.context().flow;
|
11
|
-
var nodeContext = node.context();
|
12
11
|
|
13
12
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
14
13
|
|
15
|
-
const
|
14
|
+
const client = this.engine.getEngineClient();
|
16
15
|
|
17
|
-
var
|
18
|
-
|
19
|
-
if (!client) {
|
20
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
21
|
-
client = nodeContext.get('client');
|
22
|
-
}
|
23
|
-
|
24
|
-
var eventEmitter = flowContext.get('emitter');
|
16
|
+
var eventEmitter = flowContext.get("emitter");
|
25
17
|
|
26
18
|
if (!eventEmitter) {
|
27
|
-
flowContext.set(
|
28
|
-
eventEmitter = flowContext.get(
|
19
|
+
flowContext.set("emitter", new EventEmitter());
|
20
|
+
eventEmitter = flowContext.get("emitter");
|
29
21
|
}
|
30
22
|
|
31
23
|
node.on("close", async () => {
|
@@ -33,16 +25,22 @@ module.exports = function(RED) {
|
|
33
25
|
client = null;
|
34
26
|
});
|
35
27
|
|
36
|
-
node.on(
|
37
|
-
let query = RED.util.evaluateNodeProperty(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
msg
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
node.on("input", function (msg) {
|
29
|
+
let query = RED.util.evaluateNodeProperty(
|
30
|
+
config.query,
|
31
|
+
config.query_type,
|
32
|
+
node,
|
33
|
+
msg
|
34
|
+
);
|
35
|
+
|
36
|
+
client.processInstances
|
37
|
+
.query(query, { identity: node.server.identity })
|
38
|
+
.then((matchingInstances) => {
|
39
|
+
msg.payload = matchingInstances;
|
40
|
+
|
41
|
+
node.send(msg);
|
42
|
+
});
|
45
43
|
});
|
46
44
|
}
|
47
45
|
RED.nodes.registerType("processinstance-query", ProcessinstanceQuery);
|
48
|
-
}
|
46
|
+
};
|
package/signal-event-trigger.js
CHANGED
@@ -1,45 +1,37 @@
|
|
1
|
-
const process = require(
|
1
|
+
const process = require("process");
|
2
2
|
|
3
|
-
const engine_client = require(
|
3
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
4
4
|
|
5
|
-
module.exports = function(RED) {
|
5
|
+
module.exports = function (RED) {
|
6
6
|
function SignalEventTrigger(config) {
|
7
7
|
RED.nodes.createNode(this, config);
|
8
8
|
var node = this;
|
9
|
-
var nodeContext = node.context();
|
10
9
|
|
11
10
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
12
11
|
|
13
|
-
const
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
node.send(msg);
|
37
|
-
node.status({fill: "blue", shape: "dot", text: `signal event triggered`});
|
38
|
-
|
39
|
-
}).catch((error) => {
|
40
|
-
node.error(error);
|
41
|
-
});
|
12
|
+
const client = this.engine.getEngineClient();
|
13
|
+
|
14
|
+
node.on("input", function (msg) {
|
15
|
+
client.events
|
16
|
+
.triggerSignalEvent(config.signalname, {
|
17
|
+
processInstanceId: config.processinstanceid,
|
18
|
+
payload: msg.payload,
|
19
|
+
identity: node.server.identity,
|
20
|
+
})
|
21
|
+
.then((result) => {
|
22
|
+
msg.payload = result;
|
23
|
+
|
24
|
+
node.send(msg);
|
25
|
+
node.status({
|
26
|
+
fill: "blue",
|
27
|
+
shape: "dot",
|
28
|
+
text: `signal event triggered`,
|
29
|
+
});
|
30
|
+
})
|
31
|
+
.catch((error) => {
|
32
|
+
node.error(error);
|
33
|
+
});
|
42
34
|
});
|
43
35
|
}
|
44
36
|
RED.nodes.registerType("signal-event-trigger", SignalEventTrigger);
|
45
|
-
}
|
37
|
+
};
|
@@ -1,58 +1,79 @@
|
|
1
|
-
const process = require(
|
2
|
-
const EventEmitter = require(
|
1
|
+
const process = require("process");
|
2
|
+
const EventEmitter = require("node:events");
|
3
3
|
|
4
|
-
const engine_client = require(
|
4
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
5
5
|
|
6
|
-
module.exports = function(RED) {
|
6
|
+
module.exports = function (RED) {
|
7
7
|
function UserTaskFinishedListener(config) {
|
8
8
|
RED.nodes.createNode(this, config);
|
9
9
|
var node = this;
|
10
10
|
var flowContext = node.context().flow;
|
11
|
-
var nodeContext = node.context();
|
12
11
|
|
13
12
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
14
13
|
|
15
|
-
const
|
14
|
+
const client = this.engine.getEngineClient();
|
16
15
|
|
17
|
-
var
|
18
|
-
|
19
|
-
if (!client) {
|
20
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
21
|
-
client = nodeContext.get('client');
|
22
|
-
}
|
23
|
-
|
24
|
-
var eventEmitter = flowContext.get('emitter');
|
16
|
+
var eventEmitter = flowContext.get("emitter");
|
25
17
|
|
26
18
|
if (!eventEmitter) {
|
27
|
-
flowContext.set(
|
28
|
-
eventEmitter = flowContext.get(
|
19
|
+
flowContext.set("emitter", new EventEmitter());
|
20
|
+
eventEmitter = flowContext.get("emitter");
|
29
21
|
}
|
30
22
|
|
31
23
|
const register = async () => {
|
32
24
|
let currentIdentity = node.server.identity;
|
33
|
-
let subscription = await client.userTasks.onUserTaskFinished(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
25
|
+
let subscription = await client.userTasks.onUserTaskFinished(
|
26
|
+
(userTaskFinishedNotification) => {
|
27
|
+
node.send({
|
28
|
+
payload: {
|
29
|
+
flowNodeInstanceId:
|
30
|
+
userTaskFinishedNotification.flowNodeInstanceId,
|
31
|
+
action: "finished",
|
32
|
+
type: "usertask",
|
33
|
+
},
|
34
|
+
});
|
35
|
+
},
|
36
|
+
{ identity: currentIdentity }
|
37
|
+
);
|
38
|
+
|
39
|
+
node.server.registerOnIdentityChanged(async (identity) => {
|
40
|
+
client.userTasks.removeSubscription(
|
41
|
+
subscription,
|
42
|
+
currentIdentity
|
43
|
+
);
|
39
44
|
currentIdentity = identity;
|
40
|
-
|
41
|
-
subscription = await client.userTasks.onUserTaskFinished(
|
42
|
-
|
43
|
-
|
45
|
+
|
46
|
+
subscription = await client.userTasks.onUserTaskFinished(
|
47
|
+
(userTaskFinishedNotification) => {
|
48
|
+
node.send({
|
49
|
+
payload: {
|
50
|
+
flowNodeInstanceId:
|
51
|
+
userTaskFinishedNotification.flowNodeInstanceId,
|
52
|
+
action: "finished",
|
53
|
+
type: "usertask",
|
54
|
+
},
|
55
|
+
});
|
56
|
+
},
|
57
|
+
{ identity: currentIdentity }
|
58
|
+
);
|
44
59
|
});
|
45
|
-
|
60
|
+
|
46
61
|
node.on("close", async () => {
|
47
|
-
client.userTasks.removeSubscription(
|
62
|
+
client.userTasks.removeSubscription(
|
63
|
+
subscription,
|
64
|
+
currentIdentity
|
65
|
+
);
|
48
66
|
client.dispose();
|
49
67
|
client = null;
|
50
68
|
});
|
51
|
-
}
|
69
|
+
};
|
52
70
|
|
53
71
|
if (node.server) {
|
54
72
|
register();
|
55
73
|
}
|
56
74
|
}
|
57
|
-
RED.nodes.registerType(
|
58
|
-
|
75
|
+
RED.nodes.registerType(
|
76
|
+
"usertask-finished-listener",
|
77
|
+
UserTaskFinishedListener
|
78
|
+
);
|
79
|
+
};
|
package/usertask-input.js
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
const process = require(
|
2
|
-
const EventEmitter = require(
|
1
|
+
const process = require("process");
|
2
|
+
const EventEmitter = require("node:events");
|
3
3
|
|
4
|
-
const engine_client = require(
|
4
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
5
5
|
|
6
6
|
function showStatus(node, msgCounter) {
|
7
7
|
if (msgCounter >= 1) {
|
8
|
-
node.status({
|
8
|
+
node.status({
|
9
|
+
fill: "blue",
|
10
|
+
shape: "dot",
|
11
|
+
text: `handling tasks ${msgCounter}`,
|
12
|
+
});
|
9
13
|
} else {
|
10
|
-
node.status({
|
14
|
+
node.status({
|
15
|
+
fill: "blue",
|
16
|
+
shape: "ring",
|
17
|
+
text: `subcribed ${msgCounter}`,
|
18
|
+
});
|
11
19
|
}
|
12
20
|
}
|
13
21
|
|
14
|
-
module.exports = function(RED) {
|
22
|
+
module.exports = function (RED) {
|
15
23
|
function UserTaskInput(config) {
|
16
|
-
RED.nodes.createNode(this,config);
|
24
|
+
RED.nodes.createNode(this, config);
|
17
25
|
var node = this;
|
18
26
|
var msgCounter = 0;
|
19
27
|
var flowContext = node.context().flow;
|
20
|
-
var nodeContext = node.context();
|
21
28
|
|
22
29
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
23
30
|
|
24
|
-
const
|
25
|
-
|
26
|
-
var client = nodeContext.get('client');
|
27
|
-
|
28
|
-
if (!client) {
|
29
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
30
|
-
client = nodeContext.get('client');
|
31
|
-
}
|
31
|
+
const client = this.engine.getEngineClient();
|
32
32
|
|
33
|
-
var eventEmitter = flowContext.get(
|
33
|
+
var eventEmitter = flowContext.get("emitter");
|
34
34
|
|
35
35
|
if (!eventEmitter) {
|
36
|
-
flowContext.set(
|
37
|
-
eventEmitter = flowContext.get(
|
36
|
+
flowContext.set("emitter", new EventEmitter());
|
37
|
+
eventEmitter = flowContext.get("emitter");
|
38
38
|
}
|
39
39
|
|
40
40
|
node.on("close", async () => {
|
@@ -42,40 +42,54 @@ module.exports = function(RED) {
|
|
42
42
|
client = null;
|
43
43
|
});
|
44
44
|
|
45
|
-
node.on(
|
46
|
-
let query = RED.util.evaluateNodeProperty(
|
45
|
+
node.on("input", function (msg) {
|
46
|
+
let query = RED.util.evaluateNodeProperty(
|
47
|
+
config.query,
|
48
|
+
config.query_type,
|
49
|
+
node,
|
50
|
+
msg
|
51
|
+
);
|
47
52
|
query = {
|
48
53
|
...query,
|
49
|
-
identity: node.server.identity
|
50
|
-
}
|
54
|
+
identity: node.server.identity,
|
55
|
+
};
|
51
56
|
client.userTasks.query(query).then((matchingFlowNodes) => {
|
52
|
-
|
53
|
-
|
57
|
+
if (
|
58
|
+
!config.force_send_array &&
|
59
|
+
matchingFlowNodes &&
|
60
|
+
matchingFlowNodes.userTasks &&
|
61
|
+
matchingFlowNodes.userTasks.length == 1
|
62
|
+
) {
|
54
63
|
userTask = matchingFlowNodes.userTasks[0];
|
55
64
|
|
56
65
|
msg.payload = { userTask: userTask };
|
57
66
|
node.send(msg);
|
58
67
|
} else {
|
59
68
|
if (!config.force_send_array) {
|
60
|
-
if (
|
69
|
+
if (
|
70
|
+
config.multisend &&
|
71
|
+
matchingFlowNodes.userTasks &&
|
72
|
+
matchingFlowNodes.userTasks.length > 1
|
73
|
+
) {
|
61
74
|
matchingFlowNodes.userTasks.forEach((userTask) => {
|
62
|
-
|
63
|
-
msg.payload = { userTask: userTask } ;
|
75
|
+
msg.payload = { userTask: userTask };
|
64
76
|
node.send(msg);
|
65
77
|
});
|
66
78
|
} else {
|
67
|
-
|
68
|
-
|
79
|
+
msg.payload = {
|
80
|
+
userTasks: matchingFlowNodes.userTasks,
|
81
|
+
};
|
69
82
|
node.send(msg);
|
70
83
|
}
|
71
84
|
} else {
|
72
|
-
|
73
|
-
|
85
|
+
msg.payload = {
|
86
|
+
userTasks: matchingFlowNodes.userTasks || [],
|
87
|
+
};
|
74
88
|
node.send(msg);
|
75
89
|
}
|
76
|
-
|
90
|
+
}
|
77
91
|
});
|
78
92
|
});
|
79
93
|
}
|
80
94
|
RED.nodes.registerType("usertask-input", UserTaskInput);
|
81
|
-
}
|
95
|
+
};
|
package/usertask-new-listener.js
CHANGED
@@ -1,59 +1,76 @@
|
|
1
|
-
const process = require(
|
2
|
-
const EventEmitter = require(
|
1
|
+
const process = require("process");
|
2
|
+
const EventEmitter = require("node:events");
|
3
3
|
|
4
|
-
const engine_client = require(
|
4
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
5
5
|
|
6
|
-
module.exports = function(RED) {
|
6
|
+
module.exports = function (RED) {
|
7
7
|
function UserTaskNewListener(config) {
|
8
8
|
RED.nodes.createNode(this, config);
|
9
9
|
var node = this;
|
10
10
|
var flowContext = node.context().flow;
|
11
|
-
var nodeContext = node.context();
|
12
11
|
|
13
12
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
14
13
|
|
15
|
-
const
|
14
|
+
const client = this.engine.getEngineClient();
|
16
15
|
|
17
|
-
var
|
18
|
-
|
19
|
-
if (!client) {
|
20
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
21
|
-
client = nodeContext.get('client');
|
22
|
-
}
|
23
|
-
|
24
|
-
var eventEmitter = flowContext.get('emitter');
|
16
|
+
var eventEmitter = flowContext.get("emitter");
|
25
17
|
|
26
18
|
if (!eventEmitter) {
|
27
|
-
flowContext.set(
|
28
|
-
eventEmitter = flowContext.get(
|
19
|
+
flowContext.set("emitter", new EventEmitter());
|
20
|
+
eventEmitter = flowContext.get("emitter");
|
29
21
|
}
|
30
|
-
|
22
|
+
|
31
23
|
const register = async () => {
|
32
24
|
let currentIdentity = node.server.identity;
|
33
|
-
let subscription = await client.userTasks.onUserTaskWaiting(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
25
|
+
let subscription = await client.userTasks.onUserTaskWaiting(
|
26
|
+
(userTaskWaitingNotification) => {
|
27
|
+
node.send({
|
28
|
+
payload: {
|
29
|
+
flowNodeInstanceId:
|
30
|
+
userTaskWaitingNotification.flowNodeInstanceId,
|
31
|
+
action: "new",
|
32
|
+
type: "usertask",
|
33
|
+
},
|
34
|
+
});
|
35
|
+
},
|
36
|
+
{ identity: currentIdentity }
|
37
|
+
);
|
38
|
+
|
39
|
+
node.server.registerOnIdentityChanged(async (identity) => {
|
40
|
+
client.userTasks.removeSubscription(
|
41
|
+
subscription,
|
42
|
+
currentIdentity
|
43
|
+
);
|
39
44
|
currentIdentity = identity;
|
40
|
-
|
41
|
-
subscription = await client.userTasks.onUserTaskWaiting(
|
42
|
-
|
43
|
-
|
45
|
+
|
46
|
+
subscription = await client.userTasks.onUserTaskWaiting(
|
47
|
+
(userTaskWaitingNotification) => {
|
48
|
+
node.send({
|
49
|
+
payload: {
|
50
|
+
flowNodeInstanceId:
|
51
|
+
userTaskWaitingNotification.flowNodeInstanceId,
|
52
|
+
action: "new",
|
53
|
+
type: "usertask",
|
54
|
+
},
|
55
|
+
});
|
56
|
+
},
|
57
|
+
{ identity: currentIdentity }
|
58
|
+
);
|
44
59
|
});
|
45
|
-
|
60
|
+
|
46
61
|
node.on("close", async () => {
|
47
|
-
client.userTasks.removeSubscription(
|
62
|
+
client.userTasks.removeSubscription(
|
63
|
+
subscription,
|
64
|
+
currentIdentity
|
65
|
+
);
|
48
66
|
client.dispose();
|
49
67
|
client = null;
|
50
68
|
});
|
51
|
-
}
|
69
|
+
};
|
52
70
|
|
53
71
|
if (node.server) {
|
54
72
|
register();
|
55
73
|
}
|
56
|
-
|
57
74
|
}
|
58
75
|
RED.nodes.registerType("usertask-new-listener", UserTaskNewListener);
|
59
|
-
}
|
76
|
+
};
|
package/usertask-output.js
CHANGED
@@ -1,53 +1,57 @@
|
|
1
|
-
const process = require(
|
2
|
-
const EventEmitter = require(
|
1
|
+
const process = require("process");
|
2
|
+
const EventEmitter = require("node:events");
|
3
3
|
|
4
|
-
const engine_client = require(
|
4
|
+
const engine_client = require("@5minds/processcube_engine_client");
|
5
5
|
|
6
|
-
module.exports = function(RED) {
|
6
|
+
module.exports = function (RED) {
|
7
7
|
function UserTaskOutput(config) {
|
8
|
-
|
9
8
|
RED.nodes.createNode(this, config);
|
10
9
|
|
11
10
|
var node = this;
|
12
11
|
var flowContext = node.context().flow;
|
13
|
-
var nodeContext = node.context();
|
14
12
|
|
15
13
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
16
14
|
|
17
|
-
const
|
18
|
-
|
19
|
-
var client = nodeContext.get('client');
|
20
|
-
|
21
|
-
if (!client) {
|
22
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
23
|
-
client = nodeContext.get('client');
|
24
|
-
}
|
15
|
+
const client = this.engine.getEngineClient();
|
25
16
|
|
26
|
-
var eventEmitter = flowContext.get(
|
17
|
+
var eventEmitter = flowContext.get("emitter");
|
27
18
|
|
28
19
|
if (!eventEmitter) {
|
29
|
-
flowContext.set(
|
30
|
-
eventEmitter = flowContext.get(
|
20
|
+
flowContext.set("emitter", new EventEmitter());
|
21
|
+
eventEmitter = flowContext.get("emitter");
|
31
22
|
}
|
32
23
|
|
33
|
-
node.on(
|
24
|
+
node.on("input", function (msg) {
|
34
25
|
if (msg.payload.userTask) {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
const userTaskResult = RED.util.evaluateNodeProperty(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
26
|
+
const flowNodeInstanceId =
|
27
|
+
msg.payload.userTask.flowNodeInstanceId;
|
28
|
+
|
29
|
+
const userTaskResult = RED.util.evaluateNodeProperty(
|
30
|
+
config.result,
|
31
|
+
config.result_type,
|
32
|
+
node,
|
33
|
+
msg
|
34
|
+
);
|
35
|
+
|
36
|
+
client.userTasks
|
37
|
+
.finishUserTask(
|
38
|
+
flowNodeInstanceId,
|
39
|
+
userTaskResult,
|
40
|
+
node.server.identity
|
41
|
+
)
|
42
|
+
.then(() => {
|
43
|
+
node.send(msg);
|
44
|
+
})
|
45
|
+
.catch((error) => {
|
46
|
+
node.error(error);
|
47
|
+
});
|
46
48
|
} else {
|
47
|
-
node.error(
|
49
|
+
node.error(
|
50
|
+
`No UserTask found in message: ${JSON.stringify(msg.payload)}`
|
51
|
+
);
|
48
52
|
}
|
49
53
|
});
|
50
54
|
}
|
51
55
|
|
52
56
|
RED.nodes.registerType("usertask-output", UserTaskOutput);
|
53
|
-
}
|
57
|
+
};
|