@5minds/node-red-contrib-processcube 1.2.3-feature-a741c4-m22yefrw → 1.2.3-feature-0915a5-m22z2faz
Sign up to get free protection for your applications and to get access to all the features.
package/externaltask-input.html
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
name: { value: '' },
|
7
7
|
engine: { value: '', type: 'processcube-engine-config' },
|
8
8
|
topic: { value: '' },
|
9
|
+
workerConfig: { value: '', type: 'json' },
|
9
10
|
},
|
10
11
|
inputs: 0,
|
11
12
|
outputs: 1,
|
@@ -13,6 +14,15 @@
|
|
13
14
|
label: function () {
|
14
15
|
return this.name || 'externaltask-input';
|
15
16
|
},
|
17
|
+
oneditprepare: function () {
|
18
|
+
$('#node-input-workerConfig').typedInput({
|
19
|
+
default: 'json',
|
20
|
+
types: ['json'],
|
21
|
+
});
|
22
|
+
},
|
23
|
+
oneditsave: function () {
|
24
|
+
this.workerConfig = $('#node-input-workerConfig').typedInput('value');
|
25
|
+
},
|
16
26
|
});
|
17
27
|
</script>
|
18
28
|
|
@@ -29,6 +39,10 @@
|
|
29
39
|
<label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
|
30
40
|
<input type="text" id="node-input-topic" placeholder="Topic of ExternalTask" />
|
31
41
|
</div>
|
42
|
+
<div class="form-row"></div>
|
43
|
+
<label for="node-input-workerConfig"><i class="fa fa-tag"></i> Worker Config</label>
|
44
|
+
<input type="text" id="node-input-workerConfig" />
|
45
|
+
</div>
|
32
46
|
</script>
|
33
47
|
|
34
48
|
<script type="text/markdown" data-help-name="externaltask-input">
|
package/externaltask-input.js
CHANGED
@@ -16,7 +16,7 @@ module.exports = function (RED) {
|
|
16
16
|
var node = this;
|
17
17
|
var flowContext = node.context().flow;
|
18
18
|
|
19
|
-
const engine =
|
19
|
+
const engine = RED.nodes.getNode(config.engine);
|
20
20
|
|
21
21
|
const client = engine.engineClient;
|
22
22
|
|
@@ -32,83 +32,85 @@ module.exports = function (RED) {
|
|
32
32
|
eventEmitter = flowContext.get('emitter');
|
33
33
|
}
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
};
|
35
|
+
const etwCallback = async (payload, externalTask) => {
|
36
|
+
const saveHandleCallback = (data, callback) => {
|
37
|
+
try {
|
38
|
+
callback(data);
|
39
|
+
} catch (error) {
|
40
|
+
node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
|
41
|
+
}
|
42
|
+
};
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
return await new Promise((resolve, reject) => {
|
45
|
+
const handleFinishTask = (msg) => {
|
46
|
+
let result = RED.util.encodeObject(msg.payload);
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
node.log(
|
49
|
+
`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`
|
50
|
+
);
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
if (externalTask.flowNodeInstanceId) {
|
53
|
+
delete started_external_tasks[externalTask.flowNodeInstanceId];
|
54
|
+
}
|
56
55
|
|
57
|
-
|
56
|
+
showStatus(node, Object.keys(started_external_tasks).length);
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
//resolve(result);
|
59
|
+
saveHandleCallback(result, resolve);
|
60
|
+
};
|
61
|
+
|
62
|
+
const handleErrorTask = (msg) => {
|
63
|
+
node.log(
|
64
|
+
`handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`
|
65
|
+
);
|
62
66
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
);
|
67
|
+
if (externalTask.flowNodeInstanceId) {
|
68
|
+
delete started_external_tasks[externalTask.flowNodeInstanceId];
|
69
|
+
}
|
67
70
|
|
68
|
-
|
69
|
-
delete started_external_tasks[externalTask.flowNodeInstanceId];
|
70
|
-
}
|
71
|
+
showStatus(node, Object.keys(started_external_tasks).length);
|
71
72
|
|
72
|
-
|
73
|
+
// TODO: with reject, the default error handling is proceed
|
74
|
+
// SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
|
75
|
+
// reject(result);
|
76
|
+
//resolve(msg);
|
77
|
+
saveHandleCallback(msg, resolve);
|
78
|
+
};
|
73
79
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
saveHandleCallback(msg, resolve);
|
79
|
-
};
|
80
|
+
eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
|
81
|
+
node.log(
|
82
|
+
`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`
|
83
|
+
);
|
80
84
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
);
|
85
|
+
if (isError) {
|
86
|
+
handleErrorTask(msg);
|
87
|
+
} else {
|
88
|
+
handleFinishTask(msg);
|
89
|
+
}
|
90
|
+
});
|
85
91
|
|
86
|
-
|
87
|
-
handleErrorTask(msg);
|
88
|
-
} else {
|
89
|
-
handleFinishTask(msg);
|
90
|
-
}
|
91
|
-
});
|
92
|
+
started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
|
92
93
|
|
93
|
-
|
94
|
+
showStatus(node, Object.keys(started_external_tasks).length);
|
94
95
|
|
95
|
-
|
96
|
+
let msg = {
|
97
|
+
_msgid: RED.util.generateId(),
|
98
|
+
task: RED.util.encodeObject(externalTask),
|
99
|
+
payload: payload,
|
100
|
+
flowNodeInstanceId: externalTask.flowNodeInstanceId,
|
101
|
+
processInstanceId: externalTask.processInstanceId
|
102
|
+
};
|
96
103
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
payload: payload,
|
101
|
-
flowNodeInstanceId: externalTask.flowNodeInstanceId,
|
102
|
-
processInstanceId: externalTask.processInstanceId
|
103
|
-
};
|
104
|
+
node.log(
|
105
|
+
`Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`
|
106
|
+
);
|
104
107
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
+
node.send(msg);
|
109
|
+
});
|
110
|
+
};
|
108
111
|
|
109
|
-
|
110
|
-
|
111
|
-
})
|
112
|
+
client.externalTasks
|
113
|
+
.subscribeToExternalTaskTopic(config.topic, etwCallback, config.workerConfig)
|
112
114
|
.then(async (externalTaskWorker) => {
|
113
115
|
node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
|
114
116
|
|
package/package.json
CHANGED
@@ -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
|
|
@@ -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,26 +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="date" label="
|
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="time" label="Time" type="time" defaultValue="11:54" customForm="{"hint":"hint"}" />
|
37
|
-
<camunda:formField id="url" label="URL" type="url" customForm="{"hint":"hint"}" />
|
38
|
-
<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?"}" />
|
39
36
|
</camunda:formData>
|
40
37
|
</bpmn:extensionElements>
|
41
38
|
<bpmn:incoming>Flow_142awo6</bpmn:incoming>
|