@5minds/node-red-contrib-processcube 1.1.4-feature-f2c5f6-m22xalfy → 1.1.4-feature-80ab18-m24judvf
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@5minds/node-red-contrib-processcube",
|
3
|
-
"version": "1.1.4-feature-
|
3
|
+
"version": "1.1.4-feature-80ab18-m24judvf",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"scripts": {
|
@@ -45,6 +45,7 @@
|
|
45
45
|
"processEventListener": "process-event-listener.js",
|
46
46
|
"processcubeEngineConfig": "processcube-engine-config.js",
|
47
47
|
"ProcessinstanceQuery": "processinstance-query.js",
|
48
|
+
"ProcessinstanceDelete": "processinstance-delete.js",
|
48
49
|
"ProcessdefinitionQuery": "processdefinition-query.js",
|
49
50
|
"messageEventTrigger": "message-event-trigger.js",
|
50
51
|
"signalEventTrigger": "signal-event-trigger.js",
|
@@ -2,40 +2,16 @@
|
|
2
2
|
RED.nodes.registerType('processcube-engine-config', {
|
3
3
|
category: 'config',
|
4
4
|
defaults: {
|
5
|
-
name: { value: '' },
|
5
|
+
name : { value: '' },
|
6
6
|
url: { value: 'http://engine:8000', required: true },
|
7
|
-
clientId: { value: '' },
|
8
|
-
clientIdType: { type: 'str' },
|
9
|
-
clientSecret: { value: '' },
|
10
|
-
clientSecretType: { type: 'str' },
|
11
7
|
},
|
12
8
|
label: function () {
|
13
9
|
return this.name || this.url;
|
14
10
|
},
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
});
|
20
|
-
|
21
|
-
$('#node-config-input-clientSecret').typedInput({
|
22
|
-
default: 'str',
|
23
|
-
types: ['str', 'global', 'flow', 'env', 'msg', 'cred'],
|
24
|
-
});
|
25
|
-
|
26
|
-
$('#node-config-input-clientId').typedInput('value', this.clientId);
|
27
|
-
$('#node-config-input-clientId').typedInput('type', this.clientIdType);
|
28
|
-
|
29
|
-
$('#node-config-input-clientSecret').typedInput('value', this.clientSecret);
|
30
|
-
$('#node-config-input-clientSecret').typedInput('type', this.clientSecretType);
|
31
|
-
},
|
32
|
-
oneditsave: function () {
|
33
|
-
this.clientId = $('#node-config-input-clientId').typedInput('value');
|
34
|
-
this.clientIdType = $('#node-config-input-clientId').typedInput('type');
|
35
|
-
|
36
|
-
this.clientSecret = $('#node-config-input-clientSecret').typedInput('value');
|
37
|
-
this.clientSecretType = $('#node-config-input-clientSecret').typedInput('type');
|
38
|
-
},
|
11
|
+
credentials: {
|
12
|
+
clientId: { type: 'text' },
|
13
|
+
clientSecret: { type: 'password' },
|
14
|
+
}
|
39
15
|
});
|
40
16
|
</script>
|
41
17
|
|
@@ -69,6 +45,7 @@ The configuration for the ProcessCube engine.
|
|
69
45
|
|
70
46
|
### References
|
71
47
|
|
72
|
-
-
|
73
|
-
-
|
48
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
49
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
50
|
+
|
74
51
|
</script>
|
@@ -11,21 +11,18 @@ module.exports = function (RED) {
|
|
11
11
|
const identityChangedCallbacks = [];
|
12
12
|
this.url = n.url;
|
13
13
|
this.identity = null;
|
14
|
-
|
15
|
-
this.credentials.clientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
|
16
|
-
this.credentials.clientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
|
17
|
-
|
14
|
+
|
18
15
|
this.registerOnIdentityChanged = function (callback) {
|
19
16
|
identityChangedCallbacks.push(callback);
|
20
17
|
};
|
21
18
|
|
22
|
-
this.isIdentityReady = function
|
19
|
+
this.isIdentityReady = function() {
|
23
20
|
if (this.credentials.clientId && this.credentials.clientSecret) {
|
24
21
|
return this.identity != null;
|
25
22
|
} else {
|
26
23
|
return true;
|
27
24
|
}
|
28
|
-
}
|
25
|
+
}
|
29
26
|
|
30
27
|
this.setIdentity = (identity) => {
|
31
28
|
node.log(`setIdentity: ${JSON.stringify(identity)}`);
|
@@ -53,7 +50,7 @@ module.exports = function (RED) {
|
|
53
50
|
this.credentials.clientId,
|
54
51
|
this.credentials.clientSecret,
|
55
52
|
authorityUrl,
|
56
|
-
node
|
53
|
+
node,
|
57
54
|
).catch((reason) => {
|
58
55
|
console.error(reason);
|
59
56
|
node.error(reason);
|
@@ -139,7 +136,7 @@ async function startRefreshingIdentityCycle(clientId, clientSecret, authorityUrl
|
|
139
136
|
if (retries === 0) {
|
140
137
|
console.error(
|
141
138
|
'Could not refresh identity for external task worker processes. Stopping all external task workers.',
|
142
|
-
{ error }
|
139
|
+
{ error },
|
143
140
|
);
|
144
141
|
return;
|
145
142
|
}
|
@@ -16,27 +16,23 @@
|
|
16
16
|
<bpmn:userTask id="user_task" name="User Task">
|
17
17
|
<bpmn:extensionElements>
|
18
18
|
<camunda:formData>
|
19
|
-
<camunda:formField id="checkbox" label="
|
20
|
-
<camunda:formField id="
|
21
|
-
<camunda:formField id="
|
22
|
-
<camunda:formField id="
|
23
|
-
<camunda:formField id="
|
24
|
-
<camunda:formField id="
|
25
|
-
<camunda:formField id="
|
26
|
-
<camunda:formField id="
|
27
|
-
<camunda:formField id="
|
28
|
-
<camunda:formField id="
|
29
|
-
<camunda:formField id="
|
30
|
-
<camunda:formField id="
|
31
|
-
<camunda:formField id="
|
32
|
-
<camunda:formField id="
|
33
|
-
<camunda:formField id="
|
34
|
-
<camunda:formField id="
|
35
|
-
<camunda:formField id="
|
36
|
-
<camunda:formField id="textarea" label="Textarea" type="textarea" defaultValue="jkljklj" customForm="{"rows":14,"hint":"hint"}" />
|
37
|
-
<camunda:formField id="time" label="Time" type="time" defaultValue="11:54" customForm="{"hint":"hint"}" />
|
38
|
-
<camunda:formField id="url" label="URL" type="url" customForm="{"hint":"hint"}" />
|
39
|
-
<camunda:formField id="week" label="Week" type="week" defaultValue="2024-W37" customForm="{"hint":"hint"}" />
|
19
|
+
<camunda:formField id="checkbox" label="Checkox" type="checkbox" defaultValue="true" customForm="{"hint":"hintttt","entries":[{"key":"value","value":"Label"}]}" />
|
20
|
+
<camunda:formField id="color" label="Color" type="color" defaultValue="#cd2323" />
|
21
|
+
<camunda:formField id="date-time-local" label="Datetime Local" type="datetime-local" customForm="{"hint":"jljkkljlk"}" />
|
22
|
+
<camunda:formField id="email" label="Email" type="email" customForm="{"hint":"hklojh","placeholder":"luis@luis.de"}" />
|
23
|
+
<camunda:formField id="header" type="header" defaultValue="This is a Heading" customForm="{"style":"heading_2"}" />
|
24
|
+
<camunda:formField id="hidden" type="hidden" defaultValue="jkljlkj" />
|
25
|
+
<camunda:formField id="month" label="Month" type="month" customForm="{"hint":"this is a hint for month"}" />
|
26
|
+
<camunda:formField id="paragraph" type="paragraph" defaultValue="This is a paragraph." />
|
27
|
+
<camunda:formField id="password" label="Password" type="password" customForm="{"hint":"Dont use smt i can guess"}" />
|
28
|
+
<camunda:formField id="radio" label="Radio" type="radio" customForm="{"entries":[{"key":"value","value":"Label"},{"key":"value2","value":"Label2"}]}" />
|
29
|
+
<camunda:formField id="range" label="Range" type="range" customForm="{"step":1,"min":100,"max":1000}" />
|
30
|
+
<camunda:formField id="select" label="Select" type="select" customForm="{"entries":[{"key":"value","value":"Label"},{"key":"value","value":"Label"}],"placeholder":"Select Something"}" />
|
31
|
+
<camunda:formField id="tele" label="Tel." type="tel" customForm="{"hint":"jkl","placeholder":"110"}" />
|
32
|
+
<camunda:formField id="textarea" label="Textarea" type="textarea" defaultValue="jkl" customForm="{"placeholder":"placeholder"}" />
|
33
|
+
<camunda:formField id="time" label="Time" type="time" customForm="{"hint":"jkl","placeholder":"12:0000"}" />
|
34
|
+
<camunda:formField id="url" label="URL" type="url" customForm="{"placeholder":"http://","hint":"no youtube"}" />
|
35
|
+
<camunda:formField id="week" label="Week" type="week" customForm="{"hint":"What week?"}" />
|
40
36
|
</camunda:formData>
|
41
37
|
</bpmn:extensionElements>
|
42
38
|
<bpmn:incoming>Flow_142awo6</bpmn:incoming>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
RED.nodes.registerType('processinstance-delete', {
|
3
|
+
category: 'ProcessCube DevOps',
|
4
|
+
color: '#02AFD6',
|
5
|
+
defaults: {
|
6
|
+
name: { value: '' },
|
7
|
+
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
+
time: { value: '', type: 'number' },
|
9
|
+
time_type: { value: 'hours' },
|
10
|
+
},
|
11
|
+
inputs: 1,
|
12
|
+
outputs: 1,
|
13
|
+
icon: 'font-awesome/fa-sign-in',
|
14
|
+
label: function () {
|
15
|
+
return this.name || 'processinstance-delete';
|
16
|
+
},
|
17
|
+
});
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<script type="text/html" data-template-name="processinstance-delete">
|
21
|
+
<div class="form-row">
|
22
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
23
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
24
|
+
</div>
|
25
|
+
<div class="form-row">
|
26
|
+
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
27
|
+
<input type="text" id="node-input-engine" placeholder="Engine-URL" />
|
28
|
+
</div>
|
29
|
+
<div class="form-row">
|
30
|
+
<label for="node-input-time"><i class="fa fa-tag"></i> Time</label>
|
31
|
+
<input type="text" id="node-input-time" />
|
32
|
+
</div>
|
33
|
+
<div class="form-row">
|
34
|
+
<label for="node-input-time_type"><i class="fa fa-sliders"></i> Period</label>
|
35
|
+
<select id="node-input-time_type" style="width: 70%;">
|
36
|
+
<option value="hours">Hours</option>
|
37
|
+
<option value="days">Days</option>
|
38
|
+
</select>
|
39
|
+
</div>
|
40
|
+
</script>
|
41
|
+
|
42
|
+
<script type="text/markdown" data-help-name="processinstance-delete">
|
43
|
+
Delete old instances of a process model in the ProcessCube.
|
44
|
+
|
45
|
+
## Inputs
|
46
|
+
|
47
|
+
: payload.time (number): The number of given time periods.
|
48
|
+
: payload.time_type ('hours' | 'days'): The type of time period to use.
|
49
|
+
|
50
|
+
## Outputs
|
51
|
+
|
52
|
+
: payload (string[]): The ids of the processinstances that were deleted.
|
53
|
+
|
54
|
+
### References
|
55
|
+
|
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©
|
58
|
+
</script>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module.exports = function (RED) {
|
2
|
+
function ProcessInstanceDelete(config) {
|
3
|
+
RED.nodes.createNode(this, config);
|
4
|
+
var node = this;
|
5
|
+
|
6
|
+
node.on('input', async function (msg) {
|
7
|
+
const engine = RED.nodes.getNode(config.engine);
|
8
|
+
const client = engine.engineClient;
|
9
|
+
|
10
|
+
if (!client) {
|
11
|
+
node.error('No engine configured.');
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
let timeMultiplier;
|
15
|
+
if (msg.payload.time_type) {
|
16
|
+
timeMultiplier = msg.payload.time_type == 'hours' ? 1 : 24;
|
17
|
+
} else {
|
18
|
+
timeMultiplier = config.time_type == 'hours' ? 1 : 24;
|
19
|
+
}
|
20
|
+
|
21
|
+
const timeToUse = msg.payload.time ? msg.payload.time : config.time;
|
22
|
+
|
23
|
+
try {
|
24
|
+
const fetchInstancesByState = async (state) => {
|
25
|
+
const result = await client.processInstances.query({ state });
|
26
|
+
return result.processInstances;
|
27
|
+
};
|
28
|
+
|
29
|
+
const finishedInstances = await fetchInstancesByState('finished');
|
30
|
+
const terminatedInstances = await fetchInstancesByState('terminated');
|
31
|
+
const errorInstances = await fetchInstancesByState('error');
|
32
|
+
|
33
|
+
let allInstances = [...finishedInstances, ...terminatedInstances, ...errorInstances];
|
34
|
+
|
35
|
+
const today = new Date();
|
36
|
+
|
37
|
+
const oldTasks = allInstances.filter((instance) => {
|
38
|
+
const finishedDate = new Date(instance.finishedAt);
|
39
|
+
const diffInHours = (today - finishedDate) / (1000 * 60 * 60);
|
40
|
+
return diffInHours > Number(timeToUse) * timeMultiplier;
|
41
|
+
});
|
42
|
+
|
43
|
+
const ids = oldTasks.map((obj) => obj.processInstanceId);
|
44
|
+
msg.payload = ids;
|
45
|
+
|
46
|
+
await client.processInstances.deleteProcessInstances(ids, true, engine.identity);
|
47
|
+
node.send(msg);
|
48
|
+
} catch (error) {
|
49
|
+
node.error(error);
|
50
|
+
}
|
51
|
+
});
|
52
|
+
}
|
53
|
+
|
54
|
+
RED.nodes.registerType('processinstance-delete', ProcessInstanceDelete);
|
55
|
+
};
|