bpmn-client 1.0.3 → 1.2.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 (43) hide show
  1. package/.env +4 -0
  2. package/Sample/package.json +44 -0
  3. package/Sample/test.js +30 -0
  4. package/Sample/test.ts +27 -0
  5. package/Sample/tsconfig.json +17 -0
  6. package/bpmn-client-1.2.0.tgz +0 -0
  7. package/index.js +10 -141
  8. package/index.ts +1 -139
  9. package/package.json +8 -8
  10. package/{BPMNClient.js → src/BPMNClient.js} +124 -52
  11. package/src/BPMNClient.ts +219 -0
  12. package/src/index.js +15 -0
  13. package/src/index.ts +4 -0
  14. package/src/interfaces/DataObjects.js +2 -0
  15. package/src/interfaces/DataObjects.ts +97 -0
  16. package/src/interfaces/Enums.js +117 -0
  17. package/src/interfaces/Enums.ts +71 -0
  18. package/test/.eslintrc.json +20 -0
  19. package/test/feature/.env +5 -0
  20. package/test/feature/carServer.js +117 -0
  21. package/test/helpers/setup.js +9 -0
  22. package/test/logs/Buy Used Carrepairsfalse cleaning +0 -0
  23. package/test/logs/Buy Used Carrepairstrue cleaning +0 -0
  24. package/test/logs/Buy Used Carscenario CaseId +0 -0
  25. package/test/logs/carrepairsfalse cleaning +0 -0
  26. package/test/logs/carrepairstrue cleaning +0 -0
  27. package/test/mocha.opts +5 -0
  28. package/test/resources/Invoice.js +91 -0
  29. package/test/resources/car.js +69 -0
  30. package/test/resources/loop.js +50 -0
  31. package/test.js +14 -5
  32. package/test.ts +21 -4
  33. package/test2.js +270 -0
  34. package/test2.ts +326 -0
  35. package/tsconfig.json +4 -4
  36. package/BPMNClient.d.ts +0 -36
  37. package/BPMNClient.js.map +0 -1
  38. package/BPMNClient.ts +0 -139
  39. package/index.d.ts +0 -36
  40. package/index.js.map +0 -1
  41. package/npm.list +0 -579
  42. package/test.d.ts +0 -1
  43. package/test.js.map +0 -1
