@5minds/node-red-contrib-processcube 0.14.0-fix-error-in-process-instance-query-9aeac9-lyzi0gix → 0.14.0

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 (38) hide show
  1. package/Dockerfile +1 -1
  2. package/docker-compose.yml +12 -0
  3. package/examples/External-Task-Sample.json +252 -0
  4. package/externaltask-error.html +26 -12
  5. package/externaltask-error.js +19 -20
  6. package/externaltask-input.html +31 -14
  7. package/externaltask-input.js +107 -55
  8. package/externaltask-output.html +20 -10
  9. package/externaltask-output.js +12 -11
  10. package/message-event-trigger.html +14 -14
  11. package/message-event-trigger.js +10 -14
  12. package/nodered/node-red-contrib-processcube-flows.json +216 -132
  13. package/nodered/package.json +1 -0
  14. package/nodered/settings.js +92 -82
  15. package/package.json +3 -9
  16. package/process-start.html +23 -19
  17. package/process-start.js +10 -15
  18. package/processcube-engine-config.html +10 -10
  19. package/processcube-engine-config.js +30 -22
  20. package/processdefinition-query.html +23 -29
  21. package/processdefinition-query.js +42 -36
  22. package/processes/External-Task-Sample.bpmn +94 -0
  23. package/processinstance-query.html +20 -19
  24. package/processinstance-query.js +16 -23
  25. package/signal-event-trigger.html +14 -14
  26. package/signal-event-trigger.js +10 -14
  27. package/usertask-finished-listener.html +12 -17
  28. package/usertask-finished-listener.js +30 -27
  29. package/usertask-input.html +27 -40
  30. package/usertask-input.js +37 -24
  31. package/usertask-new-listener.html +12 -17
  32. package/usertask-new-listener.js +27 -27
  33. package/usertask-output.html +24 -23
  34. package/usertask-output.js +25 -21
  35. package/.prettierrc.json +0 -6
  36. package/processes/CheckError.bpmn +0 -78
  37. package/processes/NodeRedExternalTask.bpmn +0 -77
  38. package/processes/SampleUserTask.bpmn +0 -95
@@ -1,66 +1,72 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
6
  module.exports = function (RED) {
7
7
  function ProcessdefinitionQuery(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 engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
+ const client = this.engine.getEngineClient();
16
15
 
17
- var client = nodeContext.get('client');
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('emitter', new EventEmitter());
28
- eventEmitter = flowContext.get('emitter');
19
+ flowContext.set("emitter", new EventEmitter());
20
+ eventEmitter = flowContext.get("emitter");
29
21
  }
30
22
 
31
- node.on('close', async () => {
23
+ node.on("close", async () => {
32
24
  client.dispose();
33
25
  client = null;
34
26
  });
35
27
 
36
- node.on('input', function (msg) {
37
- let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
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
37
  identity: node.server.identity,
41
38
  };
42
39
 
43
- client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
44
- if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
45
- let models = [];
40
+ client.processDefinitions
41
+ .getAll(query)
42
+ .then((matchingProcessDefinitions) => {
43
+ if (
44
+ config.models_only &&
45
+ matchingProcessDefinitions.totalCount > 0
46
+ ) {
47
+ let models = [];
46
48
 
47
- matchingProcessDefinitions.processDefinitions.forEach((processDefinition) => {
48
- processDefinition.processModels.forEach((model) => {
49
- models.push(model);
50
- });
51
- });
49
+ matchingProcessDefinitions.processDefinitions.forEach(
50
+ (processDefinition) => {
51
+ processDefinition.processModels.forEach(
52
+ (model) => {
53
+ models.push(model);
54
+ }
55
+ );
56
+ }
57
+ );
52
58
 
53
- msg.payload = {
54
- models: models,
55
- totalCount: models.length,
56
- };
57
- } else {
58
- msg.payload = matchingProcessDefinitions;
59
- }
59
+ msg.payload = {
60
+ models: models,
61
+ totalCount: models.length,
62
+ };
63
+ } else {
64
+ msg.payload = matchingProcessDefinitions;
65
+ }
60
66
 
61
- node.send(msg);
62
- });
67
+ node.send(msg);
68
+ });
63
69
  });
