bpmn-client 1.4.0 → 1.6.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 (56) hide show
  1. package/README.md +29 -0
  2. package/bin/cli.js +245 -0
  3. package/bin/setup.js +24 -0
  4. package/{src → dist}/BPMNClient.js +3 -3
  5. package/{cli.js → dist/cli.js} +3 -2
  6. package/dist/setup.js +22 -0
  7. package/dist/test.js +75 -0
  8. package/package.json +11 -2
  9. package/.env +0 -4
  10. package/Sample/.env +0 -4
  11. package/Sample/CarExample.js +0 -62
  12. package/Sample/CarExample.ts +0 -97
  13. package/Sample/package.json +0 -44
  14. package/Sample/test.js +0 -33
  15. package/Sample/test.ts +0 -32
  16. package/Sample/tsconfig.json +0 -17
  17. package/cli.ts +0 -268
  18. package/demo.env +0 -4
  19. package/index.js +0 -17
  20. package/index.ts +0 -1
  21. package/local.env +0 -4
  22. package/monitor.ts +0 -100
  23. package/remote-import.ts +0 -167
  24. package/src/BPMNClient.ts +0 -265
  25. package/src/WebService.ts +0 -90
  26. package/src/index.ts +0 -4
  27. package/src/interfaces/BPMNClient.ts +0 -29
  28. package/src/interfaces/DataObjects.ts +0 -100
  29. package/src/interfaces/Enums.ts +0 -82
  30. package/test/.eslintrc.json +0 -20
  31. package/test/.mocharc.json +0 -12
  32. package/test/feature/.env +0 -4
  33. package/test/feature/car.js +0 -123
  34. package/test/feature/carServer.js +0 -123
  35. package/test/helpers/setup.js +0 -9
  36. package/test/logs/Buy Used Carrepairsfalse cleaning +0 -0
  37. package/test/logs/Buy Used Carrepairstrue cleaning +0 -0
  38. package/test/logs/Buy Used Carscenario CaseId +0 -0
  39. package/test/logs/carrepairsfalse cleaning +0 -0
  40. package/test/logs/carrepairstrue cleaning +0 -0
  41. package/test-raw.ts +0 -73
  42. package/test.env +0 -4
  43. package/test.js +0 -258
  44. package/test.ts +0 -339
  45. package/test2.js +0 -91
  46. package/test3.ts +0 -40
  47. package/tsconfig.json +0 -17
  48. /package/{src → dist}/WebService.js +0 -0
  49. /package/{src → dist}/index.js +0 -0
  50. /package/{src/interfaces/BPMNClient.js → dist/interfaces/API.js} +0 -0
  51. /package/{src → dist}/interfaces/DataObjects.js +0 -0
  52. /package/{src → dist}/interfaces/Enums.js +0 -0
  53. /package/{monitor.js → dist/monitor.js} +0 -0
  54. /package/{remote-import.js → dist/remote-import.js} +0 -0
  55. /package/{test-raw.js → dist/test-raw.js} +0 -0
  56. /package/{test3.js → dist/test3.js} +0 -0
