bpmn-client 1.4.0 → 2.1.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.
Files changed (58) hide show
  1. package/README.md +32 -0
  2. package/bin/cli.js +245 -0
  3. package/bin/setup.js +24 -0
  4. package/{src → dist}/BPMNClient.js +285 -273
  5. package/dist/BPMNClient2.js +252 -0
  6. package/{src → dist}/WebService.js +82 -82
  7. package/{cli.js → dist/cli.js} +243 -242
  8. package/{src → dist}/index.js +16 -19
  9. package/{src/interfaces/BPMNClient.js → dist/interfaces/API.js} +2 -2
  10. package/{src → dist}/interfaces/DataObjects.js +2 -2
  11. package/{src → dist}/interfaces/Enums.js +124 -112
  12. package/{remote-import.js → dist/remote-import.js} +137 -137
  13. package/dist/setup.js +22 -0
  14. package/{test-raw.js → dist/test-raw.js} +73 -74
  15. package/dist/test.js +75 -0
  16. package/dist/test2.js +78 -0
  17. package/{test3.js → dist/test3.js} +42 -42
  18. package/package.json +11 -2
  19. package/.env +0 -4
  20. package/Sample/.env +0 -4
  21. package/Sample/CarExample.js +0 -62
  22. package/Sample/CarExample.ts +0 -97
  23. package/Sample/package.json +0 -44
  24. package/Sample/test.js +0 -33
  25. package/Sample/test.ts +0 -32
  26. package/Sample/tsconfig.json +0 -17
  27. package/cli.ts +0 -268
  28. package/demo.env +0 -4
  29. package/index.js +0 -17
  30. package/index.ts +0 -1
  31. package/local.env +0 -4
  32. package/monitor.js +0 -91
  33. package/monitor.ts +0 -100
  34. package/remote-import.ts +0 -167
  35. package/src/BPMNClient.ts +0 -265
  36. package/src/WebService.ts +0 -90
  37. package/src/index.ts +0 -4
  38. package/src/interfaces/BPMNClient.ts +0 -29
  39. package/src/interfaces/DataObjects.ts +0 -100
  40. package/src/interfaces/Enums.ts +0 -82
  41. package/test/.eslintrc.json +0 -20
  42. package/test/.mocharc.json +0 -12
  43. package/test/feature/.env +0 -4
  44. package/test/feature/car.js +0 -123
  45. package/test/feature/carServer.js +0 -123
  46. package/test/helpers/setup.js +0 -9
  47. package/test/logs/Buy Used Carrepairsfalse cleaning +0 -0
  48. package/test/logs/Buy Used Carrepairstrue cleaning +0 -0
  49. package/test/logs/Buy Used Carscenario CaseId +0 -0
  50. package/test/logs/carrepairsfalse cleaning +0 -0
  51. package/test/logs/carrepairstrue cleaning +0 -0
  52. package/test-raw.ts +0 -73
  53. package/test.env +0 -4
  54. package/test.js +0 -258
  55. package/test.ts +0 -339
  56. package/test3.ts +0 -40
  57. package/tsconfig.json +0 -17
  58. /package/{test2.js → dist/monitor.js} +0 -0
