@5minds/processcube_engine_client 4.3.1 → 4.4.0-develop-7c4bcb-lj4agef5

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/README.md CHANGED
@@ -1,227 +1,165 @@
1
1
  # Engine Client.ts
2
2
 
3
- A client for communicating with the `Engine`.
3
+ Ein NodeJS basierter Client zur Kommunikation mit der ProcessCube Engine.
4
4
 
5
- It is written in TypeScript and implemented in NodeJS.
5
+ Codebeispiele zur Verwendung des Clients und der External Task Worker [finden sich hier](./samples).
6
6
 
7
- ## Quick example
7
+ ## Schnelleinstieg
8
8
 
9
9
  ```ts
10
- import {EngineClient} from '@5minds/processcube_engine_client';
10
+ import { EngineClient } from '@5minds/processcube_engine_client';
11
11
 
12
12
  const engineUri = 'http://localhost:10560';
13
13
 
14
- async function run() {
15
- const client = new EngineClient(engineUri);
14
+ const client = new EngineClient(engineUri);
16
15
 
17
- const processInstances = await client.processInstances.query({});
16
+ const processInstancesInCorrelation = await client.processInstances.query({
17
+ correlationid: 'my-correlation-id',
18
+ });
19
+ ```
18
20
 
19
- console.log(processInstances);
20
- }
21
+ ## Wie kann ich den Client verwenden?
21
22
 
22
- run();
23
- ```
23
+ Man benötigt lediglich die URL der anzusteuernden Engine.
24
+ Mit dieser lässt sich eine Instanz des Clients anlegen, die direkt verwendbar ist.
24
25
 
25
- ## How to use the client
26
+ Es gibt verschiedene Wege sich Clients anzulegen.
26
27
 
27
- You only need to provide an url to the `Engine` you want to access.
28
- After that, the client is ready to use.
28
+ ### EngineClient
29
29
 
30
- You can either create a single EngineClient, which exposes references to all other clients,
30
+ Man kann eine Instanz des `EngineClients` direkt anlegen, welche die API der ProcessCube Engine vollständig abdeckt.
31
31
 
32
32
  ```ts
33
- import {EngineClient} from '@5minds/processcube_engine_client';
33
+ import { EngineClient } from '@5minds/processcube_engine_client';
34
34
 
35
35
  const engineUri = 'http://localhost:10560';
36
36
 
