@5minds/node-red-contrib-processcube 1.2.3-feature-241db2-m21w1ewd → 1.2.3-feature-4125f7-m22xj9q1
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@5minds/node-red-contrib-processcube",
|
3
|
-
"version": "1.2.3-feature-
|
3
|
+
"version": "1.2.3-feature-4125f7-m22xj9q1",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"scripts": {
|
@@ -52,8 +52,7 @@
|
|
52
52
|
"UserTaskNewListener": "usertask-new-listener.js",
|
53
53
|
"UserTaskFinishedListener": "usertask-finished-listener.js",
|
54
54
|
"UserTaskInput": "usertask-input.js",
|
55
|
-
"UserTaskOutput": "usertask-output.js"
|
56
|
-
"WaitForUsertask": "wait-for-usertask.js"
|
55
|
+
"UserTaskOutput": "usertask-output.js"
|
57
56
|
},
|
58
57
|
"examples": "examples"
|
59
58
|
},
|
@@ -2,16 +2,40 @@
|
|
2
2
|
RED.nodes.registerType('processcube-engine-config', {
|
3
3
|
category: 'config',
|
4
4
|
defaults: {
|
5
|
-
name
|
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' },
|
7
11
|
},
|
8
12
|
label: function () {
|
9
13
|
return this.name || this.url;
|
10
14
|
},
|
11
|
-
|
12
|
-
clientId
|
13
|
-
|
14
|
-
|
15
|
+
oneditprepare: function () {
|
16
|
+
$('#node-config-input-clientId').typedInput({
|
17
|
+
default: 'str',
|
18
|
+
types: ['str', 'global', 'flow', 'env', 'msg', 'cred'],
|
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
|
+
},
|
15
39
|
});
|
16
40
|
</script>
|
17
41
|
|
@@ -11,18 +11,21 @@ module.exports = function (RED) {
|
|
11
11
|
const identityChangedCallbacks = [];
|
12
12
|
this.url = n.url;
|
13
13
|
this.identity = null;
|
14
|
-
|
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
|
+
|
15
18
|
this.registerOnIdentityChanged = function (callback) {
|
16
19
|
identityChangedCallbacks.push(callback);
|
17
20
|
};
|
18
21
|
|
19
|
-
this.isIdentityReady = function() {
|
22
|
+
this.isIdentityReady = function () {
|
20
23
|
if (this.credentials.clientId && this.credentials.clientSecret) {
|
21
24
|
return this.identity != null;
|
22
25
|
} else {
|
23
26
|
return true;
|
24
27
|
}
|
25
|
-
}
|
28
|
+
};
|
26
29
|
|
27
30
|
this.setIdentity = (identity) => {
|
28
31
|
node.log(`setIdentity: ${JSON.stringify(identity)}`);
|
@@ -50,7 +53,7 @@ module.exports = function (RED) {
|
|
50
53
|
this.credentials.clientId,
|
51
54
|
this.credentials.clientSecret,
|
52
55
|
authorityUrl,
|
53
|
-
node
|
56
|
+
node
|
54
57
|
).catch((reason) => {
|
55
58
|
console.error(reason);
|
56
59
|
node.error(reason);
|
@@ -136,7 +139,7 @@ async function startRefreshingIdentityCycle(clientId, clientSecret, authorityUrl
|
|
136
139
|
if (retries === 0) {
|
137
140
|
console.error(
|
138
141
|
'Could not refresh identity for external task worker processes. Stopping all external task workers.',
|
139
|
-
{ error }
|
142
|
+
{ error }
|
140
143
|
);
|
141
144
|
return;
|
142
145
|
}
|
@@ -16,23 +16,27 @@
|
|
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="
|
19
|
+
<camunda:formField id="checkbox" label="Checkbox" type="checkbox" customForm="{"entries":[{"key":"key","value":"value"}],"hint":"hint"}" />
|
20
|
+
<camunda:formField id="colorpicker" label="Colorpicker" type="color" defaultValue="#e32626" customForm="{"hint":"hint"}" />
|
21
|
+
<camunda:formField id="confirm" label="Confirm" type="confirm" customForm="{"confirmButtonText":"Confirm","declineButtonText":"Decline"}" />
|
22
|
+
<camunda:formField id="date" label="Date" type="date" defaultValue="2024-10-18" customForm="{"hint":"hint"}" />
|
23
|
+
<camunda:formField id="datetime" label="Datetime" type="datetime-local" defaultValue="2024-10-19T12:41" customForm="{"hint":"hint"}" />
|
24
|
+
<camunda:formField id="email" label="Email" type="email" customForm="{"hint":"hint"}" />
|
25
|
+
<camunda:formField id="header" type="header" defaultValue="Header" />
|
26
|
+
<camunda:formField id="hidden" type="hidden" defaultValue="hidden" />
|
27
|
+
<camunda:formField id="number" label="Number" type="number" customForm="{"step":1.5,"hint":"hint"}" />
|
28
|
+
<camunda:formField id="month" label="Month" type="month" defaultValue="2024-07" customForm="{"hint":"hint"}" />
|
29
|
+
<camunda:formField id="paragraph" type="paragraph" defaultValue="bla bla" />
|
30
|
+
<camunda:formField id="password" label="Pasword" type="password" customForm="{"hint":"hint"}" />
|
31
|
+
<camunda:formField id="radio" label="Radio" type="radio" customForm="{"entries":[{"key":"key","value":"value"}],"hint":"hint"}" />
|
32
|
+
<camunda:formField id="range" label="Range" type="range" defaultValue="30" customForm="{"step":0.4,"min":3,"hint":"hint"}" />
|
33
|
+
<camunda:formField id="select" label="Select" type="select" customForm="{"entries":[{"key":"key","value":"value"}],"hint":"hint"}" />
|
34
|
+
<camunda:formField id="tel" label="Tel." type="tel" customForm="{"hint":"hint"}" />
|
35
|
+
<camunda:formField id="text" label="Text" type="string" customForm="{"hint":"hint"}" />
|
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"}" />
|
36
40
|
</camunda:formData>
|
37
41
|
</bpmn:extensionElements>
|
38
42
|
<bpmn:incoming>Flow_142awo6</bpmn:incoming>
|
package/wait-for-usertask.html
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
<script type="text/javascript">
|
2
|
-
RED.nodes.registerType('wait-for-usertask',{
|
3
|
-
category: 'ProcessCube',
|
4
|
-
color: '#02AFD6',
|
5
|
-
defaults: {
|
6
|
-
name: {value: ""},
|
7
|
-
engine: {value: "", type: "processcube-engine-config"},
|
8
|
-
query: {value: "payload"},
|
9
|
-
query_type: {value: "msg"},
|
10
|
-
only_for_new: {value: false}
|
11
|
-
},
|
12
|
-
inputs: 1,
|
13
|
-
outputs: 1,
|
14
|
-
icon: "font-awesome/fa-envelope-open",
|
15
|
-
label: function() {
|
16
|
-
return this.name || "wait-for-usertask";
|
17
|
-
},
|
18
|
-
oneditprepare: function() {
|
19
|
-
$("#node-input-query").typedInput({
|
20
|
-
default: 'msg',
|
21
|
-
types: ['msg', 'json']
|
22
|
-
});
|
23
|
-
|
24
|
-
$("#node-input-query").typedInput('value', this.query);
|
25
|
-
$("#node-input-query").typedInput('type', this.query_type);
|
26
|
-
},
|
27
|
-
oneditsave: function() {
|
28
|
-
this.query = $("#node-input-query").typedInput('value'),
|
29
|
-
this.query_type = $("#node-input-query").typedInput('type')
|
30
|
-
|
31
|
-
}
|
32
|
-
});
|
33
|
-
</script>
|
34
|
-
|
35
|
-
<script type="text/html" data-template-name="wait-for-usertask">
|
36
|
-
<div class="form-row">
|
37
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
38
|
-
<input type="text" id="node-input-name" placeholder="Name">
|
39
|
-
</div>
|
40
|
-
<div class="form-row">
|
41
|
-
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
42
|
-
<input type="text" id="node-input-engine" placeholder="http://engine:8000">
|
43
|
-
</div>
|
44
|
-
<div class="form-row">
|
45
|
-
<label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
|
46
|
-
<input type="text" id="node-input-query">
|
47
|
-
</div>
|
48
|
-
<div class="form-row" style="display:flex; margin-bottom: 3px;">
|
49
|
-
<label for="node-input-only_for_new" style="vertical-align:top"><i class="fa fa-list-alt"></i> Only for new</label>
|
50
|
-
<div>
|
51
|
-
<input type="checkbox" checked id="node-input-only_for_new" style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;">
|
52
|
-
<label style="width:auto" for="node-input-multisend">Trigger only for new user task or *checked* also for old ones?</label>
|
53
|
-
</div>
|
54
|
-
</div>
|
55
|
-
</script>
|
56
|
-
|
57
|
-
<script type="text/markdown" data-help-name="wait-for-usertask">
|
58
|
-
Waiting for Usertasks of the connected ProcessCube Engine.
|
59
|
-
|
60
|
-
### Inputs
|
61
|
-
|
62
|
-
: payload (json) : the query to filter the usertasks.
|
63
|
-
|
64
|
-
## Outputs
|
65
|
-
|
66
|
-
: payload.userTask (string) : The filtered UserTask
|
67
|
-
|
68
|
-
### Details
|
69
|
-
|
70
|
-
- `msg.payload` or a constant json to filter the UserTasks for Waiting for
|
71
|
-
- `Only for new` will trigger only for new UserTasks if checked and also for old ones if not checked.
|
72
|
-
|
73
|
-
### References
|
74
|
-
|
75
|
-
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© Plattform
|
76
|
-
</script>
|
package/wait-for-usertask.js
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
|
3
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
4
|
-
const { userInfo } = require('os');
|
5
|
-
|
6
|
-
module.exports = function (RED) {
|
7
|
-
function WaitForUsertask(config) {
|
8
|
-
RED.nodes.createNode(this, config);
|
9
|
-
var node = this;
|
10
|
-
var nodeContext = node.context();
|
11
|
-
|
12
|
-
this.engine = this.server = RED.nodes.getNode(config.engine);
|
13
|
-
|
14
|
-
const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
|
15
|
-
|
16
|
-
var client = nodeContext.get('client');
|
17
|
-
|
18
|
-
if (!client) {
|
19
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
20
|
-
client = nodeContext.get('client');
|
21
|
-
}
|
22
|
-
|
23
|
-
|
24
|
-
let currentIdentity = null;
|
25
|
-
let subscription = null;
|
26
|
-
|
27
|
-
node.on('input', async function (msg) {
|
28
|
-
if (node.server) {
|
29
|
-
currentIdentity = node.server.identity;
|
30
|
-
} else {
|
31
|
-
node.error("No processcube_config node found.")
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
36
|
-
|
37
|
-
subscription = await client.userTasks.onUserTaskWaiting(async (userTaskWaitingNotification) => {
|
38
|
-
|
39
|
-
const newQuery = {
|
40
|
-
'flowNodeInstanceId': userTaskWaitingNotification.flowNodeInstanceId,
|
41
|
-
...query
|
42
|
-
};
|
43
|
-
|
44
|
-
const matchingFlowNodes = await client.userTasks.query(newQuery, { identity: currentIdentity });
|
45
|
-
|
46
|
-
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
47
|
-
const userTask = matchingFlowNodes.userTasks[0];
|
48
|
-
|
49
|
-
msg.payload = { userTask: userTask };
|
50
|
-
node.send(msg);
|
51
|
-
} else {
|
52
|
-
// nothing todo - wait for next notification
|
53
|
-
}
|
54
|
-
|
55
|
-
// remove subscription
|
56
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
57
|
-
}, { identity: currentIdentity });
|
58
|
-
|
59
|
-
console.debug('Handling old userTasks config.only_for_new', config.only_for_new);
|
60
|
-
|
61
|
-
if (config.only_for_new === false) {
|
62
|
-
// only check suspended user tasks
|
63
|
-
const suspendedQuery = {
|
64
|
-
'state': 'suspended',
|
65
|
-
...query
|
66
|
-
};
|
67
|
-
|
68
|
-
const matchingFlowNodes = await client.userTasks.query(suspendedQuery, { identity: currentIdentity });
|
69
|
-
|
70
|
-
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
|
71
|
-
const userTask = matchingFlowNodes.userTasks[0];
|
72
|
-
|
73
|
-
msg.payload = { userTask: userTask };
|
74
|
-
node.send(msg);
|
75
|
-
|
76
|
-
// remove subscription
|
77
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
78
|
-
} else {
|
79
|
-
// let the *currentIdentity* be active
|
80
|
-
}
|
81
|
-
}
|
82
|
-
});
|
83
|
-
|
84
|
-
node.on("close", async () => {
|
85
|
-
if (client != null) {
|
86
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
87
|
-
client.dispose();
|
88
|
-
client = null;
|
89
|
-
}
|
90
|
-
});
|
91
|
-
}
|
92
|
-
RED.nodes.registerType("wait-for-usertask", WaitForUsertask);
|
93
|
-
}
|