64
70
  }
65
- RED.nodes.registerType('processdefinition-query', ProcessdefinitionQuery);
71
+ RED.nodes.registerType("processdefinition-query", ProcessdefinitionQuery);
66
72
  };
@@ -0,0 +1,94 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="External-Task-Sample_Definition" targetNamespace="http://bpmn.io/schema/bpmn" exporter="5Minds Studio" exporterVersion="1">
3
+ <bpmn:collaboration id="Collaboration_1cidyxu" name="">
4
+ <bpmn:participant id="Participant_0px403d" name="External-Task-Sample" processRef="External-Task-Sample_Process" />
5
+ <bpmn:textAnnotation id="TextAnnotation_0lbjt7p">
6
+ <bpmn:text>Will be executed at the boundary event</bpmn:text>
7
+ </bpmn:textAnnotation>
8
+ <bpmn:association id="Association_0ivfgz1" associationDirection="None" sourceRef="Activity_0ma3kzt" targetRef="TextAnnotation_0lbjt7p" />
9
+ </bpmn:collaboration>
10
+ <bpmn:process id="External-Task-Sample_Process" name="External-Task-Sample" isExecutable="true">
11
+ <bpmn:laneSet />
12
+ <bpmn:startEvent id="StartEvent_1" name="Start">
13
+ <bpmn:outgoing>Flow_0qmxzxk</bpmn:outgoing>
14
+ </bpmn:startEvent>
15
+ <bpmn:sequenceFlow id="Flow_0qmxzxk" sourceRef="StartEvent_1" targetRef="Activity_02ykwt2" />
16
+ <bpmn:sequenceFlow id="Flow_16dfeac" sourceRef="Activity_02ykwt2" targetRef="Activity_0ma3kzt" />
17
+ <bpmn:endEvent id="Event_05wpeos">
18
+ <bpmn:incoming>Flow_0mo4oek</bpmn:incoming>
19
+ </bpmn:endEvent>
20
+ <bpmn:sequenceFlow id="Flow_0mo4oek" sourceRef="Activity_0ma3kzt" targetRef="Event_05wpeos" />
21
+ <bpmn:endEvent id="Event_0yn9mzh">
22
+ <bpmn:incoming>Flow_0y6es1p</bpmn:incoming>
23
+ </bpmn:endEvent>
24
+ <bpmn:sequenceFlow id="Flow_0y6es1p" sourceRef="Event_0o7qlkd" targetRef="Event_0yn9mzh" />
25
+ <bpmn:serviceTask id="Activity_02ykwt2" name="Topic &#34;Test&#34;" camunda:type="external" camunda:topic="Test">
26
+ <bpmn:incoming>Flow_0qmxzxk</bpmn:incoming>
27
+ <bpmn:outgoing>Flow_16dfeac</bpmn:outgoing>
28
+ </bpmn:serviceTask>
29
+ <bpmn:serviceTask id="Activity_0ma3kzt" name="Topic &#34;SampleError&#34;" camunda:type="external" camunda:topic="SampleError">
30
+ <bpmn:incoming>Flow_16dfeac</bpmn:incoming>
31
+ <bpmn:outgoing>Flow_0mo4oek</bpmn:outgoing>
32
+ </bpmn:serviceTask>
33
+ <bpmn:boundaryEvent id="Event_0o7qlkd" attachedToRef="Activity_0ma3kzt">
34
+ <bpmn:outgoing>Flow_0y6es1p</bpmn:outgoing>
35
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_1lr8fha" errorRef="Error_3O8wBFQi" />
36
+ </bpmn:boundaryEvent>
37
+ </bpmn:process>
38
+ <bpmn:error id="Error_3O8wBFQi" errorCode="MyErrorCode" />
39
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
40
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1cidyxu">
41
+ <bpmndi:BPMNShape id="Participant_0px403d_di" bpmnElement="Participant_0px403d" isHorizontal="true">
42
+ <dc:Bounds x="5" y="30" width="635" height="320" />
43
+ </bpmndi:BPMNShape>
44
+ <bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1">
45
+ <dc:Bounds x="92" y="152" width="36" height="36" />
46
+ <bpmndi:BPMNLabel>
47
+ <dc:Bounds x="98" y="195" width="24" height="14" />
48
+ </bpmndi:BPMNLabel>
49
+ </bpmndi:BPMNShape>
50
+ <bpmndi:BPMNShape id="Event_05wpeos_di" bpmnElement="Event_05wpeos">
51
+ <dc:Bounds x="502" y="152" width="36" height="36" />
52
+ </bpmndi:BPMNShape>
53
+ <bpmndi:BPMNShape id="Event_0yn9mzh_di" bpmnElement="Event_0yn9mzh">
54
+ <dc:Bounds x="482" y="272" width="36" height="36" />
55
+ </bpmndi:BPMNShape>
56
+ <bpmndi:BPMNShape id="Activity_1vxcs04_di" bpmnElement="Activity_02ykwt2">
57
+ <dc:Bounds x="180" y="130" width="100" height="80" />
58
+ <bpmndi:BPMNLabel />
59
+ </bpmndi:BPMNShape>
60
+ <bpmndi:BPMNShape id="Activity_1b7fiqp_di" bpmnElement="Activity_0ma3kzt">
61
+ <dc:Bounds x="340" y="130" width="100" height="80" />
62
+ <bpmndi:BPMNLabel />
63
+ </bpmndi:BPMNShape>
64
+ <bpmndi:BPMNShape id="Event_134k5nt_di" bpmnElement="Event_0o7qlkd">
65
+ <dc:Bounds x="392" y="192" width="36" height="36" />
66
+ </bpmndi:BPMNShape>
67
+ <bpmndi:BPMNEdge id="Flow_0qmxzxk_di" bpmnElement="Flow_0qmxzxk">
68
+ <di:waypoint x="128" y="170" />
69
+ <di:waypoint x="180" y="170" />
70
+ </bpmndi:BPMNEdge>
71
+ <bpmndi:BPMNEdge id="Flow_16dfeac_di" bpmnElement="Flow_16dfeac">
72
+ <di:waypoint x="280" y="170" />
73
+ <di:waypoint x="340" y="170" />
74
+ </bpmndi:BPMNEdge>
75
+ <bpmndi:BPMNEdge id="Flow_0mo4oek_di" bpmnElement="Flow_0mo4oek">
76
+ <di:waypoint x="440" y="170" />
77
+ <di:waypoint x="502" y="170" />
78
+ </bpmndi:BPMNEdge>
79
+ <bpmndi:BPMNEdge id="Flow_0y6es1p_di" bpmnElement="Flow_0y6es1p">
80
+ <di:waypoint x="410" y="228" />
81
+ <di:waypoint x="410" y="290" />
82
+ <di:waypoint x="482" y="290" />
83
+ </bpmndi:BPMNEdge>
84
+ <bpmndi:BPMNShape id="TextAnnotation_0lbjt7p_di" bpmnElement="TextAnnotation_0lbjt7p">
85
+ <dc:Bounds x="370" y="50" width="169.99387960829492" height="39.99855990783411" />
86
+ <bpmndi:BPMNLabel />
87
+ </bpmndi:BPMNShape>
88
+ <bpmndi:BPMNEdge id="Association_0ivfgz1_di" bpmnElement="Association_0ivfgz1">
89
+ <di:waypoint x="401" y="130" />
90
+ <di:waypoint x="413" y="90" />
91
+ </bpmndi:BPMNEdge>
92
+ </bpmndi:BPMNPlane>
93
+ </bpmndi:BPMNDiagram>
94
+ </bpmn:definitions>
@@ -3,45 +3,46 @@
3
3
  category: 'ProcessCube',
