@5minds/node-red-contrib-processcube 1.1.4-develop-42c299-m05bmm2k → 1.1.4-develop-80ad6a-m0l0wxfa

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 (39) hide show
  1. package/endevent-finished-listener.html +2 -2
  2. package/externaltask-error.html +1 -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 +4 -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/process-terminate.html +37 -0
  27. package/process-terminate.js +27 -0
  28. package/processdefinition-query.html +1 -1
  29. package/processes/User-Task-Sample.bpmn +18 -2
  30. package/processinstance-query.html +1 -1
  31. package/signal-event-trigger.html +1 -1
  32. package/usertask-event-listener.html +75 -0
  33. package/usertask-event-listener.js +96 -0
  34. package/usertask-input.html +1 -1
  35. package/usertask-output.html +1 -1
  36. package/usertask-finished-listener.html +0 -45
  37. package/usertask-finished-listener.js +0 -68
  38. package/usertask-new-listener.html +0 -45
  39. package/usertask-new-listener.js +0 -69
@@ -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: 'usertask_event_listener.svg',
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,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,7 @@
10
10
  },
11
11
  inputs: 1,
12
12
  outputs: 1,
13
- icon: 'font-awesome/fa-envelope',
13
+ icon: 'usertask_output.svg',
14
14
  label: function () {
15
15
  return this.name || 'usertask-output';
16
16
  },
@@ -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
- };