@5minds/node-red-contrib-processcube 1.5.10 → 1.5.11
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.
- package/endevent-finished-listener.js +1 -1
- package/package.json +1 -1
- package/process-event-listener.js +8 -8
- package/process-start.js +11 -2
- package/process-terminate.js +1 -1
- package/processcube-engine-config.js +1 -1
- package/processdefinition-query.js +1 -1
- package/processinstance-delete.html +56 -9
- package/processinstance-delete.js +28 -9
- package/signal-event-trigger.js +1 -1
- package/usertask-event-listener.js +1 -1
- package/usertask-input.js +1 -1
- package/usertask-output.js +1 -1
- package/wait-for-usertask.js +2 -2
package/package.json
CHANGED
@@ -68,7 +68,7 @@ module.exports = function (RED) {
|
|
68
68
|
});
|
69
69
|
}
|
70
70
|
} catch (error) {
|
71
|
-
node.error(error);
|
71
|
+
node.error(JSON.stringify(error));
|
72
72
|
}
|
73
73
|
},
|
74
74
|
{ identity: currentIdentity }
|
@@ -111,7 +111,7 @@ module.exports = function (RED) {
|
|
111
111
|
});
|
112
112
|
}
|
113
113
|
} catch (error) {
|
114
|
-
node.error(error);
|
114
|
+
node.error(JSON.stringify(error));
|
115
115
|
}
|
116
116
|
},
|
117
117
|
{ identity: currentIdentity }
|
@@ -152,7 +152,7 @@ module.exports = function (RED) {
|
|
152
152
|
});
|
153
153
|
}
|
154
154
|
} catch (error) {
|
155
|
-
node.error(error);
|
155
|
+
node.error(JSON.stringify(error));
|
156
156
|
}
|
157
157
|
},
|
158
158
|
{ identity: currentIdentity }
|
@@ -194,7 +194,7 @@ module.exports = function (RED) {
|
|
194
194
|
});
|
195
195
|
}
|
196
196
|
} catch (error) {
|
197
|
-
node.error(error);
|
197
|
+
node.error(JSON.stringify(error));
|
198
198
|
}
|
199
199
|
},
|
200
200
|
{ identity: currentIdentity }
|
@@ -234,7 +234,7 @@ module.exports = function (RED) {
|
|
234
234
|
});
|
235
235
|
}
|
236
236
|
} catch (error) {
|
237
|
-
node.error(error);
|
237
|
+
node.error(JSON.stringify(error));
|
238
238
|
}
|
239
239
|
},
|
240
240
|
{ identity: currentIdentity }
|
@@ -275,7 +275,7 @@ module.exports = function (RED) {
|
|
275
275
|
});
|
276
276
|
}
|
277
277
|
} catch (error) {
|
278
|
-
node.error(error);
|
278
|
+
node.error(JSON.stringify(error));
|
279
279
|
}
|
280
280
|
},
|
281
281
|
{ identity: currentIdentity }
|
@@ -315,7 +315,7 @@ module.exports = function (RED) {
|
|
315
315
|
});
|
316
316
|
}
|
317
317
|
} catch (error) {
|
318
|
-
node.error(error);
|
318
|
+
node.error(JSON.stringify(error));
|
319
319
|
}
|
320
320
|
},
|
321
321
|
{ identity: currentIdentity }
|
@@ -355,7 +355,7 @@ module.exports = function (RED) {
|
|
355
355
|
});
|
356
356
|
}
|
357
357
|
} catch (error) {
|
358
|
-
node.error(error);
|
358
|
+
node.error(JSON.stringify(error));
|
359
359
|
}
|
360
360
|
},
|
361
361
|
{ identity: currentIdentity }
|
package/process-start.js
CHANGED
@@ -4,7 +4,6 @@ module.exports = function (RED) {
|
|
4
4
|
var node = this;
|
5
5
|
|
6
6
|
node.on('input', function (msg) {
|
7
|
-
|
8
7
|
const initialToken = RED.util.encodeObject(msg.payload);
|
9
8
|
|
10
9
|
const startParameters = {
|
@@ -13,6 +12,16 @@ module.exports = function (RED) {
|
|
13
12
|
initialToken: initialToken,
|
14
13
|
};
|
15
14
|
|
15
|
+
if (!startParameters.processModelId) {
|
16
|
+
node.error('No processModelId configured.');
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
|
20
|
+
if (!startParameters.startEventId) {
|
21
|
+
node.error('No startEventId configured.');
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
|
16
25
|
const engine = RED.nodes.getNode(config.engine);
|
17
26
|
const client = engine.engineClient;
|
18
27
|
|
@@ -34,7 +43,7 @@ module.exports = function (RED) {
|
|
34
43
|
});
|
35
44
|
})
|
36
45
|
.catch((error) => {
|
37
|
-
node.error(error);
|
46
|
+
node.error(JSON.stringify(error));
|
38
47
|
});
|
39
48
|
});
|
40
49
|
}
|
package/process-terminate.js
CHANGED
@@ -6,8 +6,9 @@
|
|
6
6
|
name: { value: '' },
|
7
7
|
engine: { value: '', type: 'processcube-engine-config' },
|
8
8
|
modelid: { value: '' },
|
9
|
-
|
10
|
-
|
9
|
+
duration: { value: '', type: 'number' },
|
10
|
+
time_unit: { value: 'hours' },
|
11
|
+
batch_size: { value: '100', type: 'number' },
|
11
12
|
},
|
12
13
|
inputs: 1,
|
13
14
|
outputs: 1,
|
@@ -32,16 +33,20 @@
|
|
32
33
|
<input type="text" id="node-input-modelid" />
|
33
34
|
</div>
|
34
35
|
<div class="form-row">
|
35
|
-
<label for="node-input-
|
36
|
-
<input type="text" id="node-input-
|
36
|
+
<label for="node-input-duration"><i class="fa fa-tag"></i> Duration</label>
|
37
|
+
<input type="text" id="node-input-duration" />
|
37
38
|
</div>
|
38
39
|
<div class="form-row">
|
39
|
-
<label for="node-input-
|
40
|
-
<select id="node-input-
|
40
|
+
<label for="node-input-time_unit"><i class="fa fa-sliders"></i> Time Unit</label>
|
41
|
+
<select id="node-input-time_unit" style="width: 70%;">
|
41
42
|
<option value="hours">Hours</option>
|
42
43
|
<option value="days">Days</option>
|
43
44
|
</select>
|
44
45
|
</div>
|
46
|
+
<div class="form-row">
|
47
|
+
<label for="node-input-batch-size"><i class="fa fa-tag"></i> Batch Size</label>
|
48
|
+
<input type="text" id="node-input-batch_size" />
|
49
|
+
</div>
|
45
50
|
</script>
|
46
51
|
|
47
52
|
<script type="text/markdown" data-help-name="processinstance-delete">
|
@@ -49,12 +54,54 @@ Delete old instances of a process model in the ProcessCube.
|
|
49
54
|
|
50
55
|
## Inputs
|
51
56
|
|
52
|
-
: payload.
|
53
|
-
: payload.
|
57
|
+
: payload.duration (number): The number of given time periods.
|
58
|
+
: payload.time_unit ('hours' | 'days'): The type of time period to use.
|
59
|
+
: payload.batch_size (number): The number of instances to be deleted simultaneously. (default 100)
|
54
60
|
|
55
61
|
## Outputs
|
56
62
|
|
57
|
-
:
|
63
|
+
: Explanation of the payload:
|
64
|
+
|
65
|
+
Object
|
66
|
+
{
|
67
|
+
successfulDeletions: [Array of strings],
|
68
|
+
failedDeletions: [Array of objects]
|
69
|
+
}
|
70
|
+
|
71
|
+
- successfulDeletions:
|
72
|
+
- Type: Array<String>
|
73
|
+
- Content: A list of successfully deleted process instance IDs.
|
74
|
+
|
75
|
+
- excample:
|
76
|
+
successfulDeletions: [
|
77
|
+
"instanceId1",
|
78
|
+
"instanceId2",
|
79
|
+
"instanceId3"
|
80
|
+
]
|
81
|
+
|
82
|
+
- failedDeletions:
|
83
|
+
- Type: Array<Object>
|
84
|
+
- Content: A list of objects containing details of the failed deletions.
|
85
|
+
- Each object has the following fields:
|
86
|
+
- id: The ID of the process instance that could not be deleted.
|
87
|
+
- error: The error message or the reason for the error.
|
88
|
+
|
89
|
+
- Example of a complete output:
|
90
|
+
{
|
91
|
+
successfulDeletions: [
|
92
|
+
"instanceId1",
|
93
|
+
"instanceId2",
|
94
|
+
"instanceId3"
|
95
|
+
],
|
96
|
+
failedDeletions: [
|
97
|
+
{ id: "instanceId4", error: "Permission denied" },
|
98
|
+
{ id: "instanceId5", error: "Instance not found" }
|
99
|
+
]
|
100
|
+
}
|
101
|
+
|
102
|
+
The node processes the IDs in configurable batches (default value: 100) and inserts successfully deleted or failed instances into the arrays accordingly.
|
103
|
+
As processing is currently forced to batch, a detailed error output is not possible.
|
104
|
+
If an error occurs during the processing of a batch, all Id's of this batch are marked as faulty.
|
58
105
|
|
59
106
|
### References
|
60
107
|
|
@@ -11,14 +11,15 @@ module.exports = function (RED) {
|
|
11
11
|
node.error('No engine configured.');
|
12
12
|
return;
|
13
13
|
}
|
14
|
+
|
14
15
|
let timeMultiplier;
|
15
|
-
if (msg.payload.
|
16
|
-
timeMultiplier = msg.payload.
|
16
|
+
if (msg.payload.time_unit) {
|
17
|
+
timeMultiplier = msg.payload.time_unit == 'hours' ? 1 : 24;
|
17
18
|
} else {
|
18
|
-
timeMultiplier = config.
|
19
|
+
timeMultiplier = config.time_unit == 'hours' ? 1 : 24;
|
19
20
|
}
|
20
21
|
|
21
|
-
const timeToUse = msg.payload.
|
22
|
+
const timeToUse = msg.payload.duration ? msg.payload.duration : config.duration;
|
22
23
|
const modelId = msg.payload.processModelId
|
23
24
|
? msg.payload.processModelId != ''
|
24
25
|
? msg.payload.processModelId
|
@@ -27,12 +28,14 @@ module.exports = function (RED) {
|
|
27
28
|
? config.modelid
|
28
29
|
: undefined;
|
29
30
|
|
31
|
+
const batchSize = config.batch_size || 100; // Konfigurierbare Batchgröße, Standardwert 100
|
32
|
+
|
30
33
|
try {
|
31
34
|
const result = await client.processInstances.query({
|
32
35
|
processModelId: modelId
|
33
36
|
}, { identity: engine.identity });
|
34
37
|
|
35
|
-
let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended');
|
38
|
+
let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended' && instance.state != 'running');
|
36
39
|
|
37
40
|
const today = new Date();
|
38
41
|
|
@@ -43,12 +46,28 @@ module.exports = function (RED) {
|
|
43
46
|
});
|
44
47
|
|
45
48
|
const ids = oldTasks.map((obj) => obj.processInstanceId);
|
46
|
-
msg.payload = ids;
|
47
49
|
|
48
|
-
|
50
|
+
msg.payload = {
|
51
|
+
successfulDeletions: [],
|
52
|
+
failedDeletions: []
|
53
|
+
};
|
54
|
+
|
55
|
+
for (let i = 0; i < ids.length; i += batchSize) {
|
56
|
+
const batch = ids.slice(i, i + batchSize);
|
57
|
+
try {
|
58
|
+
await client.processInstances.deleteProcessInstances(batch, true, engine.identity);
|
59
|
+
msg.payload.successfulDeletions.push(...batch); // Erfolgreiche IDs hinzufügen
|
60
|
+
} catch (deleteError) {
|
61
|
+
batch.forEach(id => {
|
62
|
+
msg.payload.failedDeletions.push({ id, error: deleteError.message }); // Fehler protokollieren
|
63
|
+
});
|
64
|
+
node.warn(`Failed to delete process instances in batch: ${batch.join(', ')}. Error: ${deleteError.message}`);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
49
68
|
node.send(msg);
|
50
|
-
} catch (
|
51
|
-
node.error(
|
69
|
+
} catch (queryError) {
|
70
|
+
node.error(`Failed to query process instances: ${queryError.message}`);
|
52
71
|
}
|
53
72
|
});
|
54
73
|
}
|
package/signal-event-trigger.js
CHANGED
package/usertask-input.js
CHANGED
package/usertask-output.js
CHANGED
package/wait-for-usertask.js
CHANGED
@@ -43,7 +43,7 @@ module.exports = function (RED) {
|
|
43
43
|
// nothing todo - wait for next notification
|
44
44
|
}
|
45
45
|
} catch (error) {
|
46
|
-
node.error(error);
|
46
|
+
node.error(JSON.stringify(error));
|
47
47
|
}
|
48
48
|
},
|
49
49
|
{ identity: currentIdentity }
|
@@ -75,7 +75,7 @@ module.exports = function (RED) {
|
|
75
75
|
// let the *currentIdentity* be active
|
76
76
|
}
|
77
77
|
} catch (error) {
|
78
|
-
node.error(error);
|
78
|
+
node.error(JSON.stringify(error));
|
79
79
|
}
|
80
80
|
}
|
81
81
|
};
|