4
4
  color: '#02AFD6',
5
5
  defaults: {
6
- name: { value: '' },
7
- engine: { value: '', type: 'processcube-engine-config' },
8
- query: { value: 'payload' },
9
- query_type: { value: 'msg' },
6
+ name: {value: ""},
7
+ engine: {value: "", type: "processcube-engine-config"},
8
+ query: {value: "payload"},
9
+ query_type: {value: "msg"}
10
10
  },
11
11
  inputs: 1,
12
12
  outputs: 1,
13
- icon: 'font-awesome/fa-envelope-open',
14
- label: function () {
15
- return this.name || 'processinstance-query';
13
+ icon: "font-awesome/fa-envelope-open",
14
+ label: function() {
15
+ return this.name || "processinstance-query";
16
16
  },
17
- oneditprepare: function () {
18
- $('#node-input-query').typedInput({
17
+ oneditprepare: function() {
18
+ $("#node-input-query").typedInput({
19
19
  default: 'msg',
20
- types: ['msg', 'json'],
20
+ types: ['msg', 'json']
21
21
  });
22
22
 
23
- $('#node-input-query').typedInput('value', this.query);
24
- $('#node-input-query').typedInput('type', this.query_type);
25
- },
26
- oneditsave: function () {
27
- (this.query = $('#node-input-query').typedInput('value')),
28
- (this.query_type = $('#node-input-query').typedInput('type'));
23
+ $("#node-input-query").typedInput('value', this.query);
24
+ $("#node-input-query").typedInput('type', this.query_type);
29
25
  },
26
+ oneditsave: function() {
27
+ this.query = $("#node-input-query").typedInput('value'),
28
+ this.query_type = $("#node-input-query").typedInput('type')
29
+
30
+ }
30
31
  });
31
32
  </script>
32
33
 
33
34
  <script type="text/html" data-template-name="processinstance-query">
34
35
  <div class="form-row">
35
36
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
36
- <input type="text" id="node-input-name" placeholder="Name" />
37
+ <input type="text" id="node-input-name" placeholder="Name">
37
38
  </div>
38
39
  <div class="form-row">
39
40
  <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
40
- <input type="text" id="node-input-engine" placeholder="http://engine:8000" />
41
+ <input type="text" id="node-input-engine" placeholder="http://engine:8000">
41
42
  </div>
42
43
  <div class="form-row">
43
44
  <label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
44
- <input type="text" id="node-input-query" />
45
+ <input type="text" id="node-input-query">
45
46
  </div>
46
47
  </script>
47
48
 
@@ -1,53 +1,46 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
6
  module.exports = function (RED) {
7
7
  function ProcessinstanceQuery(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 engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
+ const client = this.engine.getEngineClient();
16
15
 
17
- var client = nodeContext.get('client');
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('emitter', new EventEmitter());
28
- eventEmitter = flowContext.get('emitter');
19
+ flowContext.set("emitter", new EventEmitter());
20
+ eventEmitter = flowContext.get("emitter");
29
21
  }
30
22
 
31
- node.on('close', async () => {
23
+ node.on("close", async () => {
32
24
  client.dispose();
33
25
  client = null;
34
26
  });
35
27
 
36
- node.on('input', function (msg) {
37
- let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
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
 
39
36
  client.processInstances
40
37
  .query(query, { identity: node.server.identity })
41
38
  .then((matchingInstances) => {
42
- console.log(matchingInstances);
43
39
  msg.payload = matchingInstances;
44
40
 
45
41
  node.send(msg);
46
- })
47
- .catch((error) => {
48
- node.error(`Processinstancequery failed: ${error.message}`);
49
42
  });
50
43
  });
51
44
  }
52
- RED.nodes.registerType('processinstance-query', ProcessinstanceQuery);
45
+ RED.nodes.registerType("processinstance-query", ProcessinstanceQuery);
53
46
  };
@@ -1,41 +1,41 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('signal-event-trigger', {
2
+ RED.nodes.registerType('signal-event-trigger',{
3
3
  category: 'ProcessCube',
4
4
  color: '#02AFD6',
5
5
  defaults: {
6
- name: { value: '' },
7
- engine: { value: '', type: 'processcube-engine-config' },
8
- signalname: { value: '', required: true },
9
- processInstanceId: { value: '' },
6
+ name: {value: ""},
7
+ engine: {value: "", type: "processcube-engine-config"},
8
+ signalname: {value: "", required: true},
9
+ processInstanceId: {value:""}
10
10
  },
11
11
  inputs: 1,
12
12
  outputs: 1,
13
- icon: 'font-awesome/fa-envelope-open',
14
- label: function () {
15
- return this.name || 'signal-event-trigger';
16
- },
13
+ icon: "font-awesome/fa-envelope-open",
14
+ label: function() {
15
+ return this.name||"signal-event-trigger";
16
+ }
17
17
  });
18
18
  </script>
19
19
 
20
20
  <script type="text/html" data-template-name="signal-event-trigger">
21
21
  <div class="form-row">
22
22
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
23
- <input type="text" id="node-input-name" placeholder="Name" />
23
+ <input type="text" id="node-input-name" placeholder="Name">
24
24
  </div>
25
25
  <div class="form-row">
26
26
  <label for="node-input-engine"><i class="fa fa-tag"></i> Engine</label>
27
- <input type="text" id="node-input-engine" placeholder="Engine" />
27
+ <input type="text" id="node-input-engine" placeholder="Engine">
28
28
  </div>
29
29
  <div class="form-row">
30
30
  <label for="node-input-signalname"><i class="fa fa-tag"></i> Signal Name</label>
31
- <input type="text" id="node-input-signalname" placeholder="Name of the Signal" />
31
+ <input type="text" id="node-input-signalname" placeholder="Name of the Signal">
32
32
  </div>
33
33
  <div class="form-row">
34
34
  <label for="node-input-processinstanceid"><i class="fa fa-tag"></i> Process Instance Id</label>
35
- <input type="text" id="node-input-processinstanceid" placeholder="Id of the recipient process instance" />
35
+ <input type="text" id="node-input-processinstanceid" placeholder="Id of the recipient process instance">
36
36
  </div>
37
37
  </script>
38
38
 
39
39
  <script type="text/html" data-help-name="signal-event-trigger">
40
40
  <p>A node which emmits a signal event to the Engine.</p>
41
- </script>
41
+ </script>
@@ -1,25 +1,17 @@
1
- const process = require('process');
1
+ const process = require("process");
2
2
 
3
- const engine_client = require('@5minds/processcube_engine_client');
3
+ const engine_client = require("@5minds/processcube_engine_client");
4
4
 
5
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 engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
12
+ const client = this.engine.getEngineClient();
14
13
 
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) {
14
+ node.on("input", function (msg) {
23
15
  client.events
24
16
  .triggerSignalEvent(config.signalname, {
25
17
  processInstanceId: config.processinstanceid,
@@ -30,12 +22,16 @@ module.exports = function (RED) {
30
22
  msg.payload = result;
31
23
 
32
24
  node.send(msg);
33
- node.status({ fill: 'blue', shape: 'dot', text: `signal event triggered` });
25
+ node.status({
26
+ fill: "blue",
27
+ shape: "dot",
28
+ text: `signal event triggered`,
29
+ });
34
30
  })
35
31
  .catch((error) => {
36
32
  node.error(error);
37
33
  });
38
34
  });
39
35
  }
40
- RED.nodes.registerType('signal-event-trigger', SignalEventTrigger);
36
+ RED.nodes.registerType("signal-event-trigger", SignalEventTrigger);
41
37
  };
@@ -1,39 +1,34 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('usertask-finished-listener', {
2
+ RED.nodes.registerType('usertask-finished-listener',{
3
3
  category: 'ProcessCube Events',
4
4
  color: '#02AFD6',
5
5
  defaults: {
6
- name: { value: '' },
7
- engine: { value: '', type: 'processcube-engine-config' },
8
- multisend: { value: false },
6
+ name: {value: ""},
7
+ engine: {value: "", type: "processcube-engine-config"},
8
+ multisend: {value: false}
9
9
  },
10
10
  inputs: 0,
11
11
  outputs: 1,
12
- icon: 'font-awesome/fa-envelope',
13
- label: function () {
14
- return this.name || 'usertask-finished-listener';
15
- },
12
+ icon: "font-awesome/fa-envelope",
13
+ label: function() {
14
+ return this.name || "usertask-finished-listener";
15
+ }
16
16
  });
17
17
  </script>
18
18
 
19
19
  <script type="text/html" data-template-name="usertask-finished-listener">
20
20
  <div class="form-row">
21
21
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
22
- <input type="text" id="node-input-name" placeholder="Name" />
22
+ <input type="text" id="node-input-name" placeholder="Name">
23
23
  </div>
24
24
  <div class="form-row">
25
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" />
26
+ <input type="text" id="node-input-engine" placeholder="http://engine:8000">
27
27
  </div>
28
28
  <div class="form-row" style="display:flex; margin-bottom: 3px;">
29
29
  <label for="node-input-multisend" style="vertical-align:top"><i class="fa fa-list-alt"></i> Send multi</label>
30
30
  <div>
31
- <input
32
- type="checkbox"
33
- checked
34
- id="node-input-multisend"
35
- style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;"
36
- />
31
+ <input type="checkbox" checked id="node-input-multisend" style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;">
37
32
  <label style="width:auto" for="node-input-multisend">Send one output of each usertask input?</label>
38
33
  </div>
39
34
  </div>
@@ -41,4 +36,4 @@
41
36
 
42
37
  <script type="text/html" data-help-name="usertask-finished-listener">
43
38
  <p>A node which subscribes to an User Task of https://processcube.io</p>
44
- </script>
39
+ </script>
@@ -1,31 +1,23 @@
1
- const process = require('process');
2
- const EventEmitter = require('node:events');
1
+ const process = require("process");
2
+ const EventEmitter = require("node:events");
3
3
 
4
- const engine_client = require('@5minds/processcube_engine_client');
4
+ const engine_client = require("@5minds/processcube_engine_client");
5
5
 
6
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 engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
14
+ const client = this.engine.getEngineClient();
16
15
 
17
- var client = nodeContext.get('client');
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('emitter', new EventEmitter());
28
- eventEmitter = flowContext.get('emitter');
19
+ flowContext.set("emitter", new EventEmitter());
20
+ eventEmitter = flowContext.get("emitter");
29
21
  }
30
22
 
31
23
  const register = async () => {
@@ -34,35 +26,43 @@ module.exports = function (RED) {
34
26
  (userTaskFinishedNotification) => {
35
27
  node.send({
36
28
  payload: {
37
- flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
38
- action: 'finished',
39
- type: 'usertask',
29
+ flowNodeInstanceId:
30
+ userTaskFinishedNotification.flowNodeInstanceId,
31
+ action: "finished",
32
+ type: "usertask",
40
33
  },
41
34
  });
42
35
  },
43
- { identity: currentIdentity },
36
+ { identity: currentIdentity }
44
37
  );
45
38
 
46
39
  node.server.registerOnIdentityChanged(async (identity) => {
47
- client.userTasks.removeSubscription(subscription, currentIdentity);
40
+ client.userTasks.removeSubscription(
41
+ subscription,
42
+ currentIdentity
43
+ );
48
44
  currentIdentity = identity;
49
45
 
50
46
  subscription = await client.userTasks.onUserTaskFinished(
51
47
  (userTaskFinishedNotification) => {
52
48
  node.send({
53
49
  payload: {
54
- flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
55
- action: 'finished',
56
- type: 'usertask',
50
+ flowNodeInstanceId:
51
+ userTaskFinishedNotification.flowNodeInstanceId,
52
+ action: "finished",
53
+ type: "usertask",
57
54
  },
58
55
  });
59
56
  },
60
- { identity: currentIdentity },
57
+ { identity: currentIdentity }
61
58
  );
62
59
  });
63
60
 
64
- node.on('close', async () => {
65
- client.userTasks.removeSubscription(subscription, currentIdentity);
61
+ node.on("close", async () => {
62
+ client.userTasks.removeSubscription(
63
+ subscription,
64
+ currentIdentity
65
+ );
66
66
  client.dispose();
67
67
  client = null;
68
68
  });
@@ -72,5 +72,8 @@ module.exports = function (RED) {
72
72
  register();
73
73
  }
74
74
  }
75
- RED.nodes.registerType('usertask-finished-listener', UserTaskFinishedListener);
75
+ RED.nodes.registerType(
76
+ "usertask-finished-listener",
77
+ UserTaskFinishedListener
78
+ );
76
79
  };