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,112 +1,124 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NODE_SUBTYPE = exports.EXECUTION_STATUS = exports.TOKEN_STATUS = exports.ITEM_STATUS = exports.FLOW_ACTION = exports.NODE_ACTION = exports.EXECUTION_EVENT = exports.BPMN_TYPE = void 0;
4
- var BPMN_TYPE;
5
- (function (BPMN_TYPE) {
6
- BPMN_TYPE["UserTask"] = "bpmn:UserTask";
7
- BPMN_TYPE["ScriptTask"] = "bpmn:ScriptTask";
8
- BPMN_TYPE["ServiceTask"] = "bpmn:ServiceTask";
9
- BPMN_TYPE["SendTask"] = "bpmn:SendTask";
10
- BPMN_TYPE["ReceiveTask"] = "bpmn:ReceiveTask";
11
- BPMN_TYPE["BusinessRuleTask"] = "bpmn:BusinessRuleTask";
12
- BPMN_TYPE["SubProcess"] = "bpmn:SubProcess";
13
- BPMN_TYPE["ParallelGateway"] = "bpmn:ParallelGateway";
14
- BPMN_TYPE["EventBasedGateway"] = "bpmn:EventBasedGateway";
15
- BPMN_TYPE["InclusiveGateway"] = "bpmn:InclusiveGateway";
16
- BPMN_TYPE["ExclusiveGateway"] = "bpmn:ExclusiveGateway";
17
- BPMN_TYPE["BoundaryEvent"] = "bpmn:BoundaryEvent";
18
- BPMN_TYPE["StartEvent"] = "bpmn:StartEvent";
19
- BPMN_TYPE["IntermediateCatchEvent"] = "bpmn:IntermediateCatchEvent";
20
- BPMN_TYPE["IntermediateThrowEvent"] = "bpmn:IntermediateThrowEvent";
21
- BPMN_TYPE["EndEvent"] = "bpmn:EndEvent";
22
- BPMN_TYPE["SequenceFlow"] = "bpmn:SequenceFlow";
23
- BPMN_TYPE["MessageFlow"] = "bpmn:MessageFlow";
24
- BPMN_TYPE["CallActivity"] = "bpmn:CallActivity";
25
- })(BPMN_TYPE || (exports.BPMN_TYPE = BPMN_TYPE = {}));
26
- var NODE_SUBTYPE;
27
- (function (NODE_SUBTYPE) {
28
- NODE_SUBTYPE["timer"] = "timer";
29
- NODE_SUBTYPE["message"] = "message";
30
- NODE_SUBTYPE["signal"] = "signal";
31
- NODE_SUBTYPE["error"] = "error";
32
- NODE_SUBTYPE["escalation"] = "escalation";
33
- NODE_SUBTYPE["cancel"] = "cancel";
34
- NODE_SUBTYPE["compensate"] = "compensate";
35
- })(NODE_SUBTYPE || (exports.NODE_SUBTYPE = NODE_SUBTYPE = {}));
36
- /*
37
- * ALL events
38
- */
39
- var EXECUTION_EVENT;
40
- (function (EXECUTION_EVENT) {
41
- EXECUTION_EVENT["node_enter"] = "enter";
42
- EXECUTION_EVENT["node_start"] = "start";
43
- EXECUTION_EVENT["node_wait"] = "wait";
44
- EXECUTION_EVENT["node_end"] = "end";
45
- EXECUTION_EVENT["node_terminated"] = "terminated";
46
- EXECUTION_EVENT["transform_input"] = "transformInput";
47
- EXECUTION_EVENT["transform_output"] = "transformOutput";
48
- EXECUTION_EVENT["flow_take"] = "take";
49
- EXECUTION_EVENT["flow_discard"] = "discard";
50
- EXECUTION_EVENT["process_loaded"] = "process.loaded";
51
- EXECUTION_EVENT["process_start"] = "process.start";
52
- EXECUTION_EVENT["process_started"] = "process.started";
53
- EXECUTION_EVENT["process_invoke"] = "process.invoke";
54
- EXECUTION_EVENT["process_invoked"] = "process.invoked";
55
- EXECUTION_EVENT["process_restored"] = "process.restored";
56
- EXECUTION_EVENT["process_resumed"] = "process_resumed";
57
- EXECUTION_EVENT["process_wait"] = "process.wait";
58
- EXECUTION_EVENT["process_end"] = "process.end";
59
- EXECUTION_EVENT["process_terminated"] = "process.terminated";
60
- EXECUTION_EVENT["token_start"] = "token.start";
61
- EXECUTION_EVENT["token_wait"] = "token.wait";
62
- EXECUTION_EVENT["token_end"] = "token.end";
63
- EXECUTION_EVENT["token_terminated"] = "token.terminated";
64
- })(EXECUTION_EVENT || (exports.EXECUTION_EVENT = EXECUTION_EVENT = {}));
65
- /*
66
- * possible actions by node
67
- */
68
- var NODE_ACTION;
69
- (function (NODE_ACTION) {
70
- NODE_ACTION[NODE_ACTION["continue"] = 1] = "continue";
71
- NODE_ACTION[NODE_ACTION["wait"] = 2] = "wait";
72
- NODE_ACTION[NODE_ACTION["end"] = 3] = "end";
73
- NODE_ACTION[NODE_ACTION["cancel"] = 4] = "cancel";
74
- NODE_ACTION[NODE_ACTION["stop"] = 5] = "stop";
75
- NODE_ACTION[NODE_ACTION["error"] = 6] = "error";
76
- NODE_ACTION[NODE_ACTION["abort"] = 7] = "abort";
77
- })(NODE_ACTION || (exports.NODE_ACTION = NODE_ACTION = {}));
78
- ;
79
- var ITEM_STATUS;
80
- (function (ITEM_STATUS) {
81
- ITEM_STATUS["enter"] = "enter";
82
- ITEM_STATUS["start"] = "start";
83
- ITEM_STATUS["wait"] = "wait";
84
- ITEM_STATUS["end"] = "end";
85
- ITEM_STATUS["terminated"] = "terminated";
86
- ITEM_STATUS["cancelled"] = "cancelled";
87
- ITEM_STATUS["discard"] = "discard";
88
- })(ITEM_STATUS || (exports.ITEM_STATUS = ITEM_STATUS = {}));
89
- //type ITEMSTATUS = 'enter' | 'start' | 'wait' | 'end' | 'terminated' | 'discard';
90
- var EXECUTION_STATUS;
91
- (function (EXECUTION_STATUS) {
92
- EXECUTION_STATUS["running"] = "running";
93
- EXECUTION_STATUS["wait"] = "wait";
94
- EXECUTION_STATUS["end"] = "end";
95
- EXECUTION_STATUS["terminated"] = "terminated";
96
- })(EXECUTION_STATUS || (exports.EXECUTION_STATUS = EXECUTION_STATUS = {}));
97
- var TOKEN_STATUS;
98
- (function (TOKEN_STATUS) {
99
- TOKEN_STATUS["running"] = "running";
100
- TOKEN_STATUS["wait"] = "wait";
101
- TOKEN_STATUS["end"] = "end";
102
- TOKEN_STATUS["terminated"] = "terminated";
103
- })(TOKEN_STATUS || (exports.TOKEN_STATUS = TOKEN_STATUS = {}));
104
- /*
105
- * possible actions by flow
106
- */
107
- // must be same as above
108
- var FLOW_ACTION;
109
- (function (FLOW_ACTION) {
110
- FLOW_ACTION["take"] = "take";
111
- FLOW_ACTION["discard"] = "discard";
112
- })(FLOW_ACTION || (exports.FLOW_ACTION = FLOW_ACTION = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NODE_SUBTYPE = exports.EXECUTION_STATUS = exports.TOKEN_STATUS = exports.ITEM_STATUS = exports.FLOW_ACTION = exports.NODE_ACTION = exports.EXECUTION_EVENT = exports.BPMN_TYPE = void 0;
4
+ var BPMN_TYPE;
5
+ (function (BPMN_TYPE) {
6
+ BPMN_TYPE["UserTask"] = "bpmn:UserTask";
7
+ BPMN_TYPE["ScriptTask"] = "bpmn:ScriptTask";
8
+ BPMN_TYPE["ServiceTask"] = "bpmn:ServiceTask";
9
+ BPMN_TYPE["SendTask"] = "bpmn:SendTask";
10
+ BPMN_TYPE["ReceiveTask"] = "bpmn:ReceiveTask";
11
+ BPMN_TYPE["BusinessRuleTask"] = "bpmn:BusinessRuleTask";
12
+ BPMN_TYPE["SubProcess"] = "bpmn:SubProcess";
13
+ BPMN_TYPE["ParallelGateway"] = "bpmn:ParallelGateway";
14
+ BPMN_TYPE["EventBasedGateway"] = "bpmn:EventBasedGateway";
15
+ BPMN_TYPE["InclusiveGateway"] = "bpmn:InclusiveGateway";
16
+ BPMN_TYPE["ExclusiveGateway"] = "bpmn:ExclusiveGateway";
17
+ BPMN_TYPE["BoundaryEvent"] = "bpmn:BoundaryEvent";
18
+ BPMN_TYPE["StartEvent"] = "bpmn:StartEvent";
19
+ BPMN_TYPE["IntermediateCatchEvent"] = "bpmn:IntermediateCatchEvent";
20
+ BPMN_TYPE["IntermediateThrowEvent"] = "bpmn:IntermediateThrowEvent";
21
+ BPMN_TYPE["EndEvent"] = "bpmn:EndEvent";
22
+ BPMN_TYPE["SequenceFlow"] = "bpmn:SequenceFlow";
23
+ BPMN_TYPE["MessageFlow"] = "bpmn:MessageFlow";
24
+ BPMN_TYPE["CallActivity"] = "bpmn:CallActivity";
25
+ })(BPMN_TYPE || (BPMN_TYPE = {}));
26
+ exports.BPMN_TYPE = BPMN_TYPE;
27
+ var NODE_SUBTYPE;
28
+ (function (NODE_SUBTYPE) {
29
+ NODE_SUBTYPE["timer"] = "timer";
30
+ NODE_SUBTYPE["message"] = "message";
31
+ NODE_SUBTYPE["signal"] = "signal";
32
+ NODE_SUBTYPE["error"] = "error";
33
+ NODE_SUBTYPE["escalation"] = "escalation";
34
+ NODE_SUBTYPE["cancel"] = "cancel";
35
+ NODE_SUBTYPE["compensate"] = "compensate";
36
+ })(NODE_SUBTYPE || (NODE_SUBTYPE = {}));
37
+ exports.NODE_SUBTYPE = NODE_SUBTYPE;
38
+ /*
39
+ * ALL events
40
+ */
41
+ var EXECUTION_EVENT;
42
+ (function (EXECUTION_EVENT) {
43
+ EXECUTION_EVENT["node_enter"] = "enter";
44
+ EXECUTION_EVENT["node_assign"] = "assign";
45
+ EXECUTION_EVENT["node_validate"] = "validate";
46
+ EXECUTION_EVENT["node_start"] = "start";
47
+ EXECUTION_EVENT["node_wait"] = "wait";
48
+ EXECUTION_EVENT["node_end"] = "end";
49
+ EXECUTION_EVENT["node_terminated"] = "terminated";
50
+ EXECUTION_EVENT["transform_input"] = "transformInput";
51
+ EXECUTION_EVENT["transform_output"] = "transformOutput";
52
+ EXECUTION_EVENT["flow_take"] = "take";
53
+ EXECUTION_EVENT["flow_discard"] = "discard";
54
+ EXECUTION_EVENT["process_loaded"] = "process.loaded";
55
+ EXECUTION_EVENT["process_start"] = "process.start";
56
+ EXECUTION_EVENT["process_started"] = "process.started";
57
+ EXECUTION_EVENT["process_invoke"] = "process.invoke";
58
+ EXECUTION_EVENT["process_invoked"] = "process.invoked";
59
+ EXECUTION_EVENT["process_saving"] = "process.saving";
60
+ EXECUTION_EVENT["process_restored"] = "process.restored";
61
+ EXECUTION_EVENT["process_resumed"] = "process_resumed";
62
+ EXECUTION_EVENT["process_wait"] = "process.wait";
63
+ EXECUTION_EVENT["process_end"] = "process.end";
64
+ EXECUTION_EVENT["process_terminated"] = "process.terminated";
65
+ EXECUTION_EVENT["token_start"] = "token.start";
66
+ EXECUTION_EVENT["token_wait"] = "token.wait";
67
+ EXECUTION_EVENT["token_end"] = "token.end";
68
+ EXECUTION_EVENT["token_terminated"] = "token.terminated";
69
+ EXECUTION_EVENT["process_error"] = "process.error";
70
+ })(EXECUTION_EVENT || (EXECUTION_EVENT = {}));
71
+ exports.EXECUTION_EVENT = EXECUTION_EVENT;
72
+ /*
73
+ * possible actions by node
74
+ */
75
+ var NODE_ACTION;
76
+ (function (NODE_ACTION) {
77
+ NODE_ACTION[NODE_ACTION["continue"] = 1] = "continue";
78
+ NODE_ACTION[NODE_ACTION["wait"] = 2] = "wait";
79
+ NODE_ACTION[NODE_ACTION["end"] = 3] = "end";
80
+ NODE_ACTION[NODE_ACTION["cancel"] = 4] = "cancel";
81
+ NODE_ACTION[NODE_ACTION["stop"] = 5] = "stop";
82
+ NODE_ACTION[NODE_ACTION["error"] = 6] = "error";
83
+ NODE_ACTION[NODE_ACTION["abort"] = 7] = "abort";
84
+ })(NODE_ACTION || (NODE_ACTION = {}));
85
+ exports.NODE_ACTION = NODE_ACTION;
86
+ ;
87
+ var ITEM_STATUS;
88
+ (function (ITEM_STATUS) {
89
+ ITEM_STATUS["enter"] = "enter";
90
+ ITEM_STATUS["start"] = "start";
91
+ ITEM_STATUS["wait"] = "wait";
92
+ ITEM_STATUS["end"] = "end";
93
+ ITEM_STATUS["terminated"] = "terminated";
94
+ ITEM_STATUS["cancelled"] = "cancelled";
95
+ ITEM_STATUS["discard"] = "discard";
96
+ })(ITEM_STATUS || (ITEM_STATUS = {}));
97
+ exports.ITEM_STATUS = ITEM_STATUS;
98
+ //type ITEMSTATUS = 'enter' | 'start' | 'wait' | 'end' | 'terminated' | 'discard';
99
+ var EXECUTION_STATUS;
100
+ (function (EXECUTION_STATUS) {
101
+ EXECUTION_STATUS["running"] = "running";
102
+ EXECUTION_STATUS["wait"] = "wait";
103
+ EXECUTION_STATUS["end"] = "end";
104
+ EXECUTION_STATUS["terminated"] = "terminated";
105
+ })(EXECUTION_STATUS || (EXECUTION_STATUS = {}));
106
+ exports.EXECUTION_STATUS = EXECUTION_STATUS;
107
+ var TOKEN_STATUS;
108
+ (function (TOKEN_STATUS) {
109
+ TOKEN_STATUS["running"] = "running";
110
+ TOKEN_STATUS["wait"] = "wait";
111
+ TOKEN_STATUS["end"] = "end";
112
+ TOKEN_STATUS["terminated"] = "terminated";
113
+ })(TOKEN_STATUS || (TOKEN_STATUS = {}));
114
+ exports.TOKEN_STATUS = TOKEN_STATUS;
115
+ /*
116
+ * possible actions by flow
117
+ */
118
+ // must be same as above
119
+ var FLOW_ACTION;
120
+ (function (FLOW_ACTION) {
121
+ FLOW_ACTION["take"] = "take";
122
+ FLOW_ACTION["discard"] = "discard";
123
+ })(FLOW_ACTION || (FLOW_ACTION = {}));
124
+ exports.FLOW_ACTION = FLOW_ACTION;
@@ -1,137 +1,137 @@
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
- //FromPostMan();
13
- //request('test4', 'Trans.bpmn');
14
- const _1 = require("./");
15
- console.log('remote-import.ts');
16
- //badImport();
17
- fromClientLib();
18
- console.log('-------------------');
19
- //FromPostMan();
20
- /*
21
- process.on('uncaughtException', function (err) {
22
- console.log('*******************Client ERROR***********');
23
- console.error(err.stack);
24
- throw err;
25
- });
26
- */
27
- function badImport() {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const path = require('path');
30
- try {
31
- const bpmnServer = new _1.BPMNClient('127.0.0.1', 3000, 12345);
32
- const importResult = yield bpmnServer.definitions.import('dummyTest', path.resolve('test.js'));
33
- console.log('badImport done');
34
- return 'done';
35
- }
36
- catch (err) {
37
- console.log('badImport Error', err);
38
- }
39
- });
40
- }
41
- function fromClientLib() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- console.log('from client lib');
44
- try {
45
- // const server = new BPMNClient('localhost', 3000, '12345');
46
- const dotenv = require('dotenv');
47
- dotenv.config();
48
- console.log('env:', process.env.HOST, process.env.PORT, process.env.API_KEY);
49
- const server = new _1.BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
50
- var name = 'test-import';
51
- var file = '..\\WebApp\\processes\\Trans.bpmn';
52
- var file2 = '..\\WebApp\\processes\\Trans.svg';
53
- var res = yield server.definitions.import(name, file, file2);
54
- return res;
55
- }
56
- catch (exc) {
57
- console.log('*******ERROR********');
58
- console.log(exc);
59
- }
60
- });
61
- }
62
- function FromPostMan() {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- console.log("Testing Remote import");
65
- var file = 'E:\\x4\\dev\\webApp\\processes\\Trans.bpmn';
66
- var http = require('follow-redirects').http;
67
- //const http = require('http');
68
- var fs = require('fs');
69
- var options = {
70
- 'method': 'POST',
71
- 'hostname': 'localhost',
72
- 'port': 3000,
73
- 'path': '/api/definitions/import/testing4',
74
- 'headers': {
75
- 'x-api-key': '12345',
76
- 'Cookie': 'connect.sid=s%3AXMa01DuOlQ4WsrvBj0FVaIrTak49vLPB.hDIV9j7ONA437rZf%2F%2Biu%2Bc6B7T5%2FVuEIjj1BAaoCJW4'
77
- },
78
- 'maxRedirects': 20
79
- };
80
- var req = http.request(options, function (res) {
81
- var chunks = [];
82
- res.on("data", function (chunk) {
83
- chunks.push(chunk);
84
- });
85
- res.on("end", function (chunk) {
86
- var body = Buffer.concat(chunks);
87
- console.log(body.toString());
88
- });
89
- res.on("error", function (error) {
90
- console.error(error);
91
- });
92
- });
93
- var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"Trans.bpmn\"\r\nContent-Type: \"text/plain\"\r\n\r\n" + fs.readFileSync(file) + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
94
- req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
95
- req.write(postData);
96
- req.end();
97
- return req;
98
- });
99
- }
100
- function request(name, path) {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- console.log("Testing Request");
103
- var http = require('http');
104
- var fs = require('fs');
105
- var options = {
106
- 'method': 'POST',
107
- 'hostname': 'localhost',
108
- 'port': 3000,
109
- 'path': '/api/definitions/import/' + name,
110
- 'headers': {
111
- 'x-api-key': '12345',
112
- 'Cookie': 'connect.sid=s%3AXMa01DuOlQ4WsrvBj0FVaIrTak49vLPB.hDIV9j7ONA437rZf%2F%2Biu%2Bc6B7T5%2FVuEIjj1BAaoCJW4'
113
- },
114
- 'maxRedirects': 20
115
- };
116
- var req = http.request(options, function (res) {
117
- var chunks = [];
118
- res.on("data", function (chunk) {
119
- chunks.push(chunk);
120
- });
121
- res.on("end", function (chunk) {
122
- var body = Buffer.concat(chunks);
123
- console.log(body.toString());
124
- });
125
- res.on("error", function (error) {
126
- console.error(error);
127
- });
128
- });
129
- var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\""
130
- + path + "\"\r\nContent-Type: \"text/plain\"\r\n\r\n" +
131
- fs.readFileSync(path) + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
132
- req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
133
- req.write(postData);
134
- req.end();
135
- console.log('end');
136
- });
137
- }
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
+ //FromPostMan();
13
+ //request('test4', 'Trans.bpmn');
14
+ const _1 = require("./");
15
+ console.log('remote-import.ts');
16
+ //badImport();
17
+ fromClientLib();
18
+ console.log('-------------------');
19
+ //FromPostMan();
20
+ /*
21
+ process.on('uncaughtException', function (err) {
22
+ console.log('*******************Client ERROR***********');
23
+ console.error(err.stack);
24
+ throw err;
25
+ });
26
+ */
27
+ function badImport() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const path = require('path');
30
+ try {
31
+ const bpmnServer = new _1.BPMNClient('127.0.0.1', 3000, 12345);
32
+ const importResult = yield bpmnServer.definitions.import('dummyTest', path.resolve('test.js'));
33
+ console.log('badImport done');
34
+ return 'done';
35
+ }
36
+ catch (err) {
37
+ console.log('badImport Error', err);
38
+ }
39
+ });
40
+ }
41
+ function fromClientLib() {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ console.log('from client lib');
44
+ try {
45
+ // const server = new BPMNClient('localhost', 3000, '12345');
46
+ const dotenv = require('dotenv');
47
+ dotenv.config();
48
+ console.log('env:', process.env.HOST, process.env.PORT, process.env.API_KEY);
49
+ const server = new _1.BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
50
+ var name = 'test-import';
51
+ var file = '..\\WebApp\\processes\\Trans.bpmn';
52
+ var file2 = '..\\WebApp\\processes\\Trans.svg';
53
+ var res = yield server.definitions.import(name, file, file2);
54
+ return res;
55
+ }
56
+ catch (exc) {
57
+ console.log('*******ERROR********');
58
+ console.log(exc);
59
+ }
60
+ });
61
+ }
62
+ function FromPostMan() {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ console.log("Testing Remote import");
65
+ var file = 'E:\\x4\\dev\\webApp\\processes\\Trans.bpmn';
66
+ var http = require('follow-redirects').http;
67
+ //const http = require('http');
68
+ var fs = require('fs');
69
+ var options = {
70
+ 'method': 'POST',
71
+ 'hostname': 'localhost',
72
+ 'port': 3000,
73
+ 'path': '/api/definitions/import/testing4',
74
+ 'headers': {
75
+ 'x-api-key': '12345',
76
+ 'Cookie': 'connect.sid=s%3AXMa01DuOlQ4WsrvBj0FVaIrTak49vLPB.hDIV9j7ONA437rZf%2F%2Biu%2Bc6B7T5%2FVuEIjj1BAaoCJW4'
77
+ },
78
+ 'maxRedirects': 20
79
+ };
80
+ var req = http.request(options, function (res) {
81
+ var chunks = [];
82
+ res.on("data", function (chunk) {
83
+ chunks.push(chunk);
84
+ });
85
+ res.on("end", function (chunk) {
86
+ var body = Buffer.concat(chunks);
87
+ console.log(body.toString());
88
+ });
89
+ res.on("error", function (error) {
90
+ console.error(error);
91
+ });
92
+ });
93
+ var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"Trans.bpmn\"\r\nContent-Type: \"text/plain\"\r\n\r\n" + fs.readFileSync(file) + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
94
+ req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
95
+ req.write(postData);
96
+ req.end();
97
+ return req;
98
+ });
99
+ }
100
+ function request(name, path) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ console.log("Testing Request");
103
+ var http = require('http');
104
+ var fs = require('fs');
105
+ var options = {
106
+ 'method': 'POST',
107
+ 'hostname': 'localhost',
108
+ 'port': 3000,
109
+ 'path': '/api/definitions/import/' + name,
110
+ 'headers': {
111
+ 'x-api-key': '12345',
112
+ 'Cookie': 'connect.sid=s%3AXMa01DuOlQ4WsrvBj0FVaIrTak49vLPB.hDIV9j7ONA437rZf%2F%2Biu%2Bc6B7T5%2FVuEIjj1BAaoCJW4'
113
+ },
114
+ 'maxRedirects': 20
115
+ };
116
+ var req = http.request(options, function (res) {
117
+ var chunks = [];
118
+ res.on("data", function (chunk) {
119
+ chunks.push(chunk);
120
+ });
121
+ res.on("end", function (chunk) {
122
+ var body = Buffer.concat(chunks);
123
+ console.log(body.toString());
124
+ });
125
+ res.on("error", function (error) {
126
+ console.error(error);
127
+ });
128
+ });
129
+ var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\""
130
+ + path + "\"\r\nContent-Type: \"text/plain\"\r\n\r\n" +
131
+ fs.readFileSync(path) + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
132
+ req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
133
+ req.write(postData);
134
+ req.end();
135
+ console.log('end');
136
+ });
137
+ }
package/dist/setup.js ADDED
@@ -0,0 +1,22 @@
1
+ const fs = require('fs');
2
+ const readline = require("readline");
3
+ const cl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false });
4
+ const question = function (q) {
5
+ return new Promise((res, rej) => {
6
+ cl.question(q, answer => {
7
+ res(answer);
8
+ });
9
+ });
10
+ };
11
+ console.log('This routine will create .env file');
12
+ const cwd = process.cwd();
13
+ createEnv();
14
+ function createEnv() {
15
+ if (!fs.existsSync('.env')) {
16
+ fs.appendFileSync('.env', "API_KEY = 12345 \nHOST = localhost\nPORT = 3000\nBASE_URL = api");
17
+ console.log(`file ".env" created.`);
18
+ }
19
+ else
20
+ console.log('.env file already exists.');
21
+ process.exit();
22
+ }