@5minds/node-red-contrib-processcube 1.5.1-feature-6ba46c-m2lk79r9 → 1.5.2-feature-4db23e-m33j5ixt
Sign up to get free protection for your applications and to get access to all the features.
- package/externaltask-input.js +2 -9
- package/package.json +1 -1
- package/processcube-engine-config.js +72 -25
- package/processinstance-delete.html +16 -11
- package/processinstance-delete.js +12 -9
package/externaltask-input.js
CHANGED
@@ -98,7 +98,7 @@ module.exports = function (RED) {
|
|
98
98
|
task: RED.util.encodeObject(externalTask),
|
99
99
|
payload: payload,
|
100
100
|
flowNodeInstanceId: externalTask.flowNodeInstanceId,
|
101
|
-
processInstanceId: externalTask.processInstanceId
|
101
|
+
processInstanceId: externalTask.processInstanceId
|
102
102
|
};
|
103
103
|
|
104
104
|
node.log(
|
@@ -110,11 +110,7 @@ module.exports = function (RED) {
|
|
110
110
|
};
|
111
111
|
|
112
112
|
client.externalTasks
|
113
|
-
.subscribeToExternalTaskTopic(
|
114
|
-
config.topic,
|
115
|
-
etwCallback,
|
116
|
-
RED.util.evaluateNodeProperty(config.workerConfig, 'json', node)
|
117
|
-
)
|
113
|
+
.subscribeToExternalTaskTopic(config.topic, etwCallback, RED.util.evaluateNodeProperty(config.workerConfig, 'json', node))
|
118
114
|
.then(async (externalTaskWorker) => {
|
119
115
|
node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
|
120
116
|
|
@@ -139,9 +135,6 @@ module.exports = function (RED) {
|
|
139
135
|
|
140
136
|
showStatus(node, Object.keys(started_external_tasks).length);
|
141
137
|
break;
|
142
|
-
case 'fetchAndLock':
|
143
|
-
node.status({});
|
144
|
-
node.error(`Worker error ${errorType}: ${error.message}`);
|
145
138
|
default:
|
146
139
|
node.error(`Worker error ${errorType}: ${error.message}`);
|
147
140
|
break;
|
package/package.json
CHANGED
@@ -12,8 +12,52 @@ module.exports = function (RED) {
|
|
12
12
|
this.url = RED.util.evaluateNodeProperty(n.url, n.urlType, node);
|
13
13
|
this.identity = null;
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
async function startUpdatingCredentialsCycle() {
|
16
|
+
let retries = 5;
|
17
|
+
const UPDATE_INTERVAL = 10000;
|
18
|
+
let previousClientId, previousClientSecret;
|
19
|
+
|
20
|
+
const updateCredentials = async () => {
|
21
|
+
try {
|
22
|
+
const newClientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
|
23
|
+
const newClientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
|
24
|
+
|
25
|
+
if (newClientId !== previousClientId || newClientSecret !== previousClientSecret) {
|
26
|
+
if (this.engineClient) this.engineClient.dispose();
|
27
|
+
|
28
|
+
this.credentials.clientId = newClientId;
|
29
|
+
this.credentials.clientSecret = newClientSecret;
|
30
|
+
|
31
|
+
this.engineClient = new engine_client.EngineClient(this.url);
|
32
|
+
|
33
|
+
if (this.credentials.clientId && this.credentials.clientSecret) {
|
34
|
+
const authorityUrl = await this.engineClient.applicationInfo.getAuthorityAddress();
|
35
|
+
startRefreshingIdentityCycle(
|
36
|
+
this.credentials.clientId,
|
37
|
+
this.credentials.clientSecret,
|
38
|
+
authorityUrl,
|
39
|
+
node
|
40
|
+
).catch(console.error);
|
41
|
+
}
|
42
|
+
|
43
|
+
previousClientId = newClientId;
|
44
|
+
previousClientSecret = newClientSecret;
|
45
|
+
}
|
46
|
+
|
47
|
+
retries = 5;
|
48
|
+
setTimeout(updateCredentials, UPDATE_INTERVAL);
|
49
|
+
} catch (error) {
|
50
|
+
if (retries === 0) return console.error('Credential update failed permanently:', error);
|
51
|
+
console.error('Credential update error, retrying:', { error, retries });
|
52
|
+
retries--;
|
53
|
+
setTimeout(updateCredentials, 2000);
|
54
|
+
}
|
55
|
+
};
|
56
|
+
|
57
|
+
await updateCredentials();
|
58
|
+
}
|
59
|
+
|
60
|
+
console.log('luis888', this.credentials.clientId);
|
17
61
|
|
18
62
|
this.registerOnIdentityChanged = function (callback) {
|
19
63
|
identityChangedCallbacks.push(callback);
|
@@ -43,29 +87,32 @@ module.exports = function (RED) {
|
|
43
87
|
}
|
44
88
|
});
|
45
89
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
90
|
+
startUpdatingCredentialsCycle();
|
91
|
+
|
92
|
+
// if (this.credentials.clientId && this.credentials.clientSecret) {
|
93
|
+
// console.log('luis999', this.credentials.clientId);
|
94
|
+
// this.engineClient = new engine_client.EngineClient(this.url);
|
95
|
+
|
96
|
+
// this.engineClient.applicationInfo
|
97
|
+
// .getAuthorityAddress()
|
98
|
+
// .then((authorityUrl) => {
|
99
|
+
// startRefreshingIdentityCycle(
|
100
|
+
// this.credentials.clientId,
|
101
|
+
// this.credentials.clientSecret,
|
102
|
+
// authorityUrl,
|
103
|
+
// node
|
104
|
+
// ).catch((reason) => {
|
105
|
+
// console.error(reason);
|
106
|
+
// node.error(reason);
|
107
|
+
// });
|
108
|
+
// })
|
109
|
+
// .catch((reason) => {
|
110
|
+
// console.error(reason);
|
111
|
+
// node.error(reason);
|
112
|
+
// });
|
113
|
+
// } else {
|
114
|
+
// this.engineClient = new engine_client.EngineClient(this.url);
|
115
|
+
// }
|
69
116
|
}
|
70
117
|
RED.nodes.registerType('processcube-engine-config', ProcessCubeEngineNode, {
|
71
118
|
credentials: {
|
@@ -5,6 +5,7 @@
|
|
5
5
|
defaults: {
|
6
6
|
name: { value: '' },
|
7
7
|
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
+
modelid: { value: '' },
|
8
9
|
time: { value: '', type: 'number' },
|
9
10
|
time_type: { value: 'hours' },
|
10
11
|
},
|
@@ -27,11 +28,15 @@
|
|
27
28
|
<input type="text" id="node-input-engine" placeholder="Engine-URL" />
|
28
29
|
</div>
|
29
30
|
<div class="form-row">
|
30
|
-
<label for="node-input-
|
31
|
+
<label for="node-input-modelid"><i class="fa fa-tag"></i> Model-ID</label>
|
32
|
+
<input type="text" id="node-input-modelid" />
|
33
|
+
</div>
|
34
|
+
<div class="form-row">
|
35
|
+
<label for="node-input-time"><i class="fa fa-tag"></i> Duration</label>
|
31
36
|
<input type="text" id="node-input-time" />
|
32
37
|
</div>
|
33
38
|
<div class="form-row">
|
34
|
-
<label for="node-input-time_type"><i class="fa fa-sliders"></i>
|
39
|
+
<label for="node-input-time_type"><i class="fa fa-sliders"></i> Time Unit</label>
|
35
40
|
<select id="node-input-time_type" style="width: 70%;">
|
36
41
|
<option value="hours">Hours</option>
|
37
42
|
<option value="days">Days</option>
|
@@ -40,19 +45,19 @@
|
|
40
45
|
</script>
|
41
46
|
|
42
47
|
<script type="text/markdown" data-help-name="processinstance-delete">
|
43
|
-
Delete old instances of a process model in the ProcessCube.
|
48
|
+
Delete old instances of a process model in the ProcessCube.
|
44
49
|
|
45
|
-
## Inputs
|
50
|
+
## Inputs
|
46
51
|
|
47
|
-
: payload.time (number): The number of given time periods.
|
48
|
-
: payload.time_type ('hours' | 'days'): The type of time period to use.
|
52
|
+
: payload.time (number): The number of given time periods.
|
53
|
+
: payload.time_type ('hours' | 'days'): The type of time period to use.
|
49
54
|
|
50
|
-
## Outputs
|
55
|
+
## Outputs
|
51
56
|
|
52
|
-
: payload (string[]): The ids of the processinstances that were deleted.
|
57
|
+
: payload (string[]): The ids of the processinstances that were deleted.
|
53
58
|
|
54
|
-
### References
|
59
|
+
### References
|
55
60
|
|
56
|
-
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
57
|
-
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
61
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
62
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
58
63
|
</script>
|
@@ -19,18 +19,21 @@ module.exports = function (RED) {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
const timeToUse = msg.payload.time ? msg.payload.time : config.time;
|
22
|
+
const modelId = msg.payload.processModelId
|
23
|
+
? msg.payload.processModelId != ''
|
24
|
+
? msg.payload.processModelId
|
25
|
+
: undefined
|
26
|
+
: config.modelid != ''
|
27
|
+
? config.modelid
|
28
|
+
: undefined;
|
22
29
|
|
23
30
|
try {
|
24
|
-
const
|
25
|
-
|
26
|
-
|
27
|
-
};
|
28
|
-
|
29
|
-
const finishedInstances = await fetchInstancesByState('finished');
|
30
|
-
const terminatedInstances = await fetchInstancesByState('terminated');
|
31
|
-
const errorInstances = await fetchInstancesByState('error');
|
31
|
+
const result = await client.processInstances.query({
|
32
|
+
processModelId: modelId,
|
33
|
+
identity: engine.identity,
|
34
|
+
});
|
32
35
|
|
33
|
-
let allInstances =
|
36
|
+
let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended');
|
34
37
|
|
35
38
|
const today = new Date();
|
36
39
|
|