@5minds/node-red-contrib-processcube 1.5.6-feature-aa14a2-m3pntyi8 → 1.5.7-develop-41d845-m3q6c4hg

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.
@@ -70,6 +70,125 @@ Waiting for Usertasks of the connected ProcessCube Engine.
70
70
  - `msg.payload` or a constant json to filter the UserTasks for Waiting for
71
71
  - `Only for new` will trigger only for new UserTasks if checked and also for old ones if not checked.
72
72
 
73
+ ### Query fields
74
+
75
+ **Summary**:
76
+
77
+ **Description**: Filter result for 'Wait for UserTask'
78
+
79
+ #### Parameters:
80
+ - Name: `offset` Required: `false`
81
+ - Type: number
82
+ - Description: The index of the first ProcessInstance to include in the result set.
83
+ - Name: `limit` Required: `false`
84
+ - Type: number
85
+ - Description: The maximum number of ProcessInstances to return.
86
+ - Name: `correlationId` Required: `false`
87
+ - Type: Array<string> | string | SearchQuery
88
+ - string: myCorrelationId
89
+ - Array<string>: myCorrelationId1,myCorrelationId2
90
+ - object:
91
+ - Description: Filter by the CorrelationId of the ProcessInstances.
92
+ - Name: `processInstanceId` Required: ``
93
+ - Type: Array<string> | string | SearchQuery
94
+ - string: myProcessInstance_12345678
95
+ - Array<string>: myProcessInstance_12345678,myProcessInstance_87654321
96
+ - object:
97
+ - Description: Filter by the ID of the ProcessInstances.
98
+ - Name: `processDefinitionId` Required: ``
99
+ - Type: Array<string> | string | SearchQuery
100
+ - string: myProcess_12345678
101
+ - Array<string>: myProcess_12345678,myProcess_87654321
102
+ - object:
103
+ - Description: Filter by the ID of the ProcessDefinition that the ProcessInstances belong to.
104
+ - Name: `processModelId` Required: ``
105
+ - Type: Array<string> | string | SearchQuery
106
+ - string: myProcessModel_12345678
107
+ - Array<string>: myProcessModel_12345678,myProcessModel_87654321
108
+ - object:
109
+ - Description: Filter by the ID of the ProcessModel that the ProcessInstances belong to.
110
+ - Name: `processModelName` Required: ``
111
+ - Type: Array<string> | string | SearchQuery
112
+ - string: My Process Model
113
+ - Array<string>: My Process Model,My Other Process Model
114
+ - object:
115
+ - Description: Filter by the name of the ProcessModel that the ProcessInstances belong to.
116
+ - Name: `processModelHash` Required: ``
117
+ - Type: Array<string> | string | SearchQuery
118
+ - string: 12345678
119
+ - Array<string>: 12345678,87654321
120
+ - object:
121
+ - Description: Filter by the hash of the ProcessModel that the ProcessInstances belong to.
122
+ - Name: `ownerId` Required: ``
123
+ - Type: Array<string> | string | SearchQuery
124
+ - string: 12345678
125
+ - Array<string>: 12345678,87654321
126
+ - object:
127
+ - Description: Filter by the ID of the User that owns the ProcessInstances.
128
+ - Name: `state` Required: ``
129
+ - Type: Array<string> | string | SearchQuery
130
+ - string: running
131
+ - Array<string>: running,finished
132
+ - object:
133
+ - Description: Filter by the state of the ProcessInstances.
134
+ - Name: `parentProcessInstanceId` Required: ``
135
+ - Type: Array<string> | string | SearchQuery
136
+ - string: myParentProcessInstance_12345678
137
+ - Array<string>: myParentProcessInstance_12345678,myParentProcessInstance_87654321
138
+ - object:
139
+ - Description: Filter by the ID of the parent ProcessInstance.
140
+ - Name: `embeddedProcessModelId` Required: ``
141
+ - Type: Array<string> | string | SearchQuery
142
+ - string: myModel1
143
+ - Array<string>: myModel1,myModel2
144
+ - object:
145
+ - Description: Filter by the ID of the embedded process model.
146
+ - Name: `terminatedByUserId` Required: ``
147
+ - Type: Array<string> | string | SearchQuery
148
+ - string: 12345678
149
+ - Array<string>: 12345678,87654321
150
+ - object:
151
+ - Description: Filter by the ID of the User that terminated the ProcessInstances.
152
+ - Name: `createdBefore` Required: ``
153
+ - Type: string
154
+ - Description: The maximum created date of the ProcessInstances to include in the results.
155
+ - Name: `createdAt` Required: ``
156
+ - Type: Array<string> | string
157
+ - string: 2021-01-01T00:00:00.000Z
158
+ - array: 2021-01-01T00:00:00.000Z,2021-01-02T00:00:00.000Z
159
+ - Description: The minimum created date of the ProcessInstances to include in the results.
160
+ - Name: `createdAfter` Required: ``
161
+ - Type: string
162
+ - Description: The minimum created date of the ProcessInstances to include in the results.
163
+ - Name: `updatedBefore` Required: ``
164
+ - Type: string
165
+ - Description: The maximum updated date of the ProcessInstances to include in the results.
166
+ - Name: `updatedAt` Required: ``
167
+ - Type: Array<string> | string
168
+ - string: 2021-01-01T00:00:00.000Z
169
+ - array: 2021-01-01T00:00:00.000Z,2021-01-02T00:00:00.000Z
170
+ - Description: The exact updated date of the ProcessInstances to include in the results.
171
+ - Name: `updatedAfter` Required: ``
172
+ - Type: string
173
+ - Description: The minimum updated date of the ProcessInstances to include in the results.
174
+ - Name: `finishedBefore` Required: ``
175
+ - Type: string
176
+ - Description: The maximum finished date of the ProcessInstances to include in the results.
177
+ - Name: `finishedAt` Required: ``
178
+ - Type: Array<string> | string
179
+ - string: 2021-01-01T00:00:00.000Z
180
+ - array: 2021-01-01T00:00:00.000Z,2021-01-02T00:00:00.000Z
181
+ - Description: The exact finished date of the ProcessInstances to include in the results.
182
+ - Name: `finishedAfter` Required: ``
183
+ - Type: string
184
+ - Description: The minimum finished date of the ProcessInstances to include in the results.
185
+ - Name: `triggeredByFlowNodeInstance` Required: ``
186
+ - Type: Array<string> | string | SearchQuery
187
+ - string: myFlowNodeInstance_12345678
188
+ - array: myFlowNodeInstance_12345678,myFlowNodeInstance_87654321
189
+ - object:
190
+ - Description: Filter by the ID of the FlowNodeInstance that triggered the ProcessInstance.
191
+
73
192
  ### References