@@ -1,273 +1,285 @@
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
- console.log("BPMNClient 1.2");
15
- class BPMNClient extends WebService_1.WebService {
16
- constructor(host, port, apiKey) {
17
- super();
18
- this.host = host;
19
- this.port = port;
20
- this.apiKey = apiKey;
21
- this.engine = new ClientEngine(this);
22
- this.datastore = new ClientDatastore(this);
23
- this.definitions = new ClientDefinitions(this);
24
- }
25
- get(url, data = {}) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- return yield this.request(url, 'GET', data);
28
- });
29
- }
30
- post(url, data = {}) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- return yield this.request(url, 'POST', data);
33
- });
34
- }
35
- put(url, data = {}) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- return yield this.request(url, 'PUT', data);
38
- });
39
- }
40
- del(url, data = {}) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- return yield this.request(url, 'DELETE', data);
43
- });
44
- }
45
- request(url, method, params) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- var body = JSON.stringify(params);
48
- var size = Buffer.byteLength(body);
49
- var contentType = "application/json";
50
- if (method == 'UPLOAD') {
51
- contentType = 'multipart/form-data; boundary = ----WebKitFormBoundary7MA4YWxkTrZu0gW';
52
- method = 'POST';
53
- }
54
- var headers = {
55
- "Content-Type": contentType,
56
- "x-api-key": this.apiKey,
57
- "Accept": "*/*",
58
- // "User-Agent": "PostmanRuntime/ 7.26.8",
59
- // "Accept-Encoding": "gzip, deflate, br",
60
- "Connection": "keep-alive"
61
- //,
62
- // "Content-Length": Buffer.byteLength(body)
63
- };
64
- var options;
65
- if (params) {
66
- options = {
67
- host: this.host,
68
- port: this.port,
69
- path: '/api/' + url,
70
- method: method,
71
- headers: headers
72
- };
73
- }
74
- else {
75
- options = {
76
- host: this.host,
77
- port: this.port,
78
- path: '/api/' + url,
79
- method: method
80
- };
81
- }
82
- return yield this.invoke(params, options);
83
- });
84
- }
85
- }
86
- exports.BPMNClient = BPMNClient;
87
- class ClientEngine {
88
- constructor(client) {
89
- this.client = client;
90
- }
91
- start(name, data = {}, startNodeId = null, userId = null, options = {}) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const ret = yield this.client.post('engine/start', { name, data, startNodeId, userId, options });
94
- if (ret['errors']) {
95
- console.log(ret['errors']);
96
- throw new Error(ret['errors']);
97
- }
98
- const instance = ret;
99
- return instance;
100
- });
101
- }
102
- invoke(query, data, userId = null) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const ret = yield this.client.put('engine/invoke', { query, data, userId });
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, data, userId = null, assignment) {
114
- return __awaiter(this, void 0, void 0, function* () {
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
- throwMessage(messageId, data = {}, messageMatchingKey = {}) {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- const ret = yield this.client.post('engine/throwMessage', { "messageId": messageId, "data": data, messageMatchingKey });
127
- if (ret['errors']) {
128
- console.log(ret['errors']);
129
- throw new Error(ret['errors']);
130
- }
131
- return ret;
132
- });
133
- }
134
- throwSignal(signalId, data = {}, messageMatchingKey = {}) {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- const ret = yield this.client.post('engine/throwSignal', { "signalId": signalId, "data": data, messageMatchingKey });
137
- if (ret['errors']) {
138
- console.log(ret['errors']);
139
- throw new Error(ret['errors']);
140
- }
141
- return ret;
142
- });
143
- }
144
- get(query) {
145
- return __awaiter(this, void 0, void 0, function* () {
146
- const ret = yield this.client.get('engine/get', query);
147
- if (ret['errors']) {
148
- console.log(ret['errors']);
149
- throw new Error(ret['errors']);
150
- }
151
- const instance = ret['instance'];
152
- return instance;
153
- });
154
- }
155
- status() {
156
- return __awaiter(this, void 0, void 0, function* () {
157
- const ret = yield this.client.get('engine/status', {});
158
- if (ret['errors']) {
159
- console.log(ret['errors']);
160
- throw new Error(ret['errors']);
161
- }
162
- return ret;
163
- });
164
- }
165
- }
166
- exports.ClientEngine = ClientEngine;
167
- class ClientDatastore {
168
- constructor(client) {
169
- this.client = client;
170
- }
171
- findItems(query) {
172
- return __awaiter(this, void 0, void 0, function* () {
173
- var res = yield this.client.get('datastore/findItems', query);
174
- if (res['errors']) {
175
- console.log(res['errors']);
176
- throw new Error(res['errors']);
177
- }
178
- const items = res['items'];
179
- return items;
180
- });
181
- }
182
- findInstances(query) {
183
- return __awaiter(this, void 0, void 0, function* () {
184
- const res = yield this.client.get('datastore/findInstances', query);
185
- if (res['errors']) {
186
- console.log(res['errors']);
187
- throw new Error(res['errors']);
188
- }
189
- const instances = res['instances'];
190
- return instances;
191
- });
192
- }
193
- deleteInstances(query) {
194
- return __awaiter(this, void 0, void 0, function* () {
195
- return yield this.client.del('datastore/deleteInstances', query);
196
- });
197
- }
198
- }
199
- exports.ClientDatastore = ClientDatastore;
200
- class ClientDefinitions {
201
- constructor(client) {
202
- this.client = client;
203
- }
204
- import(name, pathToBPMN, pathToSVG = null) {
205
- return __awaiter(this, void 0, void 0, function* () {
206
- var options = {
207
- 'method': 'POST',
208
- 'host': this.client.host,
209
- 'port': this.client.port,
210
- 'path': '/api/definitions/import/' + name,
211
- 'headers': {
212
- 'x-api-key': this.client.apiKey
213
- },
214
- 'maxRedirects': 20
215
- };
216
- console.log('import ', name, pathToBPMN, pathToSVG);
217
- var res = yield this.client.upload(name, pathToBPMN, pathToSVG, options);
218
- console.log('import done ', res);
219
- this.checkErrors(res);
220
- return res;
221
- });
222
- }
223
- list() {
224
- return __awaiter(this, void 0, void 0, function* () {
225
- var res = yield this.client.get('definitions/list', []);
226
- if (res['errors']) {
227
- console.log(res['errors']);
228
- throw new Error(res['errors']);
229
- }
230
- return res;
231
- });
232
- }
233
- delete(name) {
234
- return __awaiter(this, void 0, void 0, function* () {
235
- const res = yield this.client.post('definitions/delete/', { name });
236
- if (res['errors']) {
237
- console.log(res['errors']);
238
- throw new Error(res['errors']);
239
- }
240
- console.log(res);
241
- return res;
242
- });
243
- }
244
- rename(name, newName) {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- const res = yield this.client.post('definitions/rename/', { name, newName });
247
- if (res['errors']) {
248
- console.log(res['errors']);
249
- throw new Error(res['errors']);
250
- }
251
- console.log(res);
252
- return res;
253
- });
254
- }
255
- load(name) {
256
- return __awaiter(this, void 0, void 0, function* () {
257
- const res = yield this.client.get(encodeURI('definitions/load/' + name), { name });
258
- if (res['errors']) {
259
- console.log(res['errors']);
260
- throw new Error(res['errors']);
261
- }
262
- console.log(res);
263
- return res;
264
- });
265
- }
266
- checkErrors(res) {
267
- if (res['errors']) {
268
- console.log(res['errors']);
269
- throw new Error(res['errors']);
270
- }
271
- }
272
- }
273
- exports.ClientDefinitions = ClientDefinitions;
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 {
15
+ constructor(host, port, apiKey) {
16
+ super();
17
+ this.host = host;
18
+ this.port = port;
19
+ this.apiKey = apiKey;
20
+ this.engine = new ClientEngine(this);
21
+ this.datastore = new ClientDatastore(this);
22
+ this.definitions = new ClientDefinitions(this);
23
+ }
24
+ get(url, data = {}) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return yield this.request(url, 'GET', data);
27
+ });
28
+ }
29
+ post(url, data = {}) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ return yield this.request(url, 'POST', data);
32
+ });
33
+ }
34
+ put(url, data = {}) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return yield this.request(url, 'PUT', data);
37
+ });
38
+ }
39
+ del(url, data = {}) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ return yield this.request(url, 'DELETE', data);
42
+ });
43
+ }
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)
62
+ };
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
+ });
83
+ }
84
+ }
85
+ exports.BPMNClient = BPMNClient;
86
+ class ClientEngine {
87
+ constructor(client) {
88
+ this.client = client;
89
+ }
90
+ start(name, data = {}, startNodeId = null, userId = null, options = {}) {
91
+ return __awaiter(this, void 0, void 0, function* () {
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, data, userId = null, options = {}) {
102
+ return __awaiter(this, void 0, void 0, function* () {
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, data, userId = null, assignment) {
114
+ return __awaiter(this, void 0, void 0, function* () {
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, data, userId = null, options = {}) {
125
+ return __awaiter(this, void 0, void 0, function* () {
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, data = {}, messageMatchingKey = {}) {
137
+ return __awaiter(this, void 0, void 0, function* () {
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, data = {}, messageMatchingKey = {}) {
147
+ return __awaiter(this, void 0, void 0, function* () {
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
+ });
155
+ }
156
+ get(query) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ const ret = yield this.client.get('engine/get', query);
159
+ if (ret['errors']) {
160
+ console.log(ret['errors']);
161
+ throw new Error(ret['errors']);
162
+ }
163
+ const instance = ret['instance'];
164
+ return instance;
165
+ });
166
+ }
167
+ status() {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ const ret = yield this.client.get('engine/status', {});
170
+ if (ret['errors']) {
171
+ console.log(ret['errors']);
172
+ throw new Error(ret['errors']);
173
+ }
174
+ return ret;
175
+ });
176
+ }
177
+ }
178
+ exports.ClientEngine = ClientEngine;
179
+ class ClientDatastore {
180
+ constructor(client) {
181
+ this.client = client;
182
+ }
183
+ findItems(query) {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ var res = yield this.client.get('datastore/findItems', query);
186
+ if (res['errors']) {
187
+ console.log(res['errors']);
188
+ throw new Error(res['errors']);
189
+ }
190
+ const items = res['items'];
191
+ return items;
192
+ });
193
+ }
194
+ findInstances(query) {
195
+ return __awaiter(this, void 0, void 0, function* () {
196
+ const res = yield this.client.get('datastore/findInstances', query);
197
+ if (res['errors']) {
198
+ console.log(res['errors']);
199
+ throw new Error(res['errors']);
200
+ }
201
+ const instances = res['instances'];
202
+ return instances;
203
+ });
204
+ }
205
+ deleteInstances(query) {
206
+ return __awaiter(this, void 0, void 0, function* () {
207
+ return yield this.client.del('datastore/deleteInstances', query);
208
+ });
209
+ }
210
+ }
211
+ exports.ClientDatastore = ClientDatastore;
212
+ class ClientDefinitions {
213
+ constructor(client) {
214
+ this.client = client;
215
+ }
216
+ import(name, pathToBPMN, pathToSVG = null) {
217
+ return __awaiter(this, void 0, void 0, function* () {
218
+ var options = {
219
+ 'method': 'POST',
220
+ 'host': this.client.host,
221
+ 'port': this.client.port,
222
+ 'path': '/api/definitions/import/' + name,
223
+ 'headers': {
224
+ 'x-api-key': this.client.apiKey
225
+ },
226
+ 'maxRedirects': 20
227
+ };
228
+ console.log('import ', name, pathToBPMN, pathToSVG);
229
+ var res = yield this.client.upload(name, pathToBPMN, pathToSVG, options);
230
+ console.log('import done ', res);
231
+ this.checkErrors(res);
232
+ return res;
233
+ });
234
+ }
235
+ list() {
236
+ return __awaiter(this, void 0, void 0, function* () {
237
+ var res = yield this.client.get('definitions/list', []);
238
+ if (res['errors']) {
239
+ console.log(res['errors']);
240
+ throw new Error(res['errors']);
241
+ }
242
+ return res;
243
+ });
244
+ }
245
+ delete(name) {
246
+ return __awaiter(this, void 0, void 0, function* () {
247
+ const res = yield this.client.post('definitions/delete/', { name });
248
+ if (res['errors']) {
249
+ console.log(res['errors']);
250
+ throw new Error(res['errors']);
251
+ }
252
+ console.log(res);
253
+ return res;
254
+ });
255
+ }
256
+ rename(name, newName) {
257
+ return __awaiter(this, void 0, void 0, function* () {
258
+ const res = yield this.client.post('definitions/rename/', { name, newName });
259
+ if (res['errors']) {
260
+ console.log(res['errors']);
261
+ throw new Error(res['errors']);
262
+ }
263
+ console.log(res);
264
+ return res;
265
+ });
266
+ }
267
+ load(name) {
268
+ return __awaiter(this, void 0, void 0, function* () {
269
+ const res = yield this.client.get(encodeURI('definitions/load/' + name), { name });
270
+ if (res['errors']) {
271
+ console.log(res['errors']);
272
+ throw new Error(res['errors']);
273
+ }
274
+ console.log(res);
275
+ return res;
276
+ });
277
+ }
278
+ checkErrors(res) {
279
+ if (res['errors']) {
280
+ console.log(res['errors']);
281
+ throw new Error(res['errors']);
282
+ }
283
+ }
284
+ }
285
+ exports.ClientDefinitions = ClientDefinitions;