@5minds/node-red-contrib-processcube 1.1.4-develop-f12497-m0akrvxl → 1.1.4-develop-e4b670-m0m25yen

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.
Files changed (37) hide show
  1. package/endevent-finished-listener.html +2 -2
  2. package/externaltask-error.html +2 -1
  3. package/externaltask-event-listener.html +52 -0
  4. package/externaltask-event-listener.js +77 -0
  5. package/externaltask-input.html +1 -1
  6. package/externaltask-output.html +1 -1
  7. package/icons/endevent_finished_listener.svg +4 -0
  8. package/icons/externaltask_error.svg +5 -0
  9. package/icons/externaltask_event_listener.svg +4 -0
  10. package/icons/externaltask_input.svg +6 -0
  11. package/icons/externaltask_output.svg +6 -0
  12. package/icons/message_event_trigger.svg +5 -0
  13. package/icons/process_event_listener.svg +6 -0
  14. package/icons/process_start.svg +6 -0
  15. package/icons/processdefinition_query.svg +7 -0
  16. package/icons/processinstance_query.svg +6 -0
  17. package/icons/signal_event_trigger.svg +5 -0
  18. package/icons/usertask_event_listener.svg +4 -0
  19. package/icons/usertask_input.svg +5 -0
  20. package/icons/usertask_output.svg +5 -0
  21. package/message-event-trigger.html +1 -1
  22. package/package.json +3 -1
  23. package/process-event-listener.html +24 -2
  24. package/process-event-listener.js +261 -92
  25. package/process-start.html +1 -1
  26. package/processdefinition-query.html +1 -1
  27. package/processes/User-Task-Sample.bpmn +18 -2
  28. package/processinstance-query.html +1 -1
  29. package/signal-event-trigger.html +1 -1
  30. package/usertask-event-listener.html +75 -0
  31. package/usertask-event-listener.js +96 -0
  32. package/usertask-input.html +1 -1
  33. package/usertask-output.html +4 -4
  34. package/usertask-finished-listener.html +0 -45
  35. package/usertask-finished-listener.js +0 -68
  36. package/usertask-new-listener.html +0 -45
  37. package/usertask-new-listener.js +0 -69
@@ -0,0 +1,96 @@
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
+ 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',
42
+ },
43
+ });
44
+ }
45
+ };
46
+ }
47
+
48
+ async function subscribe() {
49
+ switch (config.eventtype) {
50
+ case 'new':
51
+ return await client.userTasks.onUserTaskWaiting(userTaskCallback(), {
52
+ identity: currentIdentity,
53
+ });
54
+ case 'finished':
55
+ return await client.userTasks.onUserTaskFinished(userTaskCallback(), {
56
+ identity: currentIdentity,
57
+ });
58
+ case 'reserved':
59
+ return await client.userTasks.onUserTaskReserved(userTaskCallback(), {
60
+ identity: currentIdentity,
61
+ });
62
+ case 'reservation-canceled':
63
+ return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback(), {
64
+ identity: currentIdentity,
65
+ });
66
+ default:
67
+ console.error('no such event: ' + config.eventtype);
68
+ }
69
+ }
70
+
71
+ if (node.engine.isIdentityReady()) {
72
+ subscription = subscribe();
73
+ }
74
+
75
+ node.engine.registerOnIdentityChanged(async (identity) => {
76
+ if (subscription) {
77
+ client.userTasks.removeSubscription(subscription, currentIdentity);
78
+ }
79
+ currentIdentity = identity;
80
+
81
+ subscription = subscribe();
82
+ });
83
+
84
+ node.on('close', async () => {
85
+ if (node.engine && node.engine.engineClient && client) {
86
+ client.userTasks.removeSubscription(subscription, currentIdentity);
87
+ }
88
+ });
89
+ };
90
+
91
+ if (node.engine) {
92
+ register();
93
+ }
94
+ }
95
+ RED.nodes.registerType('usertask-event-listener', UserTaskEventListener);
96
+ };
@@ -12,7 +12,7 @@
12
12
  },
13
13
  inputs: 1,
14
14
  outputs: 1,
15
- icon: 'font-awesome/fa-envelope-open',
15
+ icon: 'usertask_input.svg',
16
16
  label: function () {
17
17
  return this.name || 'usertask-input';
18
18
  },
@@ -10,7 +10,8 @@
10
10
  },
11
11
  inputs: 1,
12
12
  outputs: 1,
13
- icon: 'font-awesome/fa-envelope',
13
+ align: 'right',
14
+ icon: 'usertask_output.svg',
14
15
  label: function () {
15
16
  return this.name || 'usertask-output';
16
17
  },
@@ -55,7 +56,6 @@ A node which sends the result of a usertask to the ProcessCube.
55
56
 
56
57
  ### References
57
58
 
58
- - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
59
- - [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
60
-
59
+ - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
60
+ - [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
61
61
  </script>
@@ -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
- };