74
193
 
75
194
  - [The ProcessCube© Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
@@ -5,12 +5,13 @@ module.exports = function (RED) {
5
5
 
6
6
  node.engine = RED.nodes.getNode(config.engine);
7
7
 
8
+ const client = node.engine.engineClient;
9
+
8
10
  let subscription = null;
9
11
  let currentIdentity = node.engine.identity;
10
12
  let subscribe = null;
11
13
 
12
14
  node.on('input', async function (msg) {
13
- const client = node.engine.engineClient;
14
15
  subscribe = async () => {
15
16
  if (!client) {
16
17
  node.error('No engine configured.');
@@ -19,49 +20,44 @@ module.exports = function (RED) {
19
20
 
20
21
  const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
21
22
 
22
- subscription = await client.userTasks.onUserTaskWaiting(
23
- async (userTaskWaitingNotification) => {
24
- const newQuery = {
25
- flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
26
- ...query,
27
- };
28
-
29
- try {
30
- const matchingFlowNodes = await client.userTasks.query(newQuery, {
31
- identity: currentIdentity,
32
- });
33
-
34
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
35
- // remove subscription
36
- client.userTasks.removeSubscription(subscription, currentIdentity);
37
-
38
- const userTask = matchingFlowNodes.userTasks[0];
39
-
40
- msg.payload = { userTask: userTask };
41
- node.send(msg);
42
- } else {
43
- // nothing todo - wait for next notification
44
- }
45
- } catch (error) {
46
- node.error(error);
23
+ subscription = await client.userTasks.onUserTaskWaiting(async (userTaskWaitingNotification) => {
24
+
25
+ const newQuery = {
26
+ 'flowNodeInstanceId': userTaskWaitingNotification.flowNodeInstanceId,
27
+ ...query
28
+ };
29
+
30
+ try {
31
+ const matchingFlowNodes = await client.userTasks.query(newQuery, { identity: currentIdentity });
32
+
33
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
34
+ // remove subscription
35
+ client.userTasks.removeSubscription(subscription, currentIdentity);
36
+
37
+ const userTask = matchingFlowNodes.userTasks[0];
38
+
39
+ msg.payload = { userTask: userTask };
40
+ node.send(msg);
41
+ } else {
42
+ // nothing todo - wait for next notification
47
43
  }
48
- },
49
- { identity: currentIdentity }
50
- );
44
+ } catch (error) {
45
+ node.error(error);
46
+ }
51
47
 
52
- node.log({ 'Handling old userTasks config.only_for_new': config.only_for_new });
48
+ }, { identity: currentIdentity });
49
+
50
+ node.log({ "Handling old userTasks config.only_for_new": config.only_for_new });
53
51
 
54
52
  if (config.only_for_new === false) {
55
53
  // only check suspended user tasks
56
54
  const suspendedQuery = {
57
- state: 'suspended',
58
- ...query,
55
+ 'state': 'suspended',
56
+ ...query
59
57
  };
60
58
 
61
59
  try {
62
- const matchingFlowNodes = await client.userTasks.query(suspendedQuery, {
63
- identity: currentIdentity,
64
- });
60
+ const matchingFlowNodes = await client.userTasks.query(suspendedQuery, { identity: currentIdentity });
65
61
 
66
62
  if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
67
63
  const userTask = matchingFlowNodes.userTasks[0];
@@ -84,6 +80,7 @@ module.exports = function (RED) {
84
80
  });
85
81
 
86
82
  node.engine.registerOnIdentityChanged(async (identity) => {
83
+
87
84
  if (subscription) {
88
85
  client.userTasks.removeSubscription(subscription, currentIdentity);
89
86
  currentIdentity = identity;
@@ -93,11 +90,11 @@ module.exports = function (RED) {
93
90
  }
94
91
  });
95
92
 
96
- node.on('close', async () => {
93
+ node.on("close", async () => {
97
94
  if (client != null && subscription != null) {
98
95
  client.userTasks.removeSubscription(subscription, currentIdentity);
99
96
  }
100
97
  });
101
98
  }
102
- RED.nodes.registerType('wait-for-usertask', WaitForUsertask);
103
- };
99
+ RED.nodes.registerType("wait-for-usertask", WaitForUsertask);
100
+ }