bpmn-client 1.3.16 → 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/test.ts CHANGED
@@ -1,16 +1,174 @@
1
1
  import { BPMNClient } from './';
2
+ const fs = require("fs");
2
3
 
4
+ const axios = require('axios');
5
+ const FormData = require('form-data');
3
6
 
7
+
8
+ uploadFile('Trans.bpmn');
9
+
10
+ //-----------------------------------
11
+ async function uploadFile(file) {
12
+
13
+ var axios = require('axios');
14
+
15
+ const fileContents = fs.createReadStream(file);
16
+ const title = 'My file';
17
+
18
+ const form = new FormData();
19
+ form.append('title', 'title');
20
+ form.append('file', fileContents);
21
+ console.log(1);
22
+ var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\""
23
+ + file + "\"\r\nContent-Type: \"text/plain\"\r\n\r\n" +
24
+ fs.readFileSync(file) + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
25
+ // formData.append(postData);
26
+
27
+
28
+
29
+ try {
30
+ console.log(2,form);
31
+
32
+ const response = await axios.post('http://localhost:3000/api/definitions/import/test1', form, {
33
+ headers: {
34
+ "Content-Type": "multipart/form-data",
35
+ "x-api-key": "12345",
36
+
37
+ }
38
+ });
39
+ console.log(3);
40
+
41
+ console.log('Response Status:',response.status,response.data);
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
+ } else if (error.request) { // no response
49
+ console.log(error.request);
50
+ } else { // Something wrong in setting up the request
51
+ console.log('Error', error.message);
52
+ }
53
+ console.log(error.config);
54
+ }
55
+ }
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+ import * as readline from 'readline';
75
+ const cl = readline.createInterface(process.stdin, process.stdout);
76
+ const question = function (q) {
77
+ return new Promise((res, rej) => {
78
+ cl.question(q, answer => {
79
+ res(answer);
80
+ })
81
+ });
82
+ };
83
+
84
+ //fun1();
85
+
86
+ async function fun1()
87
+ {
88
+ await fun2();
89
+ }
90
+ async function fun2()
91
+ {
92
+ try {
93
+ await fun3();
94
+ }
95
+ catch(exc)
96
+ {
97
+ console.log('error caught but not handled');
98
+ }
99
+ }
100
+ async function fun3()
101
+ {
102
+ throw new Error('fun3');
103
+ }
4
104
  console.log("Testing BPMNClient");
5
105
  const dotenv = require('dotenv');
6
106
  const res = dotenv.config();
7
- const fs = require('fs');
107
+ console.log(res.parsed.PORT);
108
+ //raw();
8
109
 
9
- const server = new BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
10
110
 
111
+ const server = new BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
11
112
  //testMessage();
12
- testImport();
113
+ // testImport();
114
+ /*
115
+ test1();
116
+ end();
117
+ */
118
+ async function raw() {
119
+ var https = require('follow-redirects').https;
120
+ var fs = require('fs');
121
+
122
+ var options = {
123
+ 'method': 'GET',
124
+ 'hostname': 'localhost',
125
+ 'port': 3000,
126
+ 'path': '/api/datastore/findItems',
127
+ 'headers': {
128
+ 'x-api-key': '12345',
129
+ 'Content-Type': 'application/json',
130
+ 'Cookie': 'connect.sid=s%3AFJpzbs-nlVsxrhROzC_e0joMyopi6ke0.uoCjT87OZa3SOJosZxXCrC7zriAIVdMmtwcKsrY2C4I'
131
+ },
132
+ 'maxRedirects': 20
133
+ };
134
+
135
+ var req = https.request(options, function (res) {
136
+ var chunks = [];
137
+
138
+ res.on("data", function (chunk) {
139
+ chunks.push(chunk);
140
+ });
141
+
142
+ res.on("end", function (chunk) {
143
+ var body = Buffer.concat(chunks);
144
+ console.log(body.toString());
145
+ });
146
+
147
+ res.on("error", function (error) {
148
+ console.error(error);
149
+ });
150
+ });
151
+
152
+ var postData = JSON.stringify({ "items.status": "end", "items.elementId": "script_task" });
153
+
154
+ req.write(postData);
155
+
156
+ req.end();
157
+ }
158
+
159
+ async function end() {
160
+ await question("continue")
161
+ }
162
+ async function test1() {
163
+ var items = await server.definitions.list();
13
164
 
165
+
166
+ items.forEach(item => {
167
+ // console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
168
+ });
169
+
170
+
171
+ }
14
172
  async function testImport() {
15
173
 
16
174
 
@@ -70,7 +228,7 @@ async function testMessage() {
70
228
 
71
229
  async function test() {
72
230
 
73
- const server = new BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
231
+ const server = new BPMNClient(process.env.HOST, res.parsed.PORT, process.env.API_KEY);
74
232
 
75
233
  const caseId = 3040;
76
234
 
package/test3.js CHANGED
@@ -1,42 +1,42 @@
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
- //import { BPMNClient } from "bpmn-client";
13
- const _1 = require("./");
14
- const readline = require("readline");
15
- const dotenv = require('dotenv');
16
- const res = dotenv.config();
17
- const cl = readline.createInterface(process.stdin, process.stdout);
18
- const question = function (q) {
19
- return new Promise((res, rej) => {
20
- cl.question(q, answer => {
21
- res(answer);
22
- });
23
- });
24
- };
25
- completeUserTask();
26
- function completeUserTask() {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const server = new _1.BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
29
- const instanceId = yield question('Please provide your Instance ID: ');
30
- const taskId = yield question('Please provide your Task ID: ');
31
- let taskData = yield question('Please provide your Task Data (json obj) if any: ');
32
- cl.close();
33
- if (taskData === "") {
34
- taskData = {};
35
- }
36
- else {
37
- taskData = JSON.parse(taskData.toString());
38
- }
39
- yield server.engine.invoke({ id: instanceId, "items.elementId": taskId }, taskData);
40
- console.log("Completed UserTask:", taskId);
41
- });
42
- }
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
+ //import { BPMNClient } from "bpmn-client";
13
+ const _1 = require("./");
14
+ const readline = require("readline");
15
+ const dotenv = require('dotenv');
16
+ const res = dotenv.config();
17
+ const cl = readline.createInterface(process.stdin, process.stdout);
18
+ const question = function (q) {
19
+ return new Promise((res, rej) => {
20
+ cl.question(q, answer => {
21
+ res(answer);
22
+ });
23
+ });
24
+ };
25
+ completeUserTask();
26
+ function completeUserTask() {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const server = new _1.BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
29
+ const instanceId = yield question('Please provide your Instance ID: ');
30
+ const taskId = yield question('Please provide your Task ID: ');
31
+ let taskData = yield question('Please provide your Task Data (json obj) if any: ');
32
+ cl.close();
33
+ if (taskData === "") {
34
+ taskData = {};
35
+ }
36
+ else {
37
+ taskData = JSON.parse(taskData.toString());
38
+ }
39
+ yield server.engine.invoke({ id: instanceId, "items.elementId": taskId }, taskData);
40
+ console.log("Completed UserTask:", taskId);
41
+ });
42
+ }