37
- async function run() {
38
- const client = new EngineClient(engineUri);
37
+ const client = new EngineClient(engineUri);
39
38
 
40
- const processInstances = await client.processInstances.query({}, null, 0, 100);
39
+ const processInstancesInCorrelation = await client.processInstances.query({
40
+ correlationid: 'my-correlation-id',
41
+ });
42
+ ```
41
43
 
42
- console.log(processInstances);
43
- }
44
+ ### Client Factory
44
45
 
45
- run();
46
- ```
46
+ Oder man kann sich über die Client Factory einen feature-spezifischen Client anlegen, der nur einen besimmten fachlichen Aspekt der ProcessCube Engine abdeckt.
47
47
 
48
- or create multiple specific clients with the ClientFactory:
48
+ Beispiel:
49
49
 
50
50
  ```ts
51
- import {ClientFactory} from '@5minds/processcube_engine_client';
51
+ import { ClientFactory } from '@5minds/processcube_engine_client';
52
52
 
53
53
  const engineUri = 'http://localhost:10560';
54
54
 
55
- async function run() {
56
- const processInstanceClient = ClientFactory.createProcessInstanceClient(engineUri);
57
-
58
- const processInstances = await processInstanceClient.query({}, null, 0, 100);
55
+ const processInstanceClient = ClientFactory.createProcessInstanceClient(engineUri);
59
56
 
60
- console.log(processInstances);
61
- }
62
-
63
- run();
57
+ const processInstances = await processInstanceClient.query({
58
+ correlationid: 'my-correlation-id',
59
+ });
64
60
  ```
65
61
 
66
- ### Starting Process Instances
67
-
68
- You can start new Process Instances through `processDefinitionsClient.startProcessInstance(parameters)` -
69
- Resolves right after the Process Instance was started
70
-
71
- Where `parameters` is an object that collects all startup parameters.
72
-
73
- The following parameters are required:
74
- - `processModelId`: The ID of the Process Model to execute
75
- - `startEventId`: The ID of the Start Event by which to start the Process Model. Optional, if the Process Model only has one Start Event.
76
-
77
- In addition, the following optional parameters are available:
78
- - `correlationId`: The ID of the correlation to which this Process Instance belongs. If not provided, it will be auto-generated
79
- - `initialToken`: The initial process token with which to start the Process Instance
80
- - `parentProcessInstanceId`: When the Process Instance is supposed to be the Subprocess of another Process Instance,
81
- this contains the ID of the parent Process Instance
62
+ Hier wird eine Client Instanz angelegt, welche lediglich die Interaktion mit Prozessinstanzen abdeckt.
82
63
 
83
- or through
64
+ ## Anwendungsbeispiele
84
65
 
85
- `processDefinitionsClient.startProcessInstanceAndAwaitEndEvent(parameters)` -
86
- Resolves when the Process Instance has finished with any End Event
66
+ Nachfolgend werden ein paar der am häufigsten verwendeten Use Cases demonstriert.
87
67
 
88
- or through
68
+ ### Prozesse starten
89
69
 
90
- `processDefinitionsClient.startProcessInstanceAndAwaitSpecificEndEvent(parameters, endEventId)` -
91
- Resolves after the ProcessInstance has reached a specific End Event
92
- and has additionally the required endEventId parameter:
93
- - `endEventId`: The ID of the End Event to wait for
70
+ Das Starten von Prozessinstanzen kann über die `EngineClient.processModels` Fachlichkeit realisiert werden.
94
71
 
95
- Examples:
72
+ Prozesse lassen sich auf mehrere Arten starten.
96
73
 
97
- #### Start Process Instance and wait for it to start
74
+ #### Einfacher Prozessstart
98
75
 
99
76
  ```ts
100
- import {EngineClient} from '@5minds/processcube_engine_client';
77
+ import { EngineClient } from '@5minds/processcube_engine_client';
101
78
 
102
79
  const engineUri = 'http://localhost:10560';
103
80
 
104
- async function run() {
105
- const client = new EngineClient(engineUri);
81
+ const client = new EngineClient(engineUri);
106
82
 
107
- await client.processDefinitions.startProcessInstance({processModelId: 'myProcessModelId'});
108
- }
109
-
110
- run();
83
+ await client.processModels.startProcessInstance({processModelId: 'myProcessModelId'});
111
84
  ```
112
85
 
113
- #### Start Process Instance and wait for it to finish
114
-
115
- ```ts
116
- import {EngineClient} from '@5minds/processcube_engine_client';
117
-
118
- const engineUri = 'http://localhost:10560';
119
-
120
- async function run() {
121
- const client = new EngineClient(engineUri);
86
+ Die `processModelId` ist der einzige erforderliche Parameter für diesen Request.
122
87
 
123
- await client.processDefinitions.startProcessInstanceAndAwaitEndEvent({processModelId: 'myProcessModelId'});
124
- }
88
+ Der Client wartet in diesem Szenario nur, bis die Engine den _Start_ des Prozesses bestätigt hat.
125
89
 
126
- run();
127
- ```
90
+ #### Konfigurierter Prozessstart
128
91
 
129
- #### Start Process Instance and wait for an End Event
92
+ Neben der `processModelId` können folgende Paramter mitgegeben werden:
93
+ - `startEventId`: Die ID des Start Events von welchem aus der Prozess losgehen soll
94
+ - **Hinweis:** Bei Prozessen mit mehreren Start Events ist dieser Parameter ebenfalls erforderlich!
95
+ - `correlationId`: Gibt an, in welcher Correlation die Prozessinstanz laufen soll
96
+ - `initialToken`: Der JSON-formatierte Prozess-Token, den die Prozessinstanz zu beginn besitzen soll
130
97
 
131
98
  ```ts
132
- import {EngineClient} from '@5minds/processcube_engine_client';
99
+ import { EngineClient } from '@5minds/processcube_engine_client';
133
100
 
134
101
  const engineUri = 'http://localhost:10560';
135
102
 
136
- async function run() {
137
- const client = new EngineClient(engineUri);
103
+ const client = new EngineClient(engineUri);
138
104
 
139
- await client.processDefinitions.startProcessInstanceAndAwaitSpecificEndEvent({processModelId: 'myProcessModelId'}, 'My_End_Event_1');
140
- }
141
-
142
- run();
105
+ await client.processModels.startProcessInstance({
106
+ processModelId: 'myProcessModelId',
107
+ startEventId: 'StartEvent_1',
108
+ correlationId: 'MyCorrelatioNid',
109
+ initialToken: {
110
+ hello: 'world',
111
+ },
112
+ });
143
113
  ```
144
114
 
145
- #### Start Process Instance with custom payload and correlation ID
115
+ #### Prozess starten und auf dessen Ende warten
146
116
 
147
117
  ```ts
148
- import {EngineClient} from '@5minds/processcube_engine_client';
118
+ import { EngineClient } from '@5minds/processcube_engine_client';
149
119
 
150
120
  const engineUri = 'http://localhost:10560';
151
121
 
152
- async function run() {
153
- const client = new EngineClient(engineUri);
122
+ const client = new EngineClient(engineUri);
154
123
 
155
- await client.processDefinitions.startProcessInstance({
156
- processModelId: 'myProcessModelId',
157
- correlationId: 'my_custom_correlation_id',
158
- initialToken: {
159
- hello: 'world',
160
- },
161
- });
162
- }
163
-
164
- run();
165
- ```
166
-
167
- #### Start Process Instance as a sub process
168
-
169
- ```ts
170
- import {EngineClient} from '@5minds/processcube_engine_client';
171
-
172
- const engineUri = 'http://localhost:10560';
173
-
174
- async function run() {
175
- const client = new EngineClient(engineUri);
176
-
177
- await client.processDefinitions.startProcessInstance({
178
- processModelId: 'myProcessModelId',
179
- parentProcessInstanceId: 'Some-Other-Process-Instance-Id',
180
- });
181
- }
182
-
183
- run();
124
+ await client.processModels.startProcessInstanceAndAwaitEndEvent({processModelId: 'myProcessModelId'});
184
125
  ```
185
126
 
186
- ### Code Samples
127
+ Hier wartet der Client, bis die Engine den Prozess bis zum Ende ausgeführt hat.
187
128
 
188
- You can find [executable code samples here](./samples/client) and [here](https://github.com/atlas-engine/ClientSamples/tree/develop/Client.ts).
129
+ Die Methode akzeptiert dieselben Parameter wie `processModels.startProcessInstance`.
189
130
 
190
131
  ## Query UserTasks
191
132
 
133
+ Abfragen aller User Tasks eines bestimmten Prozesses, die sich in einem "suspended" State befinden:
134
+
192
135
  ```ts
193
- import {EngineClient, DataModels} from '@5minds/processcube_engine_client';
136
+ import { EngineClient, DataModels } from '@5minds/processcube_engine_client';
194
137
 
195
138
  const engineUri = 'http://localhost:10560';
196
139
 
197
- async function run() {
198
- const client = new EngineClient(engineUri);
140
+ const client = new EngineClient(engineUri);
199
141
 
200
- const userTasks = await client.userTasks.query({
201
- processModelId: 'myProcessModelId',
202
- state: DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended,
203
- });
142
+ const userTasks = await client.userTasks.query({
143
+ processModelId: 'myProcessModelId',
144
+ state: DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended,
145
+ });
204
146
 
205
- console.log(userTasks);
206
- }
207
-
208
- run();
147
+ console.log(userTasks);
209
148
  ```
210
149
 
211
- ## How to use External Task Workers
212
-
213
- An External Task worker is designed to process External Tasks associated with a BPMN ServiceTask.
150
+ ## External Task Worker
214
151
 
215
- ### Basic
152
+ External Task Worker werden dazu benutzt, um die an einer Prozessinstanz anfallenden `External Service Tasks` zu verarbeiten.
216
153
 
217
- You need to provide three arguments to a worker:
154
+ Ein Worker benötigt minimal die folgenden 3 Einstellungen
155
+ - Die URL der Ziel-Engine
156
+ - Das Topic der abzuarbeitenden External Tasks
157
+ - Eine Handler Funktion zum Verarbeiten der External Tasks
218
158
 
219
- - The url of the Engine where the worker should connect to
220
- - The topic by which to poll External Tasks
221
- - A handler function for processing the External Tasks
159
+ Beispiel:
222
160
 
223
161
  ```ts
224
- import {EngineClient, DataModels} from '@5minds/processcube_engine_client';
162
+ import { ExternalTaskWorker } from '@5minds/processcube_engine_client';
225
163
 
226
164
  interface AddPayload {
227
165
  number1: number;
@@ -235,49 +173,33 @@ interface AddResult {
235
173
  const engineUri = 'http://localhost:10560';
236
174
  const topic = 'sum_numbers';
237
175
 
238
- async function run() {
239
- const client = new EngineClient(engineUri);
176
+ const externalTaskWorker = new ExternalTaskWorker<AddPayload, AddResult>(url, topic, doAdd, config);
240
177
 
241
- const externalTaskWorker = await client.externalTasks.subscribeToExternalTaskTopic(topic, doAdd);
242
-
243
- externalTaskWorker.start();
244
- }
178
+ externalTaskWorker.start();
245
179
 
246
180
  async function doAdd(
247
181
  payload: AddPayload,
248
182
  externalTask: DataModels.ExternalTasks.ExternalTask<AddPayload>,
249
183
  ): Promise<AddResult> {
250
-
251
184
  const result: AddResult = {
252
185
  sum: payload.number1 + payload.number2,
253
186
  };
254
187
 
255
- console.log('Receive payload from process instance');
256
- console.log(JSON.stringify(payload));
257
-
258
- return Promise.resolve(result);
188
+ return result;
259
189
  }
260
190
 
261
- run();
262
-
263
191
  ```
264
192
 
265
- Note that by subscribing to a single topic, you create a specific worker for this topic.
266
-
267
- ### Starting and stopping
268
-
269
- Start the worker with:
193
+ Der Worker lässt sich mit folgendem Befehl starten:
270
194
 
271
195
  ```ts
272
196
  externalTaskWorker.start();
273
197
  ```
274
198
 
275
- And stop it with:
199
+ und mit folgendem Befehl stoppen:
276
200
 
277
201
  ```ts
278
202
  externalTaskWorker.stop();
279
203
  ```
280
204
 
281
- ### Code Samples
282
-
283
- You can find [executable code samples here](./samples/external_task_worker) and [here](https://github.com/atlas-engine/ClientSamples/tree/develop/Client.ts).
205
+ Ein ausführbares Code-Beispiel [findet sich hier](./samples/external_task_worker/).
@@ -22,7 +22,7 @@ define(["require", "exports", "@5minds/processcube_engine_sdk", "./CallbackTypes
22
22
  Messages.BpmnEvents = processcube_engine_sdk_1.Messages.BpmnEvents;
23
23
  Messages.SystemEvents = processcube_engine_sdk_1.Messages.SystemEvents;
24
24
  Messages.CallbackTypes = callbackTypes;
25
- })(Messages = exports.Messages || (exports.Messages = {}));
25
+ })(Messages || (exports.Messages = Messages = {}));
26
26
  __exportStar(IExternalTaskWorker_1, exports);
27
27
  __exportStar(RestSettings_1, exports);
28
28
  __exportStar(SocketSettings_1, exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;IAIA,uFAAuF;IACvF,IAAiB,QAAQ,CAMxB;IAND,WAAiB,QAAQ;QAGT,mBAAU,GAAG,iCAAW,CAAC,UAAU,CAAC;QACpC,qBAAY,GAAG,iCAAW,CAAC,YAAY,CAAC;QACxC,sBAAa,GAAG,aAAa,CAAC;IAC9C,CAAC,EANgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAMxB;IAMD,6CAAsC;IACtC,sCAA+B;IAC/B,wCAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;IAIA,uFAAuF;IACvF,IAAiB,QAAQ,CAMxB;IAND,WAAiB,QAAQ;QAGT,mBAAU,GAAG,iCAAW,CAAC,UAAU,CAAC;QACpC,qBAAY,GAAG,iCAAW,CAAC,YAAY,CAAC;QACxC,sBAAa,GAAG,aAAa,CAAC;IAC9C,CAAC,EANgB,QAAQ,wBAAR,QAAQ,QAMxB;IAMD,6CAAsC;IACtC,sCAA+B;IAC/B,wCAAiC"}
@@ -23,7 +23,7 @@ var Messages;
23
23
  Messages.BpmnEvents = processcube_engine_sdk_1.Messages.BpmnEvents;
24
24
  Messages.SystemEvents = processcube_engine_sdk_1.Messages.SystemEvents;
25
25
  Messages.CallbackTypes = callbackTypes;
26
- })(Messages = exports.Messages || (exports.Messages = {}));
26
+ })(Messages || (exports.Messages = Messages = {}));
27
27
  __exportStar(require("./IExternalTaskWorker"), exports);
