bpmn-client 1.3.17 → 1.3.23
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/.env +2 -2
- package/Sample/package.json +1 -1
- package/cli.js +242 -243
- package/index.js +17 -13
- package/monitor.js +91 -91
- package/package.json +2 -2
- package/remote-import.js +132 -105
- package/remote-import.ts +37 -3
- package/src/BPMNClient.js +262 -358
- package/src/BPMNClient.ts +22 -143
- package/src/WebService.js +78 -0
- package/src/WebService.ts +85 -0
- package/src/index.js +19 -15
- package/src/interfaces/DataObjects.js +2 -2
- package/src/interfaces/DataObjects.ts +2 -0
- package/src/interfaces/Enums.js +112 -120
- package/test-raw.js +74 -74
- package/test.js +257 -190
- package/test.ts +92 -3
- package/test3.js +42 -42
package/test-raw.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
console.log("Testing BPMNClient raw");
|
|
11
|
-
raw1();
|
|
12
|
-
function raw1() {
|
|
13
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
var axios = require('axios');
|
|
15
|
-
var data = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
|
|
16
|
-
var config = {
|
|
17
|
-
method: 'get',
|
|
18
|
-
url: 'http://localhost:3000/api/datastore/findItems',
|
|
19
|
-
headers: {
|
|
20
|
-
'x-api-key': '12345',
|
|
21
|
-
'Content-Type': 'application/json',
|
|
22
|
-
// 'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
|
|
23
|
-
},
|
|
24
|
-
data: data
|
|
25
|
-
};
|
|
26
|
-
var response = yield axios(config);
|
|
27
|
-
console.log(response.data);
|
|
28
|
-
/*
|
|
29
|
-
axios(config)
|
|
30
|
-
.then(function (response) {
|
|
31
|
-
console.log('then',JSON.stringify(response.data));
|
|
32
|
-
})
|
|
33
|
-
.catch(function (error) {
|
|
34
|
-
console.log('error',error);
|
|
35
|
-
});
|
|
36
|
-
*/
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function raw() {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
console.log('raw');
|
|
42
|
-
var https = require('follow-redirects').http;
|
|
43
|
-
var fs = require('fs');
|
|
44
|
-
var options = {
|
|
45
|
-
'method': 'GET',
|
|
46
|
-
'hostname': 'localhost',
|
|
47
|
-
'port': 3000,
|
|
48
|
-
'path': '/api/datastore/findItems',
|
|
49
|
-
'headers': {
|
|
50
|
-
'x-api-key': '12345',
|
|
51
|
-
'Content-Type': 'application/json',
|
|
52
|
-
'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
|
|
53
|
-
},
|
|
54
|
-
'maxRedirects': 20
|
|
55
|
-
};
|
|
56
|
-
var req = https.request(options, function (res) {
|
|
57
|
-
var chunks = [];
|
|
58
|
-
res.on("data", function (chunk) {
|
|
59
|
-
console.log('data', chunk);
|
|
60
|
-
chunks.push(chunk);
|
|
61
|
-
});
|
|
62
|
-
res.on("end", function (chunk) {
|
|
63
|
-
var body = Buffer.concat(chunks);
|
|
64
|
-
console.log('end', body.toString());
|
|
65
|
-
});
|
|
66
|
-
res.on("error", function (error) {
|
|
67
|
-
console.error(error);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
var postData = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
|
|
71
|
-
req.write(postData);
|
|
72
|
-
req.end();
|
|
73
|
-
});
|
|
74
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
console.log("Testing BPMNClient raw");
|
|
11
|
+
raw1();
|
|
12
|
+
function raw1() {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
var axios = require('axios');
|
|
15
|
+
var data = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
|
|
16
|
+
var config = {
|
|
17
|
+
method: 'get',
|
|
18
|
+
url: 'http://localhost:3000/api/datastore/findItems',
|
|
19
|
+
headers: {
|
|
20
|
+
'x-api-key': '12345',
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
// 'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
|
|
23
|
+
},
|
|
24
|
+
data: data
|
|
25
|
+
};
|
|
26
|
+
var response = yield axios(config);
|
|
27
|
+
console.log(response.data);
|
|
28
|
+
/*
|
|
29
|
+
axios(config)
|
|
30
|
+
.then(function (response) {
|
|
31
|
+
console.log('then',JSON.stringify(response.data));
|
|
32
|
+
})
|
|
33
|
+
.catch(function (error) {
|
|
34
|
+
console.log('error',error);
|
|
35
|
+
});
|
|
36
|
+
*/
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function raw() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
console.log('raw');
|
|
42
|
+
var https = require('follow-redirects').http;
|
|
43
|
+
var fs = require('fs');
|
|
44
|
+
var options = {
|
|
45
|
+
'method': 'GET',
|
|
46
|
+
'hostname': 'localhost',
|
|
47
|
+
'port': 3000,
|
|
48
|
+
'path': '/api/datastore/findItems',
|
|
49
|
+
'headers': {
|
|
50
|
+
'x-api-key': '12345',
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
|
|
53
|
+
},
|
|
54
|
+
'maxRedirects': 20
|
|
55
|
+
};
|
|
56
|
+
var req = https.request(options, function (res) {
|
|
57
|
+
var chunks = [];
|
|
58
|
+
res.on("data", function (chunk) {
|
|
59
|
+
console.log('data', chunk);
|
|
60
|
+
chunks.push(chunk);
|
|
61
|
+
});
|
|
62
|
+
res.on("end", function (chunk) {
|
|
63
|
+
var body = Buffer.concat(chunks);
|
|
64
|
+
console.log('end', body.toString());
|
|
65
|
+
});
|
|
66
|
+
res.on("error", function (error) {
|
|
67
|
+
console.error(error);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
var postData = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
|
|
71
|
+
req.write(postData);
|
|
72
|
+
req.end();
|
|
73
|
+
});
|
|
74
|
+
}
|
package/test.js
CHANGED
|
@@ -1,191 +1,258 @@
|
|
|
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
|
-
const _1 = require("./");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
'
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
+
const _1 = require("./");
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const axios = require('axios');
|
|
15
|
+
const FormData = require('form-data');
|
|
16
|
+
uploadFile('Trans.bpmn');
|
|
17
|
+
//-----------------------------------
|
|
18
|
+
function uploadFile(file) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var axios = require('axios');
|
|
21
|
+
const fileContents = fs.createReadStream(file);
|
|
22
|
+
const title = 'My file';
|
|
23
|
+
const form = new FormData();
|
|
24
|
+
form.append('title', 'title');
|
|
25
|
+
form.append('file', fileContents);
|
|
26
|
+
console.log(1);
|
|
27
|
+
var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\""
|
|
28
|
+
+ file + "\"\r\nContent-Type: \"text/plain\"\r\n\r\n" +
|
|
29
|
+
fs.readFileSync(file) + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
|
|
30
|
+
// formData.append(postData);
|
|
31
|
+
try {
|
|
32
|
+
console.log(2, form);
|
|
33
|
+
const response = yield axios.post('http://localhost:3000/api/definitions/import/test1', form, {
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "multipart/form-data",
|
|
36
|
+
"x-api-key": "12345",
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
console.log(3);
|
|
40
|
+
console.log('Response Status:', response.status, response.data);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.log('ERROR------------');
|
|
44
|
+
if (error.response) { // get response with a status code not in range 2xx
|
|
45
|
+
console.log(error.response.data);
|
|
46
|
+
console.log(error.response.status);
|
|
47
|
+
console.log(error.response.headers);
|
|
48
|
+
}
|
|
49
|
+
else if (error.request) { // no response
|
|
50
|
+
console.log(error.request);
|
|
51
|
+
}
|
|
52
|
+
else { // Something wrong in setting up the request
|
|
53
|
+
console.log('Error', error.message);
|
|
54
|
+
}
|
|
55
|
+
console.log(error.config);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const readline = require("readline");
|
|
60
|
+
const cl = readline.createInterface(process.stdin, process.stdout);
|
|
61
|
+
const question = function (q) {
|
|
62
|
+
return new Promise((res, rej) => {
|
|
63
|
+
cl.question(q, answer => {
|
|
64
|
+
res(answer);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
//fun1();
|
|
69
|
+
function fun1() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
yield fun2();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function fun2() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
try {
|
|
77
|
+
yield fun3();
|
|
78
|
+
}
|
|
79
|
+
catch (exc) {
|
|
80
|
+
console.log('error caught but not handled');
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function fun3() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
throw new Error('fun3');
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
console.log("Testing BPMNClient");
|
|
90
|
+
const dotenv = require('dotenv');
|
|
91
|
+
const res = dotenv.config();
|
|
92
|
+
console.log(res.parsed.PORT);
|
|
93
|
+
//raw();
|
|
94
|
+
const server = new _1.BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
|
|
95
|
+
//testMessage();
|
|
96
|
+
// testImport();
|
|
97
|
+
/*
|
|
98
|
+
test1();
|
|
99
|
+
end();
|
|
100
|
+
*/
|
|
101
|
+
function raw() {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
var https = require('follow-redirects').https;
|
|
104
|
+
var fs = require('fs');
|
|
105
|
+
var options = {
|
|
106
|
+
'method': 'GET',
|
|
107
|
+
'hostname': 'localhost',
|
|
108
|
+
'port': 3000,
|
|
109
|
+
'path': '/api/datastore/findItems',
|
|
110
|
+
'headers': {
|
|
111
|
+
'x-api-key': '12345',
|
|
112
|
+
'Content-Type': 'application/json',
|
|
113
|
+
'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
|
|
114
|
+
},
|
|
115
|
+
'maxRedirects': 20
|
|
116
|
+
};
|
|
117
|
+
var req = https.request(options, function (res) {
|
|
118
|
+
var chunks = [];
|
|
119
|
+
res.on("data", function (chunk) {
|
|
120
|
+
chunks.push(chunk);
|
|
121
|
+
});
|
|
122
|
+
res.on("end", function (chunk) {
|
|
123
|
+
var body = Buffer.concat(chunks);
|
|
124
|
+
console.log(body.toString());
|
|
125
|
+
});
|
|
126
|
+
res.on("error", function (error) {
|
|
127
|
+
console.error(error);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
var postData = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
|
|
131
|
+
req.write(postData);
|
|
132
|
+
req.end();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function end() {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
yield question("continue");
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function test1() {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
var items = yield server.definitions.list();
|
|
143
|
+
items.forEach(item => {
|
|
144
|
+
// console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function testImport() {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
var file = 'test-import';
|
|
151
|
+
var path = '../webApp/processes/Trans.bpmn';
|
|
152
|
+
var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data;filename=\"" + path + "\"\r\nContent-Type: \"text/plain\"\r\n\r\n" + fs.readFileSync(file) + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
|
|
153
|
+
console.log(postData);
|
|
154
|
+
// var res = await upload('definitions/import/' + name, postData);
|
|
155
|
+
if (res['errors']) {
|
|
156
|
+
console.log(res['errors']);
|
|
157
|
+
throw new Error(res['errors']);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function testImport2() {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
console.log('calling');
|
|
164
|
+
var file = '../webApp/processes/Trans.bpmn';
|
|
165
|
+
let response = yield server.definitions.import('testing_123', file);
|
|
166
|
+
console.log(response);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function displayInstance(instanceId) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
let insts = yield server.datastore.findInstances({ id: instanceId });
|
|
172
|
+
for (var i = 0; i < insts.length; i++) {
|
|
173
|
+
let inst = insts[i];
|
|
174
|
+
var items = inst.items;
|
|
108
175
|
console.log(`name: ${inst.name} status: ${inst.status} instanceId: ${inst.id}
|
|
109
|
-
startedAt: ${inst.startedAt} endedAt ${inst.endedAt}`, 'data:', inst.data);
|
|
110
|
-
for (var j = 0; j < items.length; j++) {
|
|
111
|
-
let item = items[j];
|
|
112
|
-
console.log(`element: ${item.elementId} status: ${item.status} id: ${item.id}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function testMessage() {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
const messageId = 'Message-104';
|
|
120
|
-
let messageData = {};
|
|
121
|
-
console.log('calling');
|
|
122
|
-
let response = yield server.engine.throwMessage(messageId, messageData);
|
|
123
|
-
if (response['id'])
|
|
124
|
-
return yield displayInstance(response['id']);
|
|
125
|
-
else
|
|
126
|
-
return null;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function test() {
|
|
130
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
const server = new _1.BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
|
|
132
|
-
const caseId = 3040;
|
|
133
|
-
var delResp = yield server.datastore.deleteInstances({ name: 'Buy Used Car' });
|
|
134
|
-
//console.log(delResp);
|
|
135
|
-
//return;
|
|
136
|
-
var defs = yield server.definitions.list();
|
|
137
|
-
console.log(defs);
|
|
138
|
-
var def = yield server.definitions.load('Buy Used Car');
|
|
139
|
-
console.log(def['elements']);
|
|
140
|
-
//var instance = await server.engine.start("Buy Used Car", {});
|
|
141
|
-
var instance = yield server.engine.start("Buy Used Car", { caseId: caseId });
|
|
142
|
-
console.log("instance.id", instance.id, instance.name, instance.status, instance.data.caseId);
|
|
143
|
-
var response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_Buy' }, { needsCleaning: "Yes", needsRepairs: "Yes" });
|
|
144
|
-
console.log('after buy', response.id, response.data);
|
|
145
|
-
response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_clean' }, {});
|
|
146
|
-
console.log('after clean', response.id, response.data);
|
|
147
|
-
response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_repair' }, {});
|
|
148
|
-
console.log('after repair', response.id, response.data);
|
|
149
|
-
try {
|
|
150
|
-
response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_Drive' }, {});
|
|
151
|
-
console.log('after drive', response.id, response.data);
|
|
152
|
-
}
|
|
153
|
-
catch (exc) {
|
|
154
|
-
console.log(exc);
|
|
155
|
-
}
|
|
156
|
-
var items = yield server.datastore.findItems({ "items.status": "end", "items.elementId": "task_Buy" });
|
|
157
|
-
items.forEach(item => {
|
|
158
|
-
console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
|
|
159
|
-
});
|
|
160
|
-
var insts = yield server.datastore.findInstances({ data: { caseId: caseId } });
|
|
161
|
-
insts.forEach(inst => {
|
|
162
|
-
console.log('Inst for CaseId id==>' + inst.id, inst.name, inst.data.caseId, 'status==>', inst.status);
|
|
163
|
-
});
|
|
164
|
-
var insts = yield server.datastore.findInstances({ id: instance.id });
|
|
165
|
-
insts.forEach(inst => {
|
|
166
|
-
for (var i = 0; i < inst.items.length; i++) {
|
|
167
|
-
var item = inst.items[i];
|
|
168
|
-
console.log(' item: elementId==>' + item.elementId, item.name, 'status==>', item.status);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
var inst = yield server.engine.get({ id: instance.id });
|
|
172
|
-
for (var i = 0; i < inst.items.length; i++) {
|
|
173
|
-
var item = inst.items[i];
|
|
174
|
-
console.log(' item: elementId==>' + item.elementId, item.name, 'status==>', item.status);
|
|
175
|
-
}
|
|
176
|
-
// var items = await server.datastore.findItems({ query: { "items.elementId": "task_Buy" } });
|
|
177
|
-
var items = yield server.datastore.findItems({ id: instance.id });
|
|
178
|
-
items.forEach(item => {
|
|
179
|
-
console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
function delay(time, result) {
|
|
184
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
return new Promise(function (resolve) {
|
|
186
|
-
setTimeout(function () {
|
|
187
|
-
resolve(result);
|
|
188
|
-
}, time);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
176
|
+
startedAt: ${inst.startedAt} endedAt ${inst.endedAt}`, 'data:', inst.data);
|
|
177
|
+
for (var j = 0; j < items.length; j++) {
|
|
178
|
+
let item = items[j];
|
|
179
|
+
console.log(`element: ${item.elementId} status: ${item.status} id: ${item.id}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function testMessage() {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
const messageId = 'Message-104';
|
|
187
|
+
let messageData = {};
|
|
188
|
+
console.log('calling');
|
|
189
|
+
let response = yield server.engine.throwMessage(messageId, messageData);
|
|
190
|
+
if (response['id'])
|
|
191
|
+
return yield displayInstance(response['id']);
|
|
192
|
+
else
|
|
193
|
+
return null;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function test() {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
const server = new _1.BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
|
|
199
|
+
const caseId = 3040;
|
|
200
|
+
var delResp = yield server.datastore.deleteInstances({ name: 'Buy Used Car' });
|
|
201
|
+
//console.log(delResp);
|
|
202
|
+
//return;
|
|
203
|
+
var defs = yield server.definitions.list();
|
|
204
|
+
console.log(defs);
|
|
205
|
+
var def = yield server.definitions.load('Buy Used Car');
|
|
206
|
+
console.log(def['elements']);
|
|
207
|
+
//var instance = await server.engine.start("Buy Used Car", {});
|
|
208
|
+
var instance = yield server.engine.start("Buy Used Car", { caseId: caseId });
|
|
209
|
+
console.log("instance.id", instance.id, instance.name, instance.status, instance.data.caseId);
|
|
210
|
+
var response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_Buy' }, { needsCleaning: "Yes", needsRepairs: "Yes" });
|
|
211
|
+
console.log('after buy', response.id, response.data);
|
|
212
|
+
response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_clean' }, {});
|
|
213
|
+
console.log('after clean', response.id, response.data);
|
|
214
|
+
response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_repair' }, {});
|
|
215
|
+
console.log('after repair', response.id, response.data);
|
|
216
|
+
try {
|
|
217
|
+
response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_Drive' }, {});
|
|
218
|
+
console.log('after drive', response.id, response.data);
|
|
219
|
+
}
|
|
220
|
+
catch (exc) {
|
|
221
|
+
console.log(exc);
|
|
222
|
+
}
|
|
223
|
+
var items = yield server.datastore.findItems({ "items.status": "end", "items.elementId": "task_Buy" });
|
|
224
|
+
items.forEach(item => {
|
|
225
|
+
console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
|
|
226
|
+
});
|
|
227
|
+
var insts = yield server.datastore.findInstances({ data: { caseId: caseId } });
|
|
228
|
+
insts.forEach(inst => {
|
|
229
|
+
console.log('Inst for CaseId id==>' + inst.id, inst.name, inst.data.caseId, 'status==>', inst.status);
|
|
230
|
+
});
|
|
231
|
+
var insts = yield server.datastore.findInstances({ id: instance.id });
|
|
232
|
+
insts.forEach(inst => {
|
|
233
|
+
for (var i = 0; i < inst.items.length; i++) {
|
|
234
|
+
var item = inst.items[i];
|
|
235
|
+
console.log(' item: elementId==>' + item.elementId, item.name, 'status==>', item.status);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
var inst = yield server.engine.get({ id: instance.id });
|
|
239
|
+
for (var i = 0; i < inst.items.length; i++) {
|
|
240
|
+
var item = inst.items[i];
|
|
241
|
+
console.log(' item: elementId==>' + item.elementId, item.name, 'status==>', item.status);
|
|
242
|
+
}
|
|
243
|
+
// var items = await server.datastore.findItems({ query: { "items.elementId": "task_Buy" } });
|
|
244
|
+
var items = yield server.datastore.findItems({ id: instance.id });
|
|
245
|
+
items.forEach(item => {
|
|
246
|
+
console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function delay(time, result) {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
+
return new Promise(function (resolve) {
|
|
253
|
+
setTimeout(function () {
|
|
254
|
+
resolve(result);
|
|
255
|
+
}, time);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|