package/src/BPMNClient.ts DELETED
@@ -1,265 +0,0 @@
1
- import { IInstanceData, IItemData , IDefinitionData} from './interfaces/DataObjects';
2
- import {WebService} from './WebService';
3
- console.log("BPMNClient 1.2");
4
-
5
-
6
- class BPMNClient extends WebService {
7
- host;
8
- port;
9
- apiKey;
10
- engine: ClientEngine;
11
- datastore: ClientDatastore;
12
- definitions: ClientDefinitions;
13
-
14
- constructor(host, port, apiKey) {
15
- super();
16
-
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
-
25
- async get(url, data = {}) {
26
- return await this.request(url, 'GET', data);
27
-
28
- }
29
- async post(url, data = {}) {
30
- return await this.request(url, 'POST', data);
31
-
32
- }
33
- async put(url, data = {}) {
34
- return await this.request(url, 'PUT', data);
35
-
36
- }
37
- async del(url, data = {}) {
38
- return await this.request(url, 'DELETE', data);
39
-
40
- }
41
-
42
- async request(url, method, params) {
43
-
44
- var body = JSON.stringify(params);
45
- var size = Buffer.byteLength(body);
46
- var contentType = "application/json";
47
-
48
- if (method == 'UPLOAD') {
49
- contentType = 'multipart/form-data; boundary = ----WebKitFormBoundary7MA4YWxkTrZu0gW';
50
- method = 'POST';
51
- }
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
-
64
-
65
- var options;
66
-
67
- if (params) {
68
- options = {
69
- host: this.host,
70
- port: this.port,
71
- path: '/api/' + url,
72
- method: method,
73
- headers: headers
74
- };
75
- }
76
- else {
77
- options = {
78
- host: this.host,
79
- port: this.port,
80
- path: '/api/' + url,
81
- method: method
82
- };
83
- }
84
-
85
- return await this.invoke(params, options);
86
-
87
- }
88
-
89
- }
90
-
91
- class ClientEngine {
92
- private client: BPMNClient;
93
-
94
- constructor(client) {
95
- this.client = client;
96
- }
97
- async start(name, data = {}, startNodeId = null, userId= null,options = {}): Promise<IInstanceData> {
98
- const ret = await this.client.post('engine/start',
99
- { name, data, startNodeId, userId, options });
100
- if (ret['errors']) {
101
- console.log(ret['errors']);
102
- throw new Error(ret['errors']);
103
- }
104
- const instance = ret as IInstanceData;
105
- return instance;
106
- }
107
- async invoke(query, data, userId= null): Promise<IInstanceData> {
108
- const ret = await this.client.put('engine/invoke', { query, data , userId });
109
- if (ret['errors']) {
110
- console.log(ret['errors']);
111
- throw new Error(ret['errors']);
112
- }
113
- const instance = ret['instance'] as IInstanceData;
114
- return instance;
115
- }
116
- async assign(query, data, userId= null,assignment): Promise<IInstanceData> {
117
- const ret = await this.client.put('engine/assign', { query, data , userId,assignment });
118
- if (ret['errors']) {
119
- console.log(ret['errors']);
120
- throw new Error(ret['errors']);
121
- }
122
- const instance = ret['instance'] as IInstanceData;
123
- return instance;
124
- }
125
-
126
- async throwMessage(messageId, data = {} , messageMatchingKey = {}) {
127
- const ret = await this.client.post('engine/throwMessage', { "messageId": messageId, "data": data, messageMatchingKey });
128
- if (ret['errors']) {
129
- console.log(ret['errors']);
130
- throw new Error(ret['errors']);
131
- }
132
- return ret;
133
- }
134
- async throwSignal(signalId, data = {} , messageMatchingKey = {}) {
135
- const ret = await this.client.post('engine/throwSignal', { "signalId": signalId, "data": data, messageMatchingKey });
136
- if (ret['errors']) {
137
- console.log(ret['errors']);
138
- throw new Error(ret['errors']);
139
- }
140
- return ret;
141
- }
142
-
143
- async get(query): Promise<IInstanceData> {
144
- const ret = await this.client.get('engine/get', query);
145
- if (ret['errors']) {
146
- console.log(ret['errors']);
147
- throw new Error(ret['errors']);
148
- }
149
- const instance = ret['instance'] as IInstanceData;
150
- return instance;
151
- }
152
- async status() {
153
- const ret = await this.client.get('engine/status', {});
154
- if (ret['errors']) {
155
- console.log(ret['errors']);
156
- throw new Error(ret['errors']);
157
- }
158
- return ret;
159
- }
160
- }
161
- class ClientDatastore {
162
- private client: BPMNClient;
163
-
164
- constructor(client) {
165
- this.client = client;
166
- }
167
- async findItems(query): Promise<IItemData[]> {
168
- var res = await this.client.get('datastore/findItems', query);
169
- if (res['errors']) {
170
- console.log(res['errors']);
171
- throw new Error(res['errors']);
172
- }
173
- const items = res['items'] as IItemData[];
174
- return items;
175
-
176
- }
177
- async findInstances(query): Promise<IInstanceData[]> {
178
- const res = await this.client.get('datastore/findInstances', query);
179
-
180
- if (res['errors']) {
181
- console.log(res['errors']);
182
- throw new Error(res['errors']);
183
- }
184
- const instances = res['instances'] as IInstanceData[];
185
- return instances;
186
- }
187
- async deleteInstances(query) {
188
- return await this.client.del('datastore/deleteInstances', query);
189
- }
190
- }
191
- class ClientDefinitions {
192
- private client: BPMNClient;
193
-
194
- constructor(client) {
195
- this.client = client;
196
- }
197
-
198
- async import(name, pathToBPMN,pathToSVG=null) {
199
-
200
- var options = {
201
- 'method': 'POST',
202
- 'host': this.client.host,
203
- 'port': this.client.port,
204
- 'path': '/api/definitions/import/' + name,
205
- 'headers': {
206
- 'x-api-key': this.client.apiKey
207
- },
208
- 'maxRedirects': 20
209
- };
210
-
211
- console.log('import ',name,pathToBPMN,pathToSVG);
212
- var res = await this.client.upload(name,pathToBPMN,pathToSVG,options);
213
- console.log('import done ',res);
214
- this.checkErrors(res);
215
- return res;
216
-
217
- }
218
- async list(): Promise<string[]> {
219
- var res = await this.client.get('definitions/list', []);
220
- if (res['errors']) {
221
- console.log(res['errors']);
222
- throw new Error(res['errors']);
223
- }
224
- return res as string[];
225
-
226
- }
227
- async delete(name) {
228
- const res = await this.client.post('definitions/delete/', { name });
229
- if (res['errors']) {
230
- console.log(res['errors']);
231
- throw new Error(res['errors']);
232
- }
233
- console.log(res);
234
- return res as IDefinitionData;
235
-
236
- }
237
- async rename(name,newName) {
238
- const res = await this.client.post('definitions/rename/', { name , newName });
239
- if (res['errors']) {
240
- console.log(res['errors']);
241
- throw new Error(res['errors']);
242
- }
243
- console.log(res);
244
- return res as IDefinitionData;
245
-
246
- }
247
- async load(name): Promise<IDefinitionData> {
248
- const res = await this.client.get(encodeURI('definitions/load/' + name), { name });
249
- if (res['errors']) {
250
- console.log(res['errors']);
251
- throw new Error(res['errors']);
252
- }
253
- console.log(res);
254
- return res as IDefinitionData;
255
- }
256
- checkErrors(res) {
257
- if (res['errors']) {
258
- console.log(res['errors']);
259
- throw new Error(res['errors']);
260
- }
261
- }
262
- }
263
-
264
-
265
- export { BPMNClient , ClientEngine,ClientDatastore , ClientDefinitions}
package/src/WebService.ts DELETED
@@ -1,90 +0,0 @@
1
-
2
- const https = require('https');
3
- const http = require('http');
4
- const fs = require("fs");
5
- const axios = require('axios');
6
- const FormData = require('form-data');
7
-
8
- class WebService {
9
- statusCode;
10
- result;
11
- response;
12
- constructor() { }
13
-
14
- async invoke(params, options, postData = null) {
15
-
16
-
17
- var data = JSON.stringify(params);
18
- var url = 'http://'+options.host+':'+options.port+options.path;
19
-
20
- if (options.port == 443)
21
- url = 'https://'+options.host+options.path;
22
-
23
- var config = {
24
- method: options.method,
25
- url: url,
26
- headers: options.headers,
27
- data: data
28
- };
29
-
30
- let self = this;
31
- try {
32
- let response = await axios(config);
33
- self.result = response.data;
34
-
35
- return response.data;
36
- }
37
- catch(err)
38
- {
39
- console.log('** Connection failed ***',err);
40
- }
41
- }
42
-
43
- async upload(fileName, path,path2, options) {
44
-
45
- const title = fileName;
46
-
47
- var url = 'http://'+options.host+':'+options.port+options.path;
48
-
49
- if (options.port == 443)
50
- url = 'https://'+options.host+options.path;
51
-
52
- const form = new FormData();
53
- form.append('title', title);
54
- const fileContents = fs.createReadStream(path);
55
- form.append('file', fileContents);
56
- if (path2!==null)
57
- {
58
- const fileContents2 = fs.createReadStream(path2);
59
- form.append('file', fileContents2);
60
- }
61
-
62
-
63
- try {
64
-
65
- const response = await axios.post(url, form, {
66
- headers: options.headers });
67
-
68
- console.log('Response Status:',response.status,response.data);
69
- return response.data;
70
-
71
- }
72
- catch (error) {
73
- console.log('upload failed:',error);
74
- throw new Error(error.message);
75
- /*
76
- if (error.response) { // get response with a status code not in range 2xx
77
- console.log(error.response.data);
78
- console.log(error.response.status);
79
- console.log(error.response.headers);
80
- } else if (error.request) { // no response
81
- console.log(error.request);
82
- } else { // Something wrong in setting up the request
83
- console.log('Error', error.message);
84
- }
85
- console.log(error.config); */
86
- }
87
- }
88
-
89
- }
90
- export {WebService }
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './interfaces/Enums';
2
- export * from './interfaces/DataObjects';
3
- export * from './BPMNClient';
4
-
@@ -1,29 +0,0 @@
1
- import { IInstanceData, IItemData , IDefinitionData} from './DataObjects';
2
-
3
-
4
- export interface IBPMNClient {
5
- engine: IClientEngine;
6
- datastore: IClientDatastore;
7
- definitions: IClientDefinitions;
8
- }
9
-
10
- export interface IClientEngine {
11
- start(name, data , startNodeId , userId,options ): Promise<IInstanceData>;
12
- invoke(query, data, userId): Promise<IInstanceData> ;
13
- assign(query, data, userId,assignment): Promise<IInstanceData>;
14
- throwMessage(messageId, data, messageMatchingKey);
15
- throwSignal(signalId, data, messageMatchingKey);
16
- status();
17
- }
18
- export interface IClientDatastore {
19
- findItems(query): Promise<IItemData[]>;
20
- findInstances(query): Promise<IInstanceData[]>;
21
- deleteInstances(query);
22
- }
23
- export interface IClientDefinitions {
24
- import(name, pathToBPMN,pathToSVG);
25
- list(): Promise<string[]>;
26
- delete(name) ;
27
- rename(name,newName);
28
- load(name): Promise<IDefinitionData>;
29
- }
@@ -1,100 +0,0 @@
1
- import { ITEM_STATUS, } from './Enums';
2
-
3
- interface IItemData {
4
- id: string; // System generated unique Id
5
- itemKey: string; // application assigned key to call the item by
6
- elementId: string; // bpmn element
7
- name: string; // name of bpmn element
8
- type: string; // bpmn element type
9
- instanceId: string; // Instance Id of the item
10
- tokenId: any; // execution Token
11
- userId: any;
12
- startedAt: any;
13
- endedAt: any;
14
- seq: any;
15
- timeDue: Date;
16
- status: ITEM_STATUS;
17
- data: any;
18
- messageId;
19
- signalId;
20
- vars;
21
- assignee;
22
- candidateGroups;
23
- candidateUsers;
24
- dueDate;
25
- followUpDate;
26
- priority;
27
- }
28
- interface IInstanceData {
29
- id;
30
- name;
31
- status;
32
- startedAt;
33
- endedAt;
34
- saved;
35
- data;
36
- items;
37
- source;
38
- logs;
39
- tokens;
40
- loops;
41
- parentItemId; // used for subProcess Calls
42
- }
43
-
44
-
45
-
46
- interface IDefinitionData {
47
- name: any;
48
- processes: Map<any, any>;
49
- rootElements: any;
50
- nodes: Map<any, any>;
51
- flows: any[];
52
- source: any;
53
- logger: any;
54
- accessRules: any[];
55
- }
56
-
57
-
58
- interface IElementData {
59
- id: any;
60
- type: any;
61
- name: any;
62
- behaviours: Map<any, any>;
63
- }
64
-
65
- interface IFlowData {
66
-
67
- }
68
-
69
- interface IEventData {
70
- elementId: string;
71
- processId: string;
72
- type;
73
- name;
74
- subType;
75
- signalId?: string;
76
- messageId?: string;
77
- // timer info
78
- expression;
79
- expressionFormat; // cron/iso
80
- referenceDateTime; // start time of event or last time timer ran
81
- maxRepeat;
82
- repeatCount;
83
- timeDue?: Date;
84
-
85
- }
86
- interface IBpmnModelData {
87
- name;
88
- source;
89
- svg;
90
- processes: IProcessData[];
91
- events: IEventData[];
92
- saved;
93
- // parse(definition: IDefinition);
94
- }
95
- interface IProcessData {
96
- id;
97
- name;
98
- isExecutable;
99
- }
100
- export { IItemData, IInstanceData , IDefinitionData, IElementData, IFlowData , IBpmnModelData, IProcessData, IEventData }
@@ -1,82 +0,0 @@
1
-
2
- enum BPMN_TYPE {
3
- UserTask = 'bpmn:UserTask',
4
- ScriptTask = 'bpmn:ScriptTask',
5
- ServiceTask = 'bpmn:ServiceTask',
6
- SendTask = 'bpmn:SendTask',
7
- ReceiveTask = 'bpmn:ReceiveTask',
8
- BusinessRuleTask = 'bpmn:BusinessRuleTask',
9
- SubProcess = 'bpmn:SubProcess',
10
- ParallelGateway = 'bpmn:ParallelGateway',
11
- EventBasedGateway = 'bpmn:EventBasedGateway',
12
- InclusiveGateway = 'bpmn:InclusiveGateway',
13
- ExclusiveGateway = 'bpmn:ExclusiveGateway',
14
- BoundaryEvent = 'bpmn:BoundaryEvent',
15
- StartEvent = 'bpmn:StartEvent',
16
- IntermediateCatchEvent = 'bpmn:IntermediateCatchEvent',
17
- IntermediateThrowEvent = 'bpmn:IntermediateThrowEvent',
18
- EndEvent = 'bpmn:EndEvent',
19
- SequenceFlow = 'bpmn:SequenceFlow',
20
- MessageFlow = 'bpmn:MessageFlow',
21
- CallActivity = 'bpmn:CallActivity'
22
- }
23
-
24
- enum NODE_SUBTYPE {
25
- timer = 'timer',
26
- message = 'message',
27
- signal = 'signal',
28
- error = 'error',
29
- escalation = 'escalation',
30
- cancel = 'cancel',
31
-
32
- compensate = 'compensate'
33
- }
34
- /*
35
- * ALL events
36
- */
37
- enum EXECUTION_EVENT {
38
- node_enter = 'enter', node_start = 'start', node_wait = 'wait', node_end = 'end', node_terminated = 'terminated',
39
- transform_input = 'transformInput', transform_output ='transformOutput',
40
- flow_take = 'take', flow_discard = 'discard',
41
- process_loaded ='process.loaded',
42
- process_start = 'process.start', process_started = 'process.started',
43
- process_invoke = 'process.invoke', process_invoked = 'process.invoked',
44
- process_restored = 'process.restored', process_resumed = 'process_resumed',
45
- process_wait = 'process.wait',
46
- process_end = 'process.end', process_terminated = 'process.terminated' ,
47
- token_start = 'token.start', token_wait = 'token.wait', token_end = 'token.end', token_terminated = 'token.terminated'
48
- }
49
- /*
50
- * possible actions by node
51
- */
52
-
53
- enum NODE_ACTION { continue = 1, wait, end , cancel, stop , error , abort };
54
-
55
- enum ITEM_STATUS {
56
- enter = 'enter',
57
- start = 'start',
58
- wait = 'wait',
59
- end = 'end',
60
- terminated = 'terminated',
61
- cancelled = 'cancelled',
62
- discard = 'discard'
63
-
64
- }
65
-
66
- //type ITEMSTATUS = 'enter' | 'start' | 'wait' | 'end' | 'terminated' | 'discard';
67
-
68
- enum EXECUTION_STATUS { running='running',wait='wait', end = 'end' , terminated ='terminated' }
69
-
70
- enum TOKEN_STATUS { running = 'running', wait = 'wait', end = 'end', terminated = 'terminated' }
71
- /*
72
- * possible actions by flow
73
- */
74
- // must be same as above
75
-
76
- enum FLOW_ACTION { take = 'take', discard = 'discard' }
77
-
78
- export {
79
- BPMN_TYPE ,
80
- EXECUTION_EVENT, NODE_ACTION, FLOW_ACTION,
81
- ITEM_STATUS, TOKEN_STATUS, EXECUTION_STATUS , NODE_SUBTYPE
82
- }
@@ -1,20 +0,0 @@
1
- {
2
- "env": {
3
- "mocha": true
4
- },
5
- "rules": {
6
- "no-unused-expressions": 0,
7
- "no-var": 1,
8
- "prefer-arrow-callback": 1
9
- },
10
- "globals": {
11
- "expect": false,
12
- "Feature": false,
13
- "Scenario": false,
14
- "Given": false,
15
- "When": false,
16
- "Then": false,
17
- "And": false,
18
- "But": false
19
- }
20
- }
@@ -1,12 +0,0 @@
1
- {
2
- "diff": true,
3
- "extension": [ "js" ],
4
- "package": "package.json",
5
- "reporter": "spec",
6
- "slow": 1500,
7
- "timeout": 50000,
8
- "recursive": true,
9
- "file": [ "test/helpers/setup.js" ],
10
- "ui": "mocha-cakes-2",
11
- "watch-files": [ "test/feature/*.js" ]
12
- }
package/test/feature/.env DELETED
@@ -1,4 +0,0 @@
1
- API_KEY=1234
2
- HOST=localhost
3
- PORT=3000
4
- BASE_URL=api