28
28
  __exportStar(require("./RestSettings"), exports);
29
29
  __exportStar(require("./SocketSettings"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2EAAyE;AAEzE,iDAAiD;AAEjD,uFAAuF;AACvF,IAAiB,QAAQ,CAMxB;AAND,WAAiB,QAAQ;IAGT,mBAAU,GAAG,iCAAW,CAAC,UAAU,CAAC;IACpC,qBAAY,GAAG,iCAAW,CAAC,YAAY,CAAC;IACxC,sBAAa,GAAG,aAAa,CAAC;AAC9C,CAAC,EANgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAMxB;AAMD,wDAAsC;AACtC,iDAA+B;AAC/B,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2EAAyE;AAEzE,iDAAiD;AAEjD,uFAAuF;AACvF,IAAiB,QAAQ,CAMxB;AAND,WAAiB,QAAQ;IAGT,mBAAU,GAAG,iCAAW,CAAC,UAAU,CAAC;IACpC,qBAAY,GAAG,iCAAW,CAAC,YAAY,CAAC;IACxC,sBAAa,GAAG,aAAa,CAAC;AAC9C,CAAC,EANgB,QAAQ,wBAAR,QAAQ,QAMxB;AAMD,wDAAsC;AACtC,iDAA+B;AAC/B,mDAAiC"}
package/package.json CHANGED
@@ -1,43 +1,46 @@
1
1
  {
2
2
  "name": "@5minds/processcube_engine_client",
3
- "version": "4.3.1",
3
+ "version": "4.4.0-develop-7c4bcb-lj4agef5",
4
4
  "description": "Contains a typescript based client for accessing the Engine.",
5
5
  "main": "dist/commonjs/index.js",
6
- "typings": "dist/index.d.ts",
6
+ "types": "dist/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/atlas-engine/Client.ts.git"
10
10
  },
11
- "author": "5Minds IT-Solutions GmbH & Co. KG",
11
+ "author": {
12
+ "name": "5Minds IT-Solutions GmbH & Co. KG",
13
+ "email": "info@5minds.de",
14
+ "url": "https://5minds.de/"
15
+ },
12
16
  "maintainers": [
13
17
  "Alexander Kasten <alexander.kasten@5minds.de>",
14
18
  "Christian Werner <christian.werner@5minds.de>",
15
- "René Föhring <rene.foehring@5minds.de>",
16
- "Steffen Knaup <steffen.knaup@5minds.de>"
19
+ "Sebastian Griesa <sebastian.griesa@5minds.de>"
17
20
  ],
18
21
  "license": "MIT",
22
+ "homepage": "https://github.com/atlas-engine/Client.ts#readme",
19
23
  "bugs": {
20
24
  "url": "https://github.com/atlas-engine/Client.ts/issues"
21
25
  },
22
- "homepage": "https://github.com/atlas-engine/Client.ts#readme",
26
+ "scripts": {
27
+ "clean": "rm -rf dist",
28
+ "clean-build": "npm run clean && npm run build",
29
+ "build": "npm run build-commonjs && npm run build-amd",
30
+ "build-commonjs": "tsc",
31
+ "build-amd": "tsc --module amd --outDir ./dist/amd",
32
+ "prepare": "npm run build",
33
+ "test": ":"
34
+ },
23
35
  "dependencies": {
24
36
  "@5minds/processcube_engine_sdk": "3.3.0",
25
37
  "@types/socket.io": "^2.1.13",
26
38
  "@types/socket.io-client": "^1.4.36",
27
- "cross-fetch": "3.1.5",
39
+ "cross-fetch": "3.1.6",
28
40
  "socket.io-client": "2.5.0",
29
41
  "uuid": "^9.0.0"
30
42
  },
31
43
  "devDependencies": {
32
- "typescript": "^5.0.4"
33
- },
34
- "scripts": {
35
- "reinstall": "./reinstall.sh",
36
- "clean": "rm -rf dist",
37
- "build": "npm run clean && npm run build-commonjs && npm run build-amd",
38
- "build-commonjs": "tsc",
39
- "build-amd": "tsc --module amd --outDir ./dist/amd",
40
- "prepare": "npm run build",
41
- "test": ":"
44
+ "typescript": "^5.1.3"
42
45
  }
43
46
  }