bpmn-client 1.3.16 → 1.3.17

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 CHANGED
@@ -1,4 +1,4 @@
1
1
  API_KEY=12345
2
- HOST=localhost
3
- PORT=3000
2
+ HOST=test.omniworkflow.com
3
+ PORT=443
4
4
  BASE_URL=api
package/cli.js CHANGED
@@ -14,6 +14,7 @@ const _1 = require("./");
14
14
  const readline = require("readline");
15
15
  const dotenv = require('dotenv');
16
16
  const res = dotenv.config();
17
+ console.log(res);
17
18
  const server = new _1.BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
18
19
  const cl = readline.createInterface(process.stdin, process.stdout);
19
20
  const question = function (q) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-client",
3
- "version": "1.3.16",
3
+ "version": "1.3.17",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "tsc --build",
@@ -26,10 +26,10 @@
26
26
  "url": "git+https:github.com/ralphhanna/bpmn-client.git"
27
27
  },
28
28
  "dependencies": {
29
+ "axios": "^1.3.4",
29
30
  "connect-busboy": "0.0.2",
30
31
  "core-js": "^3.6.5",
31
- "dotenv": "^16.0.1",
32
- "follow-redirects": "^1.15.2"
32
+ "dotenv": "^16.0.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/mime": "^1.3.1",
package/src/BPMNClient.js CHANGED
@@ -17,10 +17,30 @@ const fs = require("fs");
17
17
  class WebService {
18
18
  constructor() { }
19
19
  invoke(params, options, postData = null) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ var axios = require('axios');
22
+ var data = JSON.stringify(params);
23
+ var url = 'http://' + options.host + ':' + options.port + options.path;
24
+ if (options.port == 443)
25
+ url = 'https://' + options.host + options.path;
26
+ var config = {
27
+ method: options.method,
28
+ url: url,
29
+ headers: options.headers,
30
+ data: data
31
+ };
32
+ let self = this;
33
+ let response = yield axios(config);
34
+ self.result = response.data;
35
+ return response.data;
36
+ });
37
+ }
38
+ invokeOld(params, options, postData = null) {
20
39
  return __awaiter(this, void 0, void 0, function* () {
21
40
  var driver = http;
22
41
  var body = JSON.stringify(params);
23
- // console.log(options, params);
42
+ console.log('invoke:');
43
+ console.log('options:', options, params);
24
44
  if (options.port == 443)
25
45
  driver = https;
26
46
  let data = '';
@@ -28,16 +48,21 @@ class WebService {
28
48
  return new Promise(function (resolve, reject) {
29
49
  try {
30
50
  var req = driver.request(options, function (res) {
31
- // console.log('STATUS: ' + res.statusCode);
51
+ console.log('STATUS: ' + res.statusCode);
32
52
  this.response = res;
33
53
  //console.log(res);
34
54
  self.statusCode = res.statusCode;
35
55
  res.setEncoding('utf8');
36
56
  res.on('data', function (chunk) {
57
+ console.log('>>chunk', chunk);
37
58
  data += chunk;
38
59
  });
39
60
  res.on('end', () => {
61
+ console.log('response end');
40
62
  try {
63
+ if (data == null)
64
+ console.log("empty response");
65
+ console.log('data:', data);
41
66
  self.result = JSON.parse(data);
42
67
  resolve(self.result);
43
68
  }
@@ -53,7 +78,11 @@ class WebService {
53
78
  });
54
79
  if (postData !== null)
55
80
  req.write(postData);
81
+ else
82
+ req.write('');
83
+ console.log('request ending', body);
56
84
  req.end(body);
85
+ console.log('request ended');
57
86
  }
58
87
  catch (exc) {
59
88
  console.log(exc);
@@ -65,6 +94,7 @@ class WebService {
65
94
  class BPMNClient extends WebService {
66
95
  constructor(host, port, apiKey) {
67
96
  super();
97
+ ;
68
98
  this.host = host;
69
99
  this.port = port;
70
100
  this.apiKey = apiKey;
package/src/BPMNClient.ts CHANGED
@@ -12,13 +12,37 @@ class WebService {
12
12
  response;
13
13
  constructor() { }
14
14
 
15
- async invoke(params, options,postData=null) {
15
+ async invoke(params, options, postData = null) {
16
+
17
+ var axios = require('axios');
18
+
19
+ var data = JSON.stringify(params);
20
+ var url = 'http://'+options.host+':'+options.port+options.path;
21
+
22
+ if (options.port == 443)
23
+ url = 'https://'+options.host+options.path;
24
+
25
+ var config = {
26
+ method: options.method,
27
+ url: url,
28
+ headers: options.headers,
29
+ data: data
30
+ };
31
+
32
+ let self = this;
33
+
34
+ let response = await axios(config);
35
+ self.result = response.data;
36
+
37
+ return response.data;
38
+ }
39
+ async invokeOld(params, options,postData=null) {
16
40
 
17
41
  var driver = http;
18
42
 
19
43
  var body = JSON.stringify(params);
20
-
21
- // console.log(options, params);
44
+ console.log('invoke:');
45
+ console.log('options:',options, params);
22
46
  if (options.port == 443)
23
47
  driver = https;
24
48
 
@@ -28,16 +52,22 @@ class WebService {
28
52
  try {
29
53
 
30
54
  var req = driver.request(options, function (res) {
31
- // console.log('STATUS: ' + res.statusCode);
55
+ console.log('STATUS: ' + res.statusCode);
32
56
  this.response = res;
33
57
  //console.log(res);
34
58
  self.statusCode = res.statusCode;
35
59
  res.setEncoding('utf8');
36
60
  res.on('data', function (chunk) {
61
+ console.log('>>chunk', chunk);
37
62
  data += chunk;
38
63
  });
39
64
  res.on('end', () => {
65
+ console.log('response end');
40
66
  try {
67
+ if (data == null)
68
+ console.log("empty response");
69
+ console.log('data:', data);
70
+
41
71
  self.result = JSON.parse(data);
42
72
  resolve(self.result);
43
73
  }
@@ -53,10 +83,13 @@ class WebService {
53
83
  console.log("Error: " + err.message);
54
84
  reject(err);
55
85
  });
56
- if (postData !==null)
86
+ if (postData !== null)
57
87
  req.write(postData);
58
-
88
+ else
89
+ req.write('');
90
+ console.log('request ending',body);
59
91
  req.end(body);
92
+ console.log('request ended');
60
93
  }
61
94
  catch (exc) {
62
95
  console.log(exc);
@@ -76,6 +109,7 @@ class BPMNClient extends WebService {
76
109
 
77
110
  constructor(host, port, apiKey) {
78
111
  super();
112
+ ;
79
113
  this.host = host;
80
114
  this.port = port;
81
115
  this.apiKey = apiKey;
@@ -187,7 +221,6 @@ class BPMNClient extends WebService {
187
221
  };
188
222
  }
189
223
 
190
-
191
224
  return await this.invoke(params, options);
192
225
 
193
226
  }
package/test-raw.js ADDED
@@ -0,0 +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
+ }
package/test-raw.ts ADDED
@@ -0,0 +1,73 @@
1
+ console.log("Testing BPMNClient raw");
2
+
3
+
4
+ raw1();
5
+
6
+ async function raw1() {
7
+ var axios = require('axios');
8
+ var data = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
9
+
10
+ var config = {
11
+ method: 'get',
12
+ url: 'http://localhost:3000/api/datastore/findItems',
13
+ headers: {
14
+ 'x-api-key': '12345',
15
+ 'Content-Type': 'application/json',
16
+ // 'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
17
+ },
18
+ data: data
19
+ };
20
+ var response = await axios(config);
21
+ console.log(response.data);
22
+ /*
23
+ axios(config)
24
+ .then(function (response) {
25
+ console.log('then',JSON.stringify(response.data));
26
+ })
27
+ .catch(function (error) {
28
+ console.log('error',error);
29
+ });
30
+ */
31
+ }
32
+ async function raw() {
33
+ console.log('raw');
34
+ var https = require('follow-redirects').http;
35
+ var fs = require('fs');
36
+
37
+ var options = {
38
+ 'method': 'GET',
39
+ 'hostname': 'localhost',
40
+ 'port': 3000,
41
+ 'path': '/api/datastore/findItems',
42
+ 'headers': {
43
+ 'x-api-key': '12345',
44
+ 'Content-Type': 'application/json',
45
+ 'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
46
+ },
47
+ 'maxRedirects': 20
48
+ };
49
+
50
+ var req = https.request(options, function (res) {
51
+ var chunks = [];
52
+
53
+ res.on("data", function (chunk) {
54
+ console.log('data', chunk);
55
+ chunks.push(chunk);
56
+ });
57
+
58
+ res.on("end", function (chunk) {
59
+ var body = Buffer.concat(chunks);
60
+ console.log('end',body.toString());
61
+ });
62
+
63
+ res.on("error", function (error) {
64
+ console.error(error);
65
+ });
66
+ });
67
+
68
+ var postData = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
69
+
70
+ req.write(postData);
71
+
72
+ req.end();
73
+ }
package/test.js CHANGED
@@ -10,13 +10,74 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const _1 = require("./");
13
+ const readline = require("readline");
14
+ const cl = readline.createInterface(process.stdin, process.stdout);
15
+ const question = function (q) {
16
+ return new Promise((res, rej) => {
17
+ cl.question(q, answer => {
18
+ res(answer);
19
+ });
20
+ });
21
+ };
13
22
  console.log("Testing BPMNClient");
14
23
  const dotenv = require('dotenv');
15
24
  const res = dotenv.config();
25
+ console.log(res.parsed.PORT);
16
26
  const fs = require('fs');
17
- const server = new _1.BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
27
+ //raw();
28
+ const server = new _1.BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
29
+ console.log(server);
18
30
  //testMessage();
19
- testImport();
31
+ // testImport();
32
+ test1();
33
+ end();
34
+ function raw() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ var https = require('follow-redirects').https;
37
+ var fs = require('fs');
38
+ var options = {
39
+ 'method': 'GET',
40
+ 'hostname': 'localhost',
41
+ 'port': 3000,
42
+ 'path': '/api/datastore/findItems',
43
+ 'headers': {
44
+ 'x-api-key': '12345',
45
+ 'Content-Type': 'application/json',
46
+ 'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
47
+ },
48
+ 'maxRedirects': 20
49
+ };
50
+ var req = https.request(options, function (res) {
51
+ var chunks = [];
52
+ res.on("data", function (chunk) {
53
+ chunks.push(chunk);
54
+ });
55
+ res.on("end", function (chunk) {
56
+ var body = Buffer.concat(chunks);
57
+ console.log(body.toString());
58
+ });
59
+ res.on("error", function (error) {
60
+ console.error(error);
61
+ });
62
+ });
63
+ var postData = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
64
+ req.write(postData);
65
+ req.end();
66
+ });
67
+ }
68
+ function end() {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ yield question("continue");
71
+ });
72
+ }
73
+ function test1() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ var items = yield server.definitions.list();
76
+ items.forEach(item => {
77
+ // console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
78
+ });
79
+ });
80
+ }
20
81
  function testImport() {
21
82
  return __awaiter(this, void 0, void 0, function* () {
22
83
  var file = 'test-import';
@@ -67,7 +128,7 @@ function testMessage() {
67
128
  }
68
129
  function test() {
69
130
  return __awaiter(this, void 0, void 0, function* () {
70
- const server = new _1.BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
131
+ const server = new _1.BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
71
132
  const caseId = 3040;
72
133
  var delResp = yield server.datastore.deleteInstances({ name: 'Buy Used Car' });
73
134
  //console.log(delResp);
package/test.ts CHANGED
@@ -1,16 +1,85 @@
1
1
  import { BPMNClient } from './';
2
2
 
3
+ import * as readline from 'readline';
4
+ const cl = readline.createInterface(process.stdin, process.stdout);
5
+ const question = function (q) {
6
+ return new Promise((res, rej) => {
7
+ cl.question(q, answer => {
8
+ res(answer);
9
+ })
10
+ });
11
+ };
12
+
3
13
 
4
14
  console.log("Testing BPMNClient");
5
15
  const dotenv = require('dotenv');
6
16
  const res = dotenv.config();
17
+ console.log(res.parsed.PORT);
7
18
  const fs = require('fs');
19
+ //raw();
8
20
 
9
- const server = new BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
10
21
 
22
+ const server = new BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
23
+ console.log(server);
11
24
  //testMessage();
12
- testImport();
25
+ // testImport();
26
+ test1();
27
+ end();
28
+
29
+ async function raw() {
30
+ var https = require('follow-redirects').https;
31
+ var fs = require('fs');
32
+
33
+ var options = {
34
+ 'method': 'GET',
35
+ 'hostname': 'localhost',
36
+ 'port': 3000,
37
+ 'path': '/api/datastore/findItems',
38
+ 'headers': {
39
+ 'x-api-key': '12345',
40
+ 'Content-Type': 'application/json',
41
+ 'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
42
+ },
43
+ 'maxRedirects': 20
44
+ };
45
+
46
+ var req = https.request(options, function (res) {
47
+ var chunks = [];
48
+
49
+ res.on("data", function (chunk) {
50
+ chunks.push(chunk);
51
+ });
52
+
53
+ res.on("end", function (chunk) {
54
+ var body = Buffer.concat(chunks);
55
+ console.log(body.toString());
56
+ });
57
+
58
+ res.on("error", function (error) {
59
+ console.error(error);
60
+ });
61
+ });
62
+
63
+ var postData = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
13
64
 
65
+ req.write(postData);
66
+
67
+ req.end();
68
+ }
69
+
70
+ async function end() {
71
+ await question("continue")
72
+ }
73
+ async function test1() {
74
+ var items = await server.definitions.list();
75
+
76
+
77
+ items.forEach(item => {
78
+ // console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
79
+ });
80
+
81
+
82
+ }
14
83
  async function testImport() {
15
84
 
16
85
 
@@ -70,7 +139,7 @@ async function testMessage() {
70
139
 
71
140
  async function test() {
72
141
 
73
- const server = new BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
142
+ const server = new BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
74
143
 
75
144
  const caseId = 3040;
76
145