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.
- package/README.md +32 -0
- package/bin/cli.js +245 -0
- package/bin/setup.js +24 -0
- package/{src → dist}/BPMNClient.js +285 -273
- package/dist/BPMNClient2.js +252 -0
- package/{src → dist}/WebService.js +82 -82
- package/{cli.js → dist/cli.js} +243 -242
- package/{src → dist}/index.js +16 -19
- package/{src/interfaces/BPMNClient.js → dist/interfaces/API.js} +2 -2
- package/{src → dist}/interfaces/DataObjects.js +2 -2
- package/{src → dist}/interfaces/Enums.js +124 -112
- package/{remote-import.js → dist/remote-import.js} +137 -137
- package/dist/setup.js +22 -0
- package/{test-raw.js → dist/test-raw.js} +73 -74
- package/dist/test.js +75 -0
- package/dist/test2.js +78 -0
- package/{test3.js → dist/test3.js} +42 -42
- package/package.json +11 -2
- package/.env +0 -4
- package/Sample/.env +0 -4
- package/Sample/CarExample.js +0 -62
- package/Sample/CarExample.ts +0 -97
- package/Sample/package.json +0 -44
- package/Sample/test.js +0 -33
- package/Sample/test.ts +0 -32
- package/Sample/tsconfig.json +0 -17
- package/cli.ts +0 -268
- package/demo.env +0 -4
- package/index.js +0 -17
- package/index.ts +0 -1
- package/local.env +0 -4
- package/monitor.js +0 -91
- package/monitor.ts +0 -100
- package/remote-import.ts +0 -167
- package/src/BPMNClient.ts +0 -265
- package/src/WebService.ts +0 -90
- package/src/index.ts +0 -4
- package/src/interfaces/BPMNClient.ts +0 -29
- package/src/interfaces/DataObjects.ts +0 -100
- package/src/interfaces/Enums.ts +0 -82
- package/test/.eslintrc.json +0 -20
- package/test/.mocharc.json +0 -12
- package/test/feature/.env +0 -4
- package/test/feature/car.js +0 -123
- package/test/feature/carServer.js +0 -123
- package/test/helpers/setup.js +0 -9
- package/test/logs/Buy Used Carrepairsfalse cleaning +0 -0
- package/test/logs/Buy Used Carrepairstrue cleaning +0 -0
- package/test/logs/Buy Used Carscenario CaseId +0 -0
- package/test/logs/carrepairsfalse cleaning +0 -0
- package/test/logs/carrepairstrue cleaning +0 -0
- package/test-raw.ts +0 -73
- package/test.env +0 -4
- package/test.js +0 -258
- package/test.ts +0 -339
- package/test3.ts +0 -40
- package/tsconfig.json +0 -17
- /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 || (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
NODE_SUBTYPE["
|
|
30
|
-
NODE_SUBTYPE["
|
|
31
|
-
NODE_SUBTYPE["
|
|
32
|
-
NODE_SUBTYPE["
|
|
33
|
-
NODE_SUBTYPE["
|
|
34
|
-
NODE_SUBTYPE["
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
EXECUTION_EVENT["
|
|
44
|
-
EXECUTION_EVENT["
|
|
45
|
-
EXECUTION_EVENT["
|
|
46
|
-
EXECUTION_EVENT["
|
|
47
|
-
EXECUTION_EVENT["
|
|
48
|
-
EXECUTION_EVENT["
|
|
49
|
-
EXECUTION_EVENT["
|
|
50
|
-
EXECUTION_EVENT["
|
|
51
|
-
EXECUTION_EVENT["
|
|
52
|
-
EXECUTION_EVENT["
|
|
53
|
-
EXECUTION_EVENT["
|
|
54
|
-
EXECUTION_EVENT["
|
|
55
|
-
EXECUTION_EVENT["
|
|
56
|
-
EXECUTION_EVENT["
|
|
57
|
-
EXECUTION_EVENT["
|
|
58
|
-
EXECUTION_EVENT["
|
|
59
|
-
EXECUTION_EVENT["
|
|
60
|
-
EXECUTION_EVENT["
|
|
61
|
-
EXECUTION_EVENT["
|
|
62
|
-
EXECUTION_EVENT["
|
|
63
|
-
EXECUTION_EVENT["
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
})(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
}
|