@5minds/node-red-contrib-processcube 1.12.6 → 1.14.0-feature-c2bc1c-m9v8ypsp
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.
@@ -0,0 +1,141 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
RED.nodes.registerType('dataobject-instance-query', {
|
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
|
+
onlyNewest: { value: true },
|
11
|
+
},
|
12
|
+
inputs: 1,
|
13
|
+
outputs: 1,
|
14
|
+
icon: 'data-object-query.svg',
|
15
|
+
label: function () {
|
16
|
+
return this.name || 'dataobject-instance-query';
|
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
|
+
</script>
|
33
|
+
|
34
|
+
<script type="text/html" data-template-name="dataobject-instance-query">
|
35
|
+
<div class="form-row">
|
36
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
37
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
38
|
+
</div>
|
39
|
+
<div class="form-row">
|
40
|
+
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
41
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
42
|
+
</div>
|
43
|
+
<div class="form-row">
|
44
|
+
<label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
|
45
|
+
<input type="text" id="node-input-query" />
|
46
|
+
</div>
|
47
|
+
<div class="form-row">
|
48
|
+
<label for="node-input-onlyNewest"><i class="fa fa-hand"></i>Only current instance per dataObject</label>
|
49
|
+
<input type="checkbox" id="node-input-onlyNewest" title="Applys a client-side filter, that returns just the newest instance per dataObject">
|
50
|
+
</div>
|
51
|
+
</script>
|
52
|
+
|
53
|
+
<script type="text/markdown" data-help-name="dataobject-instance-query">
|
54
|
+
A node to query dataobject instances on the ProcessCube Engine.
|
55
|
+
|
56
|
+
## Inputs
|
57
|
+
|
58
|
+
: msg (Object | JSON) : The selected field of the *msg*, eg *payload*, will be used as the input for the query or can be directly set as JSON.
|
59
|
+
: query (Object) : The query that was used.
|
60
|
+
|
61
|
+
## Outputs
|
62
|
+
|
63
|
+
: dataObjectInstances (Array) : The dataobject instances that matched the query.
|
64
|
+
: totalCount (number) : The number of matches.
|
65
|
+
|
66
|
+
### Query fields
|
67
|
+
|
68
|
+
**Summary**:
|
69
|
+
|
70
|
+
**Description**: Gets all DataObjectInstances that match the given query.
|
71
|
+
|
72
|
+
#### Parameters:
|
73
|
+
- Name: `offset` Required: `false`
|
74
|
+
- Type: number
|
75
|
+
- Description: The index of the first DataObjectInstance to include in the result set.
|
76
|
+
- Name: `limit` Required: `false`
|
77
|
+
- Type: number
|
78
|
+
- Description: The maximum number of DataObjectInstances to return.
|
79
|
+
- Name: `dataObjectId` Required: ``
|
80
|
+
- Type: Array<string> | string | SearchQuery
|
81
|
+
- string: myDataObjectId_12345678
|
82
|
+
- Array<string>: myDataObjectId_12345678,myDataObjectId_87654321
|
83
|
+
- object:
|
84
|
+
- Description: Filter by the ID of the DataObject.
|
85
|
+
- Name: `flowNodeInstanceId` Required: ``
|
86
|
+
- Type: Array<string> | string | SearchQuery
|
87
|
+
- string: myFlowNodeInstanceId_12345678
|
88
|
+
- Array<string>: myFlowNodeInstanceId_12345678,myFlowNodeInstanceId_87654321
|
89
|
+
- object:
|
90
|
+
- Description: Filter by the ID of the FlowNodeInstance that wrote to the DataObject.
|
91
|
+
- Name: `processInstanceId` Required: ``
|
92
|
+
- Type: Array<string> | string | SearchQuery
|
93
|
+
- string: myProcessInstance_12345678
|
94
|
+
- Array<string>: myProcessInstance_12345678,myProcessInstance_87654321
|
95
|
+
- object:
|
96
|
+
- Description: Filter by the ID of the ProcessInstances.
|
97
|
+
- Name: `processDefinitionId` Required: ``
|
98
|
+
- Type: Array<string> | string | SearchQuery
|
99
|
+
- string: myProcess_12345678
|
100
|
+
- Array<string>: myProcess_12345678,myProcess_87654321
|
101
|
+
- object:
|
102
|
+
- Description: Filter by the ID of the ProcessDefinition that the DataObjectInstances belong to.
|
103
|
+
- Name: `processModelId` Required: ``
|
104
|
+
- Type: Array<string> | string | SearchQuery
|
105
|
+
- string: myProcessModel_12345678
|
106
|
+
- Array<string>: myProcessModel_12345678,myProcessModel_87654321
|
107
|
+
- object:
|
108
|
+
- Description: Filter by the ID of the ProcessModel that the DataObjectInstances belong to.
|
109
|
+
- Name: `embeddedProcessModelId` Required: ``
|
110
|
+
- Type: Array<string> | string | SearchQuery
|
111
|
+
- string: myProcessModel_12345678
|
112
|
+
- Array<string>: myProcessModel_12345678,myProcessModel_87654321
|
113
|
+
- object:
|
114
|
+
- Description: Filter by the ID of the EmbeededProcessModel that the DataObjectInstances belong to.
|
115
|
+
- Name: `createdAt` Required: ``
|
116
|
+
- Type: Array<string> | string
|
117
|
+
- string: 2021-01-01T00:00:00.000Z
|
118
|
+
- array: 2021-01-01T00:00:00.000Z,2021-01-02T00:00:00.000Z
|
119
|
+
- Description: The created date of the DataObjectInstances to include in the results.
|
120
|
+
|
121
|
+
### Only current instance per dataObject
|
122
|
+
|
123
|
+
When checked, an additional filter is applied to the result of the query.
|
124
|
+
For each `dataObjectId`+`processInstanceId` in the result set, only the instance with the newest `createdAt` timestamp will be returned.
|
125
|
+
Therefore, it creates a list containing only the current values of each dataObject.
|
126
|
+
|
127
|
+
**Note**: This is not guranteed to work as described above. Since this is a client-side filter, that is applied after executing the server side query, there are some limitations.
|
128
|
+
Depending on your query, you might not load all instances of an dataObject. I.e. when setting a limit or offset. Or when querying such an amount of instances, that the engine applies an automatic limit.
|
129
|
+
In these cases, this filter will still be applied and return the newest instance from the result set, but that might not be the actual newest value for this dataObject, which would be available in the engines database.
|
130
|
+
To avoid thoses problems, make sure to write strict queries, which are guranteed to have a small result set, that can be retrieved in one request.
|
131
|
+
The `totalCount` property will, as well, not work as expected. Since this is a value created by the engine, it will not line up with the actual amount of instances, that are returned.
|
132
|
+
|
133
|
+
**Note**: This feature will be removed in a future version.
|
134
|
+
Due to the problems described above, this functionality should rather be provided by the engines interface.
|
135
|
+
As soon as the engine supports querying for the newest dataObject values, this filter becomes obsolete and you should instead alter your query to apply this filter server-side.
|
136
|
+
|
137
|
+
### References
|
138
|
+
|
139
|
+
- [The ProcessCube© Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
140
|
+
- [ProcessCube© LowCode Integration](https://processcube.io/docs/node-red) - LowCode integration in ProcessCube©
|
141
|
+
</script>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module.exports = function (RED) {
|
2
|
+
function DataobjectInstanceQuery(config) {
|
3
|
+
RED.nodes.createNode(this, config);
|
4
|
+
var node = this;
|
5
|
+
|
6
|
+
node.on('input', function (msg) {
|
7
|
+
let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
|
8
|
+
|
9
|
+
node.engine = RED.nodes.getNode(config.engine);
|
10
|
+
const client = node.engine.engineClient;
|
11
|
+
const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
|
12
|
+
const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
|
13
|
+
|
14
|
+
if (!client) {
|
15
|
+
node.error('No engine configured.', msg);
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
|
19
|
+
client.dataObjectInstances
|
20
|
+
.query(query, { identity: userIdentity })
|
21
|
+
.then((matchingInstances) => {
|
22
|
+
msg.payload = matchingInstances;
|
23
|
+
|
24
|
+
if (config.onlyNewest) {
|
25
|
+
const newestInstances = {};
|
26
|
+
|
27
|
+
matchingInstances.dataObjectInstances.forEach(instance => {
|
28
|
+
newestInstances[instance.processInstanceId] ??= {};
|
29
|
+
if (!newestInstances[instance.processInstanceId][instance.dataObjectId] || newestInstances[instance.processInstanceId][instance.dataObjectId].createdAt < instance.createdAt) {
|
30
|
+
newestInstances[instance.processInstanceId][instance.dataObjectId] = instance;
|
31
|
+
}
|
32
|
+
})
|
33
|
+
|
34
|
+
msg.payload.dataObjectInstances = Object.values(newestInstances).flatMap(v => Object.values(v));
|
35
|
+
}
|
36
|
+
|
37
|
+
node.send(msg);
|
38
|
+
})
|
39
|
+
.catch((error) => {
|
40
|
+
node.error(`Dataobject Instance Query failed: ${error.message}`, msg);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
}
|
44
|
+
RED.nodes.registerType('dataobject-instance-query', DataobjectInstanceQuery);
|
45
|
+
};
|
@@ -0,0 +1,109 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": "8b280114f8ac9c23",
|
4
|
+
"type": "tab",
|
5
|
+
"label": "Dataobject Instances Query Sample",
|
6
|
+
"disabled": false,
|
7
|
+
"info": "",
|
8
|
+
"env": []
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"id": "be0d703c70d1687b",
|
12
|
+
"type": "group",
|
13
|
+
"z": "8b280114f8ac9c23",
|
14
|
+
"style": {
|
15
|
+
"stroke": "#999999",
|
16
|
+
"stroke-opacity": "1",
|
17
|
+
"fill": "none",
|
18
|
+
"fill-opacity": "1",
|
19
|
+
"label": true,
|
20
|
+
"label-position": "nw",
|
21
|
+
"color": "#a4a4a4"
|
22
|
+
},
|
23
|
+
"nodes": [
|
24
|
+
"8687cdf9bf6c4d7d",
|
25
|
+
"74773491693b7f22",
|
26
|
+
"29e796ef38867f2a"
|
27
|
+
],
|
28
|
+
"x": 74,
|
29
|
+
"y": 79,
|
30
|
+
"w": 632,
|
31
|
+
"h": 82
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"id": "8687cdf9bf6c4d7d",
|
35
|
+
"type": "dataobject-instance-query",
|
36
|
+
"z": "8b280114f8ac9c23",
|
37
|
+
"g": "be0d703c70d1687b",
|
38
|
+
"name": "Query 5 DataobjectInstances",
|
39
|
+
"engine": "7de3086e71c028f9",
|
40
|
+
"query": "{ \"limit\": 5}",
|
41
|
+
"query_type": "json",
|
42
|
+
"x": 400,
|
43
|
+
"y": 120,
|
44
|
+
"wires": [
|
45
|
+
[
|
46
|
+
"74773491693b7f22"
|
47
|
+
]
|
48
|
+
]
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"id": "74773491693b7f22",
|
52
|
+
"type": "debug",
|
53
|
+
"z": "8b280114f8ac9c23",
|
54
|
+
"g": "be0d703c70d1687b",
|
55
|
+
"name": "Log",
|
56
|
+
"active": true,
|
57
|
+
"tosidebar": true,
|
58
|
+
"console": false,
|
59
|
+
"tostatus": false,
|
60
|
+
"complete": "payload",
|
61
|
+
"targetType": "msg",
|
62
|
+
"statusVal": "",
|
63
|
+
"statusType": "auto",
|
64
|
+
"x": 610,
|
65
|
+
"y": 120,
|
66
|
+
"wires": []
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"id": "29e796ef38867f2a",
|
70
|
+
"type": "inject",
|
71
|
+
"z": "8b280114f8ac9c23",
|
72
|
+
"g": "be0d703c70d1687b",
|
73
|
+
"name": "Trigger",
|
74
|
+
"props": [
|
75
|
+
{
|
76
|
+
"p": "payload"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"p": "topic",
|
80
|
+
"vt": "str"
|
81
|
+
}
|
82
|
+
],
|
83
|
+
"repeat": "",
|
84
|
+
"crontab": "",
|
85
|
+
"once": false,
|
86
|
+
"onceDelay": 0.1,
|
87
|
+
"topic": "",
|
88
|
+
"payload": "",
|
89
|
+
"payloadType": "date",
|
90
|
+
"x": 170,
|
91
|
+
"y": 120,
|
92
|
+
"wires": [
|
93
|
+
[
|
94
|
+
"8687cdf9bf6c4d7d"
|
95
|
+
]
|
96
|
+
]
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"id": "7de3086e71c028f9",
|
100
|
+
"type": "processcube-engine-config",
|
101
|
+
"name": "",
|
102
|
+
"url": "http://engine:8000",
|
103
|
+
"urlType": "str",
|
104
|
+
"clientId": "",
|
105
|
+
"clientIdType": "str",
|
106
|
+
"clientSecret": "",
|
107
|
+
"clientSecretType": "str"
|
108
|
+
}
|
109
|
+
]
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<svg width="40" height="60" viewBox="0 0 40 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path d="M3.88776 46.3334C4.33879 46.7844 5.07006 46.7844 5.52109 46.3334L11.4215 40.4329C11.7818 40.0726 12.3521 40.0481 12.7896 40.3093C13.1835 40.5444 13.6093 40.7441 14.0669 40.9084C14.8253 41.1806 15.6322 41.3167 16.4878 41.3167C18.6072 41.3167 20.401 40.5827 21.869 39.1146C23.3371 37.6466 24.0711 35.8528 24.0711 33.7334C24.0711 31.6139 23.3371 29.8202 21.869 28.3521C20.401 26.8841 18.6072 26.15 16.4878 26.15C14.3683 26.15 12.5746 26.8841 11.1065 28.3521C9.63845 29.8202 8.90442 31.6139 8.90442 33.7334C8.90442 34.5889 9.04054 35.3959 9.31276 36.1542C9.47704 36.6118 9.67673 37.0376 9.91183 37.4315C10.173 37.8691 10.1485 38.4393 9.7882 38.7996L3.88776 44.7C3.43673 45.1511 3.43672 45.8823 3.88776 46.3334V46.3334ZM16.4878 38.9834C15.0294 38.9834 13.7898 38.4729 12.769 37.4521C11.7482 36.4313 11.2378 35.1917 11.2378 33.7334C11.2378 32.275 11.7482 31.0354 12.769 30.0146C13.7898 28.9938 15.0294 28.4834 16.4878 28.4834C17.9461 28.4834 19.1857 28.9938 20.2065 30.0146C21.2273 31.0354 21.7378 32.275 21.7378 33.7334C21.7378 35.1917 21.2273 36.4313 20.2065 37.4521C19.1857 38.4729 17.9461 38.9834 16.4878 38.9834Z" fill="white"/>
|
3
|
+
<path d="M12 46H34V22L28 15H12V22" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
4
|
+
<path d="M25 15V24H34" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
5
|
+
</svg>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@5minds/node-red-contrib-processcube",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.14.0-feature-c2bc1c-m9v8ypsp",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"scripts": {
|
@@ -36,6 +36,7 @@
|
|
36
36
|
"version": ">=3.1.9",
|
37
37
|
"nodes": {
|
38
38
|
"checkAuthorization": "check-authorization.js",
|
39
|
+
"DataobjectInstanceQuery": "dataobject-instance-query.js",
|
39
40
|
"EndEventFinishedListener": "endevent-finished-listener.js",
|
40
41
|
"externaltaskInput": "externaltask-input.js",
|
41
42
|
"externaltaskOutput": "externaltask-output.js",
|