package/.env ADDED
@@ -0,0 +1,4 @@
1
+ API_KEY=12345
2
+ HOST=localhost
3
+ PORT=3000
4
+ BASE_URL=api
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "bpmn-client-sample",
3
+ "version": "1.2.0",
4
+ "license": "MIT",
5
+ "scripts": {
6
+ "build": "tsc --build",
7
+ "clean": "tsc --build --clean",
8
+ "start": "node app.ts",
9
+ "test": "mocha -R dot",
10
+ "posttest": "eslint . --cache && npm run toc",
11
+ "wintest": "node_modules/.bin/mocha",
12
+ "start:watch": "tsc-watch --project . --onSuccess \"nodemon ./test.ts\"",
13
+ "toc": "node scripts/generate-api-toc ./docs/API.md,./docs/Examples.md",
14
+ "test-md": "node scripts/test-markdown.js ./docs/API.md && node scripts/test-markdown.js ./docs/Examples.md"
15
+ },
16
+ "description": "Client API for BPMN-Server webservices",
17
+ "keywords": [
18
+ "BPMN",
19
+ "BPMN 2.0",
20
+ "Workflow",
21
+ "Node.js",
22
+ "TypeScript"
23
+ ],
24
+ "author": {
25
+ "name": "ralphhanna"
26
+ },
27
+ "dependencies": {
28
+ "bpmn-client": "*",
29
+ "connect-busboy": "0.0.2",
30
+ "core-js": "^3.6.5",
31
+ "dotenv": "^16.0.1"
32
+ },
33
+ "devDependencies": {
34
+ "@types/mime": "^1.3.1",
35
+ "@types/node": "^8.10.62",
36
+ "@types/serve-static": "^1.7.32",
37
+ "nodemon": "^2.0.19",
38
+ "ts-node": "^8.10.2",
39
+ "typescript": "^3.9.7"
40
+ },
41
+ "engines": {
42
+ "node": "^14.0.0"
43
+ }
44
+ }
package/Sample/test.js ADDED
@@ -0,0 +1,30 @@
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 src_1 = require("bpmn-client/src/");
13
+ console.log("Testing BPMNClient");
14
+ test();
15
+ function test() {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const client = new src_1.BPMNClient('localhost', 3000, 12345);
18
+ var instance = yield client.engine.start("Buy Used Car", {});
19
+ console.log("instance.id", instance.id, instance.name, instance.status);
20
+ var insts = yield client.datastore.findInstances({ 'status': 'running' });
21
+ insts.forEach(inst => {
22
+ console.log('id==>' + inst.id, inst.name, 'status==>', inst.status);
23
+ });
24
+ var items = yield client.datastore.findItems({ query: { "items.elementId": "task_Buy" } });
25
+ items.forEach(item => {
26
+ console.log('item: id==>' + item.id, item.name, 'status==>', item.status);
27
+ });
28
+ });
29
+ }
30
+ //# sourceMappingURL=test.js.map
package/Sample/test.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { BPMNClient } from "bpmn-client/src/";
2
+
3
+
4
+ console.log("Testing BPMNClient");
5
+ test();
6
+
7
+ async function test() {
8
+ const client = new BPMNClient('localhost', 3000,12345);
9
+ var instance = await client.engine.start("Buy Used Car", {} );
10
+ console.log("instance.id", instance.id, instance.name,instance.status);
11
+
12
+ var insts= await client.datastore.findInstances({ 'status': 'running' });
13
+
14
+ insts.forEach(inst => {
15
+ console.log('id==>' + inst.id,inst.name, 'status==>',inst.status);
16
+ });
17
+
18
+
19
+ var items = await client.datastore.findItems({ query: { "items.elementId": "task_Buy" } });
20
+
21
+
22
+ items.forEach(item => {
23
+ console.log('item: id==>' + item.id, item.name, 'status==>', item.status);
24
+ });
25
+
26
+ }
27
+
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "target": "es6",
5
+ "lib": [ "es6" ],
6
+ "sourceMap": false,
7
+ "declaration": false,
8
+ "listFiles" : false
9
+
10
+ },
11
+ "include": [
12
+ "**/*.ts"
13
+ ],
14
+ "exclude": [
15
+ "node_modules"
16
+ ]
17
+ }
Binary file
package/index.js CHANGED
@@ -1,144 +1,13 @@
1
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
- });
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
10
11
  };
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Engine = exports.BPMNClient = void 0;
13
- const http = require('http');
14
- class BPMNClient {
15
- constructor(host, port) {
16
- this.host = host;
17
- this.port = port;
18
- this.engine = new Engine(this);
19
- this.datastore = new Datastore(this);
20
- }
21
- get(url, data = {}) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- return yield this.request(url, 'GET', data);
24
- });
25
- }
26
- post(url, data = {}) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- return yield this.request(url, 'POST', data);
29
- });
30
- }
31
- put(url, data = {}) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- return yield this.request(url, 'PUT', data);
34
- });
35
- }
36
- del(url, data = {}) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- return yield this.request(url, 'DELETE', data);
39
- });
40
- }
41
- request(url, method, params) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- var options;
44
- var body = JSON.stringify(params);
45
- if (params) {
46
- options = {
47
- host: this.host,
48
- port: this.port,
49
- path: '/api/' + url,
50
- method: method,
51
- headers: {
52
- "Content-Type": "application/json",
53
- "Content-Length": Buffer.byteLength(body)
54
- }
55
- };
56
- }
57
- else {
58
- options = {
59
- host: this.host,
60
- port: this.port,
61
- path: '/api/' + url,
62
- method: method
63
- };
64
- }
65
- console.log(options);
66
- let data = '';
67
- let self = this;
68
- return new Promise(function (resolve, reject) {
69
- try {
70
- http.request(options, function (res) {
71
- console.log('STATUS: ' + res.statusCode);
72
- // console.log('HEADERS: ' + JSON.stringify(res.headers));
73
- self.statusCode = res.statusCode;
74
- res.setEncoding('utf8');
75
- res.on('data', function (chunk) {
76
- data += chunk;
77
- });
78
- res.on('end', () => {
79
- // console.log(JSON.parse(data));
80
- self.result = JSON.parse(data);
81
- resolve(self.result);
82
- });
83
- }).on("error", (err) => {
84
- console.log("Error: " + err.message);
85
- reject(err);
86
- }).end(body);
87
- }
88
- catch (exc) {
89
- console.log(exc);
90
- }
91
- });
92
- });
93
- }
94
- getItem(id) {
95
- if (!this.result.instance) {
96
- console.log(this.result);
97
- return;
98
- }
99
- return this.result.instance.items.filter(item => { return item.elementId == id; })[0];
100
- }
101
- }
102
- exports.BPMNClient = BPMNClient;
103
- class Engine {
104
- constructor(client) {
105
- this.client = client;
106
- }
107
- start({ name, data }) {
108
- return __awaiter(this, void 0, void 0, function* () {
109
- return yield this.client.post('engine/start', { name, data });
110
- });
111
- }
112
- invoke({ query, data }) {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- return yield this.client.put('engine/invoke', { query, data });
115
- });
116
- }
117
- get(query) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- return yield this.client.get('engine/get', query);
120
- });
121
- }
122
- }
123
- exports.Engine = Engine;
124
- class Datastore {
125
- constructor(client) {
126
- this.client = client;
127
- }
128
- findItems(query) {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- return yield this.client.get('datastore/findItems', query);
131
- });
132
- }
133
- findInsances(query) {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- return yield this.client.get('datastore/findInstances', query);
136
- });
137
- }
138
- deleteInstances(query) {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- return yield this.client.del('datastore/delete', query);
141
- });
142
- }
143
- }
144
- //# sourceMappingURL=index.js.map
13
+ __exportStar(require("./src/"), exports);
package/index.ts CHANGED
@@ -1,139 +1 @@
1
-
2
- const http = require('http');
3
-
4
-
5
-
6
- class BPMNClient {
7
- host;
8
- port;
9
- statusCode;
10
- result;
11
- engine: Engine;
12
- datastore: Datastore;
13
- constructor(host, port) {
14
- this.host = host;
15
- this.port = port;
16
- this.engine = new Engine(this);
17
- this.datastore = new Datastore(this);
18
- }
19
-
20
- async get(url, data = {}) {
21
- return await this.request(url, 'GET', data);
22
-
23
- }
24
- async post(url, data = {}) {
25
- return await this.request(url, 'POST', data);
26
-
27
- }
28
- async put(url, data = {}) {
29
- return await this.request(url, 'PUT', data);
30
-
31
- }
32
- async del(url, data = {}) {
33
- return await this.request(url, 'DELETE', data);
34
-
35
- }
36
- async request(url, method, params) {
37
-
38
- var options;
39
-
40
- var body = JSON.stringify(params);
41
-
42
- if (params) {
43
- options = {
44
- host: this.host,
45
- port: this.port,
46
- path: '/api/' + url,
47
- method: method,
48
- headers: {
49
- "Content-Type": "application/json",
50
- "Content-Length": Buffer.byteLength(body)
51
- }
52
- };
53
- }
54
- else {
55
- options = {
56
- host: this.host,
57
- port: this.port,
58
- path: '/api/' + url,
59
- method: method
60
- };
61
- }
62
- console.log(options);
63
- let data = '';
64
- let self = this;
65
- return new Promise(function (resolve, reject) {
66
- try {
67
-
68
- http.request(options, function (res) {
69
- console.log('STATUS: ' + res.statusCode);
70
- // console.log('HEADERS: ' + JSON.stringify(res.headers));
71
- self.statusCode = res.statusCode;
72
- res.setEncoding('utf8');
73
- res.on('data', function (chunk) {
74
- data += chunk;
75
- });
76
- res.on('end', () => {
77
- // console.log(JSON.parse(data));
78
- self.result = JSON.parse(data);
79
-
80
- resolve(self.result);
81
- });
82
-
83
-
84
- }).on("error", (err) => {
85
- console.log("Error: " + err.message);
86
- reject(err);
87
- }).end(body);
88
- }
89
- catch (exc) {
90
- console.log(exc);
91
- }
92
-
93
- });
94
-
95
- }
96
-
97
- getItem(id) {
98
- if (!this.result.instance) {
99
- console.log(this.result);
100
- return;
101
- }
102
- return this.result.instance.items.filter(item => { return item.elementId == id; })[0];
103
- }
104
- }
105
-
106
- class Engine {
107
- private client: BPMNClient;
108
-
109
- constructor(client) {
110
- this.client = client;
111
- }
112
- async start({ name, data }) {
113
- return await this.client.post('engine/start', { name, data });
114
- }
115
- async invoke({ query, data }) {
116
- return await this.client.put('engine/invoke', { query, data });
117
- }
118
- async get(query) {
119
- return await this.client.get('engine/get', query);
120
- }
121
- }
122
- class Datastore {
123
- private client: BPMNClient;
124
-
125
- constructor(client) {
126
- this.client = client;
127
- }
128
- async findItems(query) {
129
- return await this.client.get('datastore/findItems', query);
130
- }
131
- async findInsances(query) {
132
- return await this.client.get('datastore/findInstances', query);
133
- }
134
- async deleteInstances(query) {
135
- return await this.client.del('datastore/delete', query);
136
- }
137
- }
138
-
139
- export { BPMNClient , Engine}
1
+ export * from './src/';
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "bpmn-client",
3
- "version": "1.0.3",
3
+ "version": "1.2.0",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "tsc --build",
7
7
  "clean": "tsc --build --clean",
