bpmn-client 2.3.2 → 3.0.0

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,32 +1,32 @@
1
- cbpmn-client
2
- ===========
3
-
4
- [![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
5
-
6
- This is a light-weight package to allow remote access to [bpmn-server](https://github.com/bpmnServer/bpmn-server)
7
-
8
- # Installation
9
-
10
- This installs bpmn-client-sample application along with `bpmn-client`
11
-
12
- ```sh
13
-
14
- git clone https://github.com/bpmnServer/bpmn-client-sample.git
15
-
16
- cd bpmn-client-sample
17
-
18
- npm install
19
-
20
- npm run setup
21
-
22
- npm run cli
23
-
24
- ```
25
- the above setup command will copy .env
26
- You can edit .env file to point to your implementation of `bpmn-server`
27
-
28
- ### to update to latest release
29
-
30
- ```
31
- $ npm update bpmn-client
32
- ```
1
+ cbpmn-client
2
+ ===========
3
+
4
+ [![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
5
+
6
+ This is a light-weight package to allow remote access to [bpmn-server](https://github.com/bpmnServer/bpmn-server)
7
+
8
+ # Installation
9
+
10
+ This installs bpmn-client-sample application along with `bpmn-client`
11
+
12
+ ```sh
13
+
14
+ git clone https://github.com/bpmnServer/bpmn-client-sample.git
15
+
16
+ cd bpmn-client-sample
17
+
18
+ npm install
19
+
20
+ npm run setup
21
+
22
+ npm run cli
23
+
24
+ ```
25
+ the above setup command will copy .env
26
+ You can edit .env file to point to your implementation of `bpmn-server`
27
+
28
+ ### to update to latest release
29
+
30
+ ```
31
+ $ npm update bpmn-client
32
+ ```
@@ -0,0 +1,62 @@
1
+ import { IInstanceData, IItemData, IDefinitionData } from './interfaces/DataObjects.js';
2
+ import { WebService } from './WebService.js';
3
+ declare class BPMNClient extends WebService {
4
+ host: any;
5
+ port: any;
6
+ apiKey: any;
7
+ engine: ClientEngine;
8
+ datastore: ClientDatastore;
9
+ definitions: ClientDefinitions;
10
+ constructor(host: any, port: any, apiKey: any);
11
+ get(url: any, data?: {}): Promise<any>;
12
+ post(url: any, data?: {}): Promise<any>;
13
+ put(url: any, data?: {}): Promise<any>;
14
+ del(url: any, data?: {}): Promise<any>;
15
+ request(url: any, method: any, params: any): Promise<any>;
16
+ }
17
+ declare class ClientEngine {
18
+ private client;
19
+ constructor(client: any);
20
+ start(name: any, data?: {}, startNodeId?: any, userId?: any, options?: {}): Promise<IInstanceData>;
21
+ invoke(query: any, data: any, userId?: any, options?: {}): Promise<IInstanceData>;
22
+ assign(query: any, data: any, userId: any, assignment: any): Promise<IInstanceData>;
23
+ restart(query: any, data: any, userId?: any, options?: {}): Promise<IInstanceData>;
24
+ throwMessage(messageId: any, data?: {}, messageMatchingKey?: {}): Promise<any>;
25
+ throwSignal(signalId: any, data?: {}, messageMatchingKey?: {}): Promise<any>;
26
+ startEvent(instanceId: any, startNodeId: any, data?: {}, userId?: any, options?: {}): Promise<IInstanceData>;
27
+ get(query: any): Promise<IInstanceData>;
28
+ status(): Promise<any>;
29
+ }
30
+ declare class ClientDatastore {
31
+ private client;
32
+ constructor(client: any);
33
+ find({ filter, sort, limit, after, projection, lastItem, latestItem, getTotalCount }: {
34
+ filter?: Record<string, any>;
35
+ after?: string;
36
+ limit?: number;
37
+ sort?: Record<string, 1 | -1>;
38
+ projection?: Record<string, 0 | 1 | any>;
39
+ lastItem?: Record<string, any>;
40
+ latestItem?: Record<string, any>;
41
+ getTotalCount?: boolean;
42
+ }): Promise<{
43
+ data?: any[];
44
+ nextCursor?: string | null;
45
+ totalCount?: number;
46
+ error?: string;
47
+ }>;
48
+ findItems(query: any): Promise<IItemData[]>;
49
+ findInstances(query: any, projection?: {}): Promise<IInstanceData[]>;
50
+ deleteInstances(query: any): Promise<any>;
51
+ }
52
+ declare class ClientDefinitions {
53
+ private client;
54
+ constructor(client: any);
55
+ import(name: any, pathToBPMN: any, pathToSVG?: any): Promise<any>;
56
+ list(): Promise<string[]>;
57
+ delete(name: any): Promise<IDefinitionData>;
58
+ rename(name: any, newName: any): Promise<IDefinitionData>;
59
+ load(name: any): Promise<IDefinitionData>;
60
+ checkErrors(res: any): void;
61
+ }
62
+ export { BPMNClient, ClientEngine, ClientDatastore, ClientDefinitions };
@@ -1,17 +1,11 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ClientDefinitions = exports.ClientDatastore = exports.ClientEngine = exports.BPMNClient = void 0;
13
- const WebService_1 = require("./WebService");
14
- class BPMNClient extends WebService_1.WebService {
1
+ import { WebService } from './WebService.js';
2
+ class BPMNClient extends WebService {
3
+ host;
4
+ port;
5
+ apiKey;
6
+ engine;
7
+ datastore;
8
+ definitions;
15
9
  constructor(host, port, apiKey) {
16
10
  super();
17
11
  this.host = host;
@@ -21,280 +15,234 @@ class BPMNClient extends WebService_1.WebService {
21
15
  this.datastore = new ClientDatastore(this);
22
16
  this.definitions = new ClientDefinitions(this);
23
17
  }
24
- get(url_1) {
25
- return __awaiter(this, arguments, void 0, function* (url, data = {}) {
26
- return yield this.request(url, 'GET', data);
27
- });
18
+ async get(url, data = {}) {
19
+ return await this.request(url, 'GET', data);
28
20
  }
29
- post(url_1) {
30
- return __awaiter(this, arguments, void 0, function* (url, data = {}) {
31
- return yield this.request(url, 'POST', data);
32
- });
21
+ async post(url, data = {}) {
22
+ return await this.request(url, 'POST', data);
33
23
  }
34
- put(url_1) {
35
- return __awaiter(this, arguments, void 0, function* (url, data = {}) {
36
- return yield this.request(url, 'PUT', data);
37
- });
24
+ async put(url, data = {}) {
25
+ return await this.request(url, 'PUT', data);
38
26
  }
39
- del(url_1) {
40
- return __awaiter(this, arguments, void 0, function* (url, data = {}) {
41
- return yield this.request(url, 'DELETE', data);
42
- });
27
+ async del(url, data = {}) {
28
+ return await this.request(url, 'DELETE', data);
43
29
  }
44
- request(url, method, params) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- var body = JSON.stringify(params);
47
- var size = Buffer.byteLength(body);
48
- var contentType = "application/json";
49
- if (method == 'UPLOAD') {
50
- contentType = 'multipart/form-data; boundary = ----WebKitFormBoundary7MA4YWxkTrZu0gW';
51
- method = 'POST';
52
- }
53
- var headers = {
54
- "Content-Type": contentType,
55
- "x-api-key": this.apiKey,
56
- "Accept": "*/*",
57
- // "User-Agent": "PostmanRuntime/ 7.26.8",
58
- // "Accept-Encoding": "gzip, deflate, br",
59
- "Connection": "keep-alive"
60
- //,
61
- // "Content-Length": Buffer.byteLength(body)
30
+ async request(url, method, params) {
31
+ var body = JSON.stringify(params);
32
+ var size = Buffer.byteLength(body);
33
+ var contentType = "application/json";
34
+ if (method == 'UPLOAD') {
35
+ contentType = 'multipart/form-data; boundary = ----WebKitFormBoundary7MA4YWxkTrZu0gW';
36
+ method = 'POST';
37
+ }
38
+ var headers = {
39
+ "Content-Type": contentType,
40
+ "x-api-key": this.apiKey,
41
+ "Accept": "*/*",
42
+ // "User-Agent": "PostmanRuntime/ 7.26.8",
43
+ // "Accept-Encoding": "gzip, deflate, br",
44
+ "Connection": "keep-alive"
45
+ //,
46
+ // "Content-Length": Buffer.byteLength(body)
47
+ };
48
+ var options;
49
+ if (params) {
50
+ options = {
51
+ host: this.host,
52
+ port: this.port,
53
+ path: '/api/' + url,
54
+ method: method,
55
+ headers: headers
56
+ };
57
+ }
58
+ else {
59
+ options = {
60
+ host: this.host,
61
+ port: this.port,
62
+ path: '/api/' + url,
63
+ method: method
62
64
  };
63
- var options;
64
- if (params) {
65
- options = {
66
- host: this.host,
67
- port: this.port,
68
- path: '/api/' + url,
69
- method: method,
70
- headers: headers
71
- };
72
- }
73
- else {
74
- options = {
75
- host: this.host,
76
- port: this.port,
77
- path: '/api/' + url,
78
- method: method
79
- };
80
- }
81
- return yield this.invoke(params, options);
82
- });
65
+ }
66
+ return await this.invoke(params, options);
83
67
  }
84
68
  }
85
- exports.BPMNClient = BPMNClient;
86
69
  class ClientEngine {
70
+ client;
87
71
  constructor(client) {
88
72
  this.client = client;
89
73
  }
90
- start(name_1) {
91
- return __awaiter(this, arguments, void 0, function* (name, data = {}, startNodeId = null, userId = null, options = {}) {
92
- const ret = yield this.client.post('engine/start', { name, data, startNodeId, userId, options });
93
- if (ret['errors']) {
94
- console.log(ret['errors']);
95
- throw new Error(ret['errors']);
96
- }
97
- const instance = ret;
98
- return instance;
99
- });
100
- }
101
- invoke(query_1, data_1) {
102
- return __awaiter(this, arguments, void 0, function* (query, data, userId = null, options = {}) {
103
- console.log('invoke', options);
104
- const ret = yield this.client.put('engine/invoke', { query, data, userId, options });
105
- if (ret['errors']) {
106
- console.log(ret['errors']);
107
- throw new Error(ret['errors']);
108
- }
109
- const instance = ret['instance'];
110
- return instance;
111
- });
112
- }
113
- assign(query_1, data_1) {
114
- return __awaiter(this, arguments, void 0, function* (query, data, userId = null, assignment) {
115
- const ret = yield this.client.put('engine/assign', { query, data, userId, assignment });
116
- if (ret['errors']) {
117
- console.log(ret['errors']);
118
- throw new Error(ret['errors']);
119
- }
120
- const instance = ret['instance'];
121
- return instance;
122
- });
123
- }
124
- restart(query_1, data_1) {
125
- return __awaiter(this, arguments, void 0, function* (query, data, userId = null, options = {}) {
126
- console.log('invoke', options);
127
- const ret = yield this.client.put('engine/restart', { query, data, userId, options });
128
- if (ret['errors']) {
129
- console.log(ret['errors']);
130
- throw new Error(ret['errors']);
131
- }
132
- const instance = ret['instance'];
133
- return instance;
134
- });
135
- }
136
- throwMessage(messageId_1) {
137
- return __awaiter(this, arguments, void 0, function* (messageId, data = {}, messageMatchingKey = {}) {
138
- const ret = yield this.client.post('engine/throwMessage', { "messageId": messageId, "data": data, messageMatchingKey });
139
- if (ret['errors']) {
140
- console.log(ret['errors']);
141
- throw new Error(ret['errors']);
142
- }
143
- return ret;
144
- });
145
- }
146
- throwSignal(signalId_1) {
147
- return __awaiter(this, arguments, void 0, function* (signalId, data = {}, messageMatchingKey = {}) {
148
- const ret = yield this.client.post('engine/throwSignal', { "signalId": signalId, "data": data, messageMatchingKey });
149
- if (ret['errors']) {
150
- console.log(ret['errors']);
151
- throw new Error(ret['errors']);
152
- }
153
- return ret;
154
- });
74
+ async start(name, data = {}, startNodeId = null, userId = null, options = {}) {
75
+ const ret = await this.client.post('engine/start', { name, data, startNodeId, userId, options });
76
+ if (ret['errors']) {
77
+ console.log(ret['errors']);
78
+ throw new Error(ret['errors']);
79
+ }
80
+ const instance = ret;
81
+ return instance;
82
+ }
83
+ async invoke(query, data, userId = null, options = {}) {
84
+ console.log('invoke', options);
85
+ const ret = await this.client.put('engine/invoke', { query, data, userId, options });
86
+ if (ret['errors']) {
87
+ console.log(ret['errors']);
88
+ throw new Error(ret['errors']);
89
+ }
90
+ const instance = ret['instance'];
91
+ return instance;
92
+ }
93
+ async assign(query, data, userId = null, assignment) {
94
+ const ret = await this.client.put('engine/assign', { query, data, userId, assignment });
95
+ if (ret['errors']) {
96
+ console.log(ret['errors']);
97
+ throw new Error(ret['errors']);
98
+ }
99
+ const instance = ret['instance'];
100
+ return instance;
101
+ }
102
+ async restart(query, data, userId = null, options = {}) {
103
+ console.log('invoke', options);
104
+ const ret = await this.client.put('engine/restart', { query, data, userId, options });
105
+ if (ret['errors']) {
106
+ console.log(ret['errors']);
107
+ throw new Error(ret['errors']);
108
+ }
109
+ const instance = ret['instance'];
110
+ return instance;
111
+ }
112
+ async throwMessage(messageId, data = {}, messageMatchingKey = {}) {
113
+ const ret = await this.client.post('engine/throwMessage', { "messageId": messageId, "data": data, messageMatchingKey });
114
+ if (ret['errors']) {
115
+ console.log(ret['errors']);
116
+ throw new Error(ret['errors']);
117
+ }
118
+ return ret;
155
119
  }
156
- startEvent(instanceId_1, startNodeId_1) {
157
- return __awaiter(this, arguments, void 0, function* (instanceId, startNodeId, data = {}, userId = null, options = {}) {
158
- const ret = yield this.client.put('engine/startEvent', { "instanceId": instanceId, "startNodeId": startNodeId, "data": data, "userName": userId, "options": options });
159
- if (ret['errors']) {
160
- console.log(ret['errors']);
161
- throw new Error(ret['errors']);
162
- }
163
- return ret;
164
- });
120
+ async throwSignal(signalId, data = {}, messageMatchingKey = {}) {
121
+ const ret = await this.client.post('engine/throwSignal', { "signalId": signalId, "data": data, messageMatchingKey });
122
+ if (ret['errors']) {
123
+ console.log(ret['errors']);
124
+ throw new Error(ret['errors']);
125
+ }
126
+ return ret;
165
127
  }
166
- get(query) {
167
- return __awaiter(this, void 0, void 0, function* () {
168
- const ret = yield this.client.get('engine/get', query);
169
- if (ret['errors']) {
170
- console.log(ret['errors']);
171
- throw new Error(ret['errors']);
172
- }
173
- const instance = ret['instance'];
174
- return instance;
175
- });
128
+ async startEvent(instanceId, startNodeId, data = {}, userId = null, options = {}) {
129
+ const ret = await this.client.put('engine/startEvent', { "instanceId": instanceId, "startNodeId": startNodeId, "data": data, "userName": userId, "options": options });
130
+ if (ret['errors']) {
131
+ console.log(ret['errors']);
132
+ throw new Error(ret['errors']);
133
+ }
134
+ return ret;
176
135
  }
177
- status() {
178
- return __awaiter(this, void 0, void 0, function* () {
179
- const ret = yield this.client.get('engine/status', {});
180
- if (ret['errors']) {
181
- console.log(ret['errors']);
182
- throw new Error(ret['errors']);
183
- }
184
- return ret;
185
- });
136
+ async get(query) {
137
+ const ret = await this.client.get('engine/get', query);
138
+ if (ret['errors']) {
139
+ console.log(ret['errors']);
140
+ throw new Error(ret['errors']);
141
+ }
142
+ const instance = ret['instance'];
143
+ return instance;
144
+ }
145
+ async status() {
146
+ const ret = await this.client.get('engine/status', {});
147
+ if (ret['errors']) {
148
+ console.log(ret['errors']);
149
+ throw new Error(ret['errors']);
150
+ }
151
+ return ret;
186
152
  }
187
153
  }
188
- exports.ClientEngine = ClientEngine;
189
154
  class ClientDatastore {
155
+ client;
190
156
  constructor(client) {
191
157
  this.client = client;
192
158
  }
193
- find(_a) {
194
- return __awaiter(this, arguments, void 0, function* ({ filter, sort, limit, after, projection, getTotalCount }) {
195
- var res = yield this.client.get('datastore/find', { filter, after, limit, sort, projection, getTotalCount });
196
- if (res.error) {
197
- console.log(res.error);
198
- throw new Error(res.error);
199
- throw new Error(res['errors']);
200
- }
201
- return res;
202
- });
159
+ async find({ filter, sort, limit, after, projection, lastItem, latestItem, getTotalCount }) {
160
+ var res = await this.client.get('datastore/find', { filter, after, limit, sort, projection, lastItem, latestItem, getTotalCount });
161
+ if (res.error) {
162
+ console.log(res.error);
163
+ throw new Error(res.error);
164
+ throw new Error(res['errors']);
165
+ }
166
+ return res;
203
167
  }
204
- findItems(query) {
205
- return __awaiter(this, void 0, void 0, function* () {
206
- var res = yield this.client.get('datastore/findItems', query);
207
- if (res['errors']) {
208
- console.log(res['errors']);
209
- throw new Error(res['errors']);
210
- }
211
- const items = res['items'];
212
- return items;
213
- });
168
+ async findItems(query) {
169
+ var res = await this.client.get('datastore/findItems', query);
170
+ if (res['errors']) {
171
+ console.log(res['errors']);
172
+ throw new Error(res['errors']);
173
+ }
174
+ const items = res['items'];
175
+ return items;
214
176
  }
215
- findInstances(query_1) {
216
- return __awaiter(this, arguments, void 0, function* (query, projection = {}) {
217
- const res = yield this.client.get('datastore/findInstances', { query, projection });
218
- if (res['errors']) {
219
- console.log(res['errors']);
220
- throw new Error(res['errors']);
221
- }
222
- const instances = res['instances'];
223
- return instances;
224
- });
177
+ async findInstances(query, projection = {}) {
178
+ const res = await this.client.get('datastore/findInstances', { query, projection });
179
+ if (res['errors']) {
180
+ console.log(res['errors']);
181
+ throw new Error(res['errors']);
182
+ }
183
+ const instances = res['instances'];
184
+ return instances;
225
185
  }
226
- deleteInstances(query) {
227
- return __awaiter(this, void 0, void 0, function* () {
228
- return yield this.client.del('datastore/deleteInstances', query);
229
- });
186
+ async deleteInstances(query) {
187
+ return await this.client.del('datastore/deleteInstances', query);
230
188
  }
231
189
  }
232
- exports.ClientDatastore = ClientDatastore;
233
190
  class ClientDefinitions {
191
+ client;
234
192
  constructor(client) {
235
193
  this.client = client;
236
194
  }
237
- import(name_1, pathToBPMN_1) {
238
- return __awaiter(this, arguments, void 0, function* (name, pathToBPMN, pathToSVG = null) {
239
- var options = {
240
- 'method': 'POST',
241
- 'host': this.client.host,
242
- 'port': this.client.port,
243
- 'path': '/api/definitions/import/' + name,
244
- 'headers': {
245
- 'x-api-key': this.client.apiKey
246
- },
247
- 'maxRedirects': 20
248
- };
249
- console.log('import ', name, pathToBPMN, pathToSVG);
250
- var res = yield this.client.upload(name, pathToBPMN, pathToSVG, options);
251
- console.log('import done ', res);
252
- this.checkErrors(res);
253
- return res;
254
- });
255
- }
256
- list() {
257
- return __awaiter(this, void 0, void 0, function* () {
258
- var res = yield this.client.get('definitions/list', []);
259
- if (res['errors']) {
260
- console.log(res['errors']);
261
- throw new Error(res['errors']);
262
- }
263
- return res;
264
- });
195
+ async import(name, pathToBPMN, pathToSVG = null) {
196
+ var options = {
197
+ 'method': 'POST',
198
+ 'host': this.client.host,
199
+ 'port': this.client.port,
200
+ 'path': '/api/definitions/import/' + name,
201
+ 'headers': {
202
+ 'x-api-key': this.client.apiKey
203
+ },
204
+ 'maxRedirects': 20
205
+ };
206
+ console.log('import ', name, pathToBPMN, pathToSVG);
207
+ var res = await this.client.upload(name, pathToBPMN, pathToSVG, options);
208
+ console.log('import done ', res);
209
+ this.checkErrors(res);
210
+ return res;
211
+ }
212
+ async list() {
213
+ var res = await this.client.get('definitions/list', []);
214
+ if (res['errors']) {
215
+ console.log(res['errors']);
216
+ throw new Error(res['errors']);
217
+ }
218
+ return res;
265
219
  }
266
- delete(name) {
267
- return __awaiter(this, void 0, void 0, function* () {
268
- const res = yield this.client.post('definitions/delete/', { name });
269
- if (res['errors']) {
270
- console.log(res['errors']);
271
- throw new Error(res['errors']);
272
- }
273
- console.log(res);
274
- return res;
275
- });
220
+ async delete(name) {
221
+ const res = await this.client.post('definitions/delete/', { name });
222
+ if (res['errors']) {
223
+ console.log(res['errors']);
224
+ throw new Error(res['errors']);
225
+ }
226
+ console.log(res);
227
+ return res;
276
228
  }
277
- rename(name, newName) {
278
- return __awaiter(this, void 0, void 0, function* () {
279
- const res = yield this.client.post('definitions/rename/', { name, newName });
280
- if (res['errors']) {
281
- console.log(res['errors']);
282
- throw new Error(res['errors']);
283
- }
284
- console.log(res);
285
- return res;
286
- });
229
+ async rename(name, newName) {
230
+ const res = await this.client.post('definitions/rename/', { name, newName });
231
+ if (res['errors']) {
232
+ console.log(res['errors']);
233
+ throw new Error(res['errors']);
234
+ }
235
+ console.log(res);
236
+ return res;
287
237
  }
288
- load(name) {
289
- return __awaiter(this, void 0, void 0, function* () {
290
- const res = yield this.client.get(encodeURI('definitions/load/' + name), { name });
291
- if (res['errors']) {
292
- console.log(res['errors']);
293
- throw new Error(res['errors']);
294
- }
295
- console.log(res);
296
- return res;
297
- });
238
+ async load(name) {
239
+ const res = await this.client.get(encodeURI('definitions/load/' + name), { name });
240
+ if (res['errors']) {
241
+ console.log(res['errors']);
242
+ throw new Error(res['errors']);
243
+ }
244
+ console.log(res);
245
+ return res;
298
246
  }
299
247
  checkErrors(res) {
300
248
  if (res['errors']) {
@@ -303,4 +251,5 @@ class ClientDefinitions {
303
251
  }
304
252
  }
305
253
  }
306
- exports.ClientDefinitions = ClientDefinitions;
254
+ export { BPMNClient, ClientEngine, ClientDatastore, ClientDefinitions };
255
+ //# sourceMappingURL=BPMNClient.js.map