@5minds/node-red-contrib-processcube 1.5.10-feature-495a3f-m4mrvan4 → 1.5.10-feature-1657ec-m4r2pgad

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.
@@ -6,6 +6,17 @@ module.exports = function (RED) {
6
6
 
7
7
  let subscription = null;
8
8
 
9
+ const eventEmitter = node.engine.eventEmitter;
10
+
11
+ eventEmitter.on('engine-client-dispose', () => {
12
+ node.engine.engineClient.events.removeSubscription(subscription, node.engine.identity);
13
+ });
14
+
15
+ eventEmitter.on('engine-client-changed', () => {
16
+ node.log('new engineClient received');
17
+ register();
18
+ });
19
+
9
20
  const register = async () => {
10
21
  const client = node.engine.engineClient;
11
22
 
@@ -14,19 +25,39 @@ module.exports = function (RED) {
14
25
  return;
15
26
  }
16
27
 
28
+ let currentIdentity = node.engine.identity;
29
+
17
30
  try {
18
- subscription = await client.events.onEndEventFinished((endEventFinished) => {
19
- node.send({
20
- payload: endEventFinished,
21
- });
31
+ subscription = await client.events.onEndEventFinished(
32
+ (endEventFinished) => {
33
+ node.send({
34
+ payload: endEventFinished,
35
+ });
36
+ },
37
+ { identity: currentIdentity }
38
+ );
39
+
40
+ node.engine.registerOnIdentityChanged(async (identity) => {
41
+ client.events.removeSubscription(subscription, currentIdentity);
42
+
43
+ currentIdentity = identity;
44
+
45
+ subscription = await client.events.onEndEventFinished(
46
+ (endEventFinished) => {
47
+ node.send({
48
+ payload: endEventFinished,
49
+ });
50
+ },
51
+ { identity: currentIdentity }
52
+ );
22
53
  });
23
54
  } catch (error) {
24
- node.error(error);
55
+ node.error(JSON.stringify(error));
25
56
  }
26
57
 
27
58
  node.on('close', async () => {
28
59
  if (node.engine && node.engine.engineClient && client) {
29
- client.events.removeSubscription(subscription);
60
+ client.events.removeSubscription(subscription, currentIdentity);
30
61
  }
31
62
  });
32
63
  };
@@ -6,7 +6,20 @@ module.exports = function (RED) {
6
6
 
7
7
  let subscription;
8
8
 
9
+ const eventEmitter = node.engine.eventEmitter;
10
+
11
+ eventEmitter.on('engine-client-dispose', () => {
12
+ node.engine.engineClient.notification.removeSubscription(subscription, node.engine.identity);
13
+ });
14
+
15
+ eventEmitter.on('engine-client-changed', () => {
16
+ node.log('new engineClient received');
17
+ register();
18
+ });
19
+
9
20
  const register = async () => {
21
+ let currentIdentity = node.engine.identity;
22
+
10
23
  const client = node.engine.engineClient;
11
24
 
12
25
  if (!client) {
@@ -31,21 +44,38 @@ module.exports = function (RED) {
31
44
  async function subscribe() {
32
45
  switch (config.eventtype) {
33
46
  case 'created':
34
- return await client.notification.onExternalTaskCreated(externalTaskCallback());
47
+ return await client.notification.onExternalTaskCreated(externalTaskCallback(), {
48
+ identity: currentIdentity,
49
+ });
35
50
  case 'locked':
36
- return await client.notification.onExternalTaskLocked(externalTaskCallback());
51
+ return await client.notification.onExternalTaskLocked(externalTaskCallback(), {
52
+ identity: currentIdentity,
53
+ });
37
54
  case 'unlocked':
38
- return await client.notification.onExternalTaskUnlocked(externalTaskCallback());
55
+ return await client.notification.onExternalTaskUnlocked(externalTaskCallback(), {
56
+ identity: currentIdentity,
57
+ });
39
58
  default:
40
59
  console.error('no such event: ' + config.eventtype);
41
60
  }
42
61
  }
43
62
 
44
- subscription = subscribe();
63
+ if (node.engine.isIdentityReady()) {
64
+ subscription = subscribe();
65
+ }
66
+
67
+ node.engine.registerOnIdentityChanged(async (identity) => {
68
+ if (subscription) {
69
+ client.notification.removeSubscription(subscription, currentIdentity);
70
+ }
71
+ currentIdentity = identity;
72
+
73
+ subscription = subscribe();
74
+ });
45
75
 
46
76
  node.on('close', async () => {
47
77
  if (node.engine && node.engine.engineClient && client) {
48
- client.notification.removeSubscription(subscription);
78
+ client.notification.removeSubscription(subscription, currentIdentity);
49
79
  }
50
80
  });
51
81
  };
@@ -16,7 +16,7 @@ module.exports = function (RED) {
16
16
  var node = this;
17
17
  var flowContext = node.context().flow;
18
18
 
19
- node.engine = RED.nodes.getNode(config.engine);
19
+ const engine = RED.nodes.getNode(config.engine);
20
20
 
21
21
  var eventEmitter = flowContext.get('emitter');
22
22
 
@@ -25,6 +25,13 @@ module.exports = function (RED) {
25
25
  eventEmitter = flowContext.get('emitter');
26
26
  }
27
27
 
28
+ const engineEventEmitter = engine.eventEmitter;
29
+
30
+ engineEventEmitter.on('engine-client-changed', () => {
31
+ node.log('new engineClient received');
32
+ register();
33
+ });
34
+
28
35
  const register = async () => {
29
36
  if (node.etw) {
30
37
  try {
@@ -34,7 +41,7 @@ module.exports = function (RED) {
34
41
  node.log(`cant close etw: ${JSON.stringify(node.etw)}`);
35
42
  }
36
43
  }
37
- const client = node.engine.engineClient;
44
+ const client = engine.engineClient;
38
45
 
39
46
  if (!client) {
40
47
  node.error('No engine configured.');
@@ -126,6 +133,11 @@ module.exports = function (RED) {
126
133
 
127
134
  node.etw = externalTaskWorker;
128
135
 
136
+ externalTaskWorker.identity = engine.identity;
137
+ engine.registerOnIdentityChanged((identity) => {
138
+ externalTaskWorker.identity = identity;
139
+ });
140
+
129
141
  // export type WorkerErrorHandler = (errorType: 'fetchAndLock' | 'extendLock' | 'processExternalTask' | 'finishExternalTask', error: Error, externalTask?: ExternalTask<any>) => void;
130
142
  externalTaskWorker.onWorkerError((errorType, error, externalTask) => {
131
143
  switch (errorType) {
@@ -173,7 +185,7 @@ module.exports = function (RED) {
173
185
  });
174
186
  };
175
187
 
176
- if (node.engine) {
188
+ if (engine) {
177
189
  register();
178
190
  }
179
191
  }
@@ -4,18 +4,20 @@ module.exports = function (RED) {
4
4
  var node = this;
5
5
 
6
6
  node.on('input', function (msg) {
7
- node.engine = RED.nodes.getNode(config.engine);
8
- const client = node.engine.engineClient;
7
+
8
+ const engine = RED.nodes.getNode(config.engine);
9
+ const client = engine.engineClient;
9
10
 
10
11
  if (!client) {
11
12
  node.error('No engine configured.');
12
13
  return;
13
14
  }
14
15
 
15
- node.engine.engineClient.events
16
+ engine.engineClient.events
16
17
  .triggerMessageEvent(config.messagename, {
17
18
  processInstanceId: msg.processinstanceid,
18
19
  payload: msg.payload,
20
+ identity: engine.identity,
19
21
  })
20
22
  .then((result) => {
21
23
  msg.payload = result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.5.10-feature-495a3f-m4mrvan4",
3
+ "version": "1.5.10-feature-1657ec-m4r2pgad",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -57,7 +57,7 @@
57
57
  "examples": "examples"
58
58
  },
59
59
  "dependencies": {
60
- "@5minds/processcube_engine_client": "5.1.1",
60
+ "@5minds/processcube_engine_client": "5.1.0-hotfix-a73235-m346kg1n",
61
61
  "jwt-decode": "^4.0.0",
62
62
  "openid-client": "^5.5.0"
63
63
  },