8
- "start:watch": "nodemon app",
9
8
  "start": "node app.ts",
10
9
  "test": "mocha -R dot",
11
10
  "posttest": "eslint . --cache && npm run toc",
12
11
  "wintest": "node_modules/.bin/mocha",
12
+ "start:watch": "tsc-watch --project . --onSuccess \"nodemon ./test.ts\"",
13
13
  "toc": "node scripts/generate-api-toc ./docs/API.md,./docs/Examples.md",
14
14
  "test-md": "node scripts/test-markdown.js ./docs/API.md && node scripts/test-markdown.js ./docs/Examples.md"
15
15
  },
16
- "description": "bpmn-server.webApp",
16
+ "description": "Client API for BPMN-Server webservices",
17
17
  "keywords": [
18
18
  "BPMN",
19
19
  "BPMN 2.0",
@@ -26,22 +26,22 @@
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "git+https:github.com/ralphhanna/bpmn-server.git"
29
+ "url": "git+https:github.com/ralphhanna/bpmn-client.git"
30
30
  },
31
31
  "dependencies": {
32
- "bpmn-server": "^1.0.0",
33
32
  "connect-busboy": "0.0.2",
34
33
  "core-js": "^3.6.5",
35
- "nodemon": "^2.0.4",
36
- "ts-node": "^8.10.1"
34
+ "dotenv": "^16.0.1"
37
35
  },
38
36
  "devDependencies": {
39
37
  "@types/mime": "^1.3.1",
40
38
  "@types/node": "^8.10.62",
41
39
  "@types/serve-static": "^1.7.32",
40
+ "nodemon": "^2.0.19",
41
+ "ts-node": "^8.10.2",
42
42
  "typescript": "^3.9.7"
43
43
  },
44
44
  "engines": {
45
- "node": "^8.0.0"
45
+ "node": "^14.0.0"
46
46
  }
47
47
  }