bellboy 8.4.1 → 8.5.2
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 +1 -1
- package/lib/destinations/base/database-destination.js +10 -70
- package/lib/destinations/base/destination.js +10 -47
- package/lib/destinations/http-destination.js +20 -98
- package/lib/destinations/mssql-destination.js +41 -137
- package/lib/destinations/mysql-destination.js +30 -109
- package/lib/destinations/postgres-destination.js +49 -119
- package/lib/destinations/stdout-destination.js +11 -67
- package/lib/job.js +169 -424
- package/lib/processors/base/database-processor.js +8 -23
- package/lib/processors/base/directory-processor.js +16 -33
- package/lib/processors/base/processor.js +7 -47
- package/lib/processors/delimited-processor.js +43 -111
- package/lib/processors/dynamic-processor.js +12 -72
- package/lib/processors/excel-processor.js +43 -122
- package/lib/processors/firebird-processor.js +31 -96
- package/lib/processors/http-processor.js +82 -175
- package/lib/processors/json-processor.js +27 -99
- package/lib/processors/mqtt-processor.js +24 -91
- package/lib/processors/mssql-processor.js +79 -179
- package/lib/processors/mysql-processor.js +15 -81
- package/lib/processors/postgres-processor.js +17 -83
- package/lib/processors/tail-processor.js +33 -102
- package/lib/reporters/base/reporter.js +5 -7
- package/lib/types.d.ts +6 -7
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +91 -281
- package/package.json +31 -31
|
@@ -1,97 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
-
function step(op) {
|
|
29
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
31
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
-
switch (op[0]) {
|
|
34
|
-
case 0: case 1: t = op; break;
|
|
35
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
-
default:
|
|
39
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
-
if (t[2]) _.ops.pop();
|
|
44
|
-
_.trys.pop(); continue;
|
|
45
|
-
}
|
|
46
|
-
op = body.call(thisArg, _);
|
|
47
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
3
|
exports.MqttProcessor = void 0;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
const processor_1 = require("./base/processor");
|
|
6
|
+
let mqtt = require('async-mqtt');
|
|
7
|
+
class MqttProcessor extends processor_1.Processor {
|
|
8
|
+
url;
|
|
9
|
+
topics;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
super(config);
|
|
12
|
+
this.url = config.url;
|
|
13
|
+
this.topics = config.topics;
|
|
63
14
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
client = mqtt.connect(this.url);
|
|
75
|
-
return [4 /*yield*/, client.subscribe(this.topics)];
|
|
76
|
-
case 1:
|
|
77
|
-
_a.sent();
|
|
78
|
-
client.on('message', function (topic, message) {
|
|
79
|
-
readStream.push({ topic: topic, message: message.toString() });
|
|
80
|
-
});
|
|
81
|
-
return [4 /*yield*/, processStream(readStream)];
|
|
82
|
-
case 2:
|
|
83
|
-
_a.sent();
|
|
84
|
-
return [4 /*yield*/, client.unsubscribe(this.topics)];
|
|
85
|
-
case 3:
|
|
86
|
-
_a.sent();
|
|
87
|
-
return [4 /*yield*/, client.end(true)];
|
|
88
|
-
case 4:
|
|
89
|
-
_a.sent();
|
|
90
|
-
return [2 /*return*/];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
15
|
+
async process(processStream) {
|
|
16
|
+
const readStream = new stream_1.Readable({
|
|
17
|
+
objectMode: true,
|
|
18
|
+
read() { },
|
|
19
|
+
});
|
|
20
|
+
const client = mqtt.connect(this.url);
|
|
21
|
+
await client.subscribe(this.topics);
|
|
22
|
+
client.on('message', (topic, message) => {
|
|
23
|
+
readStream.push({ topic, message: message.toString() });
|
|
93
24
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
25
|
+
await processStream(readStream);
|
|
26
|
+
await client.unsubscribe(this.topics);
|
|
27
|
+
await client.end(true);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
97
30
|
exports.MqttProcessor = MqttProcessor;
|
|
@@ -1,187 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
-
function step(op) {
|
|
29
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
31
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
-
switch (op[0]) {
|
|
34
|
-
case 0: case 1: t = op; break;
|
|
35
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
-
default:
|
|
39
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
-
if (t[2]) _.ops.pop();
|
|
44
|
-
_.trys.pop(); continue;
|
|
45
|
-
}
|
|
46
|
-
op = body.call(thisArg, _);
|
|
47
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
3
|
exports.MssqlProcessor = void 0;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return _this;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const database_processor_1 = require("./base/database-processor");
|
|
7
|
+
class MssqlProcessor extends database_processor_1.DatabaseProcessor {
|
|
8
|
+
connection;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super(config);
|
|
11
|
+
this.connection = config.connection;
|
|
62
12
|
}
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (err.code !== 'ECANCEL') {
|
|
110
|
-
readStream.emit('error', err);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
readStream.on('close', function () {
|
|
114
|
-
dbRequest.cancel();
|
|
115
|
-
});
|
|
116
|
-
dbRequest.stream = true;
|
|
117
|
-
dbRequest.query(this.query);
|
|
118
|
-
processRows = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
119
|
-
var _this = this;
|
|
120
|
-
return __generator(this, function (_a) {
|
|
121
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
122
|
-
function removeListeners() {
|
|
123
|
-
dbRequest.removeListener('row', onRow);
|
|
124
|
-
dbRequest.removeListener('done', onDone);
|
|
125
|
-
dbRequest.removeListener('error', onError);
|
|
126
|
-
}
|
|
127
|
-
function onRow(row) {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
-
return __generator(this, function (_a) {
|
|
130
|
-
data.push(row);
|
|
131
|
-
if (data.length >= 1000) {
|
|
132
|
-
dbRequest.pause();
|
|
133
|
-
removeListeners();
|
|
134
|
-
resolve();
|
|
135
|
-
}
|
|
136
|
-
return [2 /*return*/];
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
function onDone() {
|
|
141
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
-
return __generator(this, function (_a) {
|
|
143
|
-
done = true;
|
|
144
|
-
removeListeners();
|
|
145
|
-
resolve();
|
|
146
|
-
return [2 /*return*/];
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
function onError(err) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
return __generator(this, function (_a) {
|
|
153
|
-
removeListeners();
|
|
154
|
-
reject(err);
|
|
155
|
-
return [2 /*return*/];
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return __generator(this, function (_a) {
|
|
160
|
-
;
|
|
161
|
-
;
|
|
162
|
-
;
|
|
163
|
-
;
|
|
164
|
-
dbRequest.on('row', onRow);
|
|
165
|
-
dbRequest.on('done', onDone);
|
|
166
|
-
dbRequest.on('error', onError);
|
|
167
|
-
dbRequest.resume();
|
|
168
|
-
return [2 /*return*/];
|
|
169
|
-
});
|
|
170
|
-
}); })];
|
|
171
|
-
});
|
|
172
|
-
}); };
|
|
13
|
+
async process(processStream) {
|
|
14
|
+
let done = false;
|
|
15
|
+
const readStream = new stream_1.Readable({
|
|
16
|
+
objectMode: true,
|
|
17
|
+
async read() {
|
|
18
|
+
if (data.length === 0) {
|
|
19
|
+
if (!done) {
|
|
20
|
+
try {
|
|
21
|
+
await processRows();
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
this.emit('error', err);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return this.push(null);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const rowData = data.shift() || null;
|
|
32
|
+
this.push(rowData);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const data = [];
|
|
36
|
+
const db = await (0, utils_1.getDb)(this.connection, 'mssql');
|
|
37
|
+
const dbRequest = db.request();
|
|
38
|
+
dbRequest.on('error', (err) => {
|
|
39
|
+
if (err.code !== 'ECANCEL') {
|
|
40
|
+
readStream.emit('error', err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
readStream.on('close', () => {
|
|
44
|
+
dbRequest.cancel();
|
|
45
|
+
});
|
|
46
|
+
dbRequest.stream = true;
|
|
47
|
+
dbRequest.query(this.query);
|
|
48
|
+
const processRows = async () => {
|
|
49
|
+
return new Promise(async (resolve, reject) => {
|
|
50
|
+
function removeListeners() {
|
|
51
|
+
dbRequest.removeListener('row', onRow);
|
|
52
|
+
dbRequest.removeListener('done', onDone);
|
|
53
|
+
dbRequest.removeListener('error', onError);
|
|
54
|
+
}
|
|
55
|
+
;
|
|
56
|
+
async function onRow(row) {
|
|
57
|
+
data.push(row);
|
|
58
|
+
if (data.length >= 1000) {
|
|
173
59
|
dbRequest.pause();
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
60
|
+
removeListeners();
|
|
61
|
+
resolve();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
;
|
|
65
|
+
async function onDone() {
|
|
66
|
+
done = true;
|
|
67
|
+
removeListeners();
|
|
68
|
+
resolve();
|
|
181
69
|
}
|
|
70
|
+
;
|
|
71
|
+
async function onError(err) {
|
|
72
|
+
removeListeners();
|
|
73
|
+
reject(err);
|
|
74
|
+
}
|
|
75
|
+
;
|
|
76
|
+
dbRequest.on('row', onRow);
|
|
77
|
+
dbRequest.on('done', onDone);
|
|
78
|
+
dbRequest.on('error', onError);
|
|
79
|
+
dbRequest.resume();
|
|
182
80
|
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
81
|
+
};
|
|
82
|
+
dbRequest.pause();
|
|
83
|
+
await processStream(readStream);
|
|
84
|
+
await (0, utils_1.closeDbConnection)(this.connection);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
187
87
|
exports.MssqlProcessor = MssqlProcessor;
|
|
@@ -1,86 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
-
function step(op) {
|
|
29
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
31
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
-
switch (op[0]) {
|
|
34
|
-
case 0: case 1: t = op; break;
|
|
35
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
-
default:
|
|
39
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
-
if (t[2]) _.ops.pop();
|
|
44
|
-
_.trys.pop(); continue;
|
|
45
|
-
}
|
|
46
|
-
op = body.call(thisArg, _);
|
|
47
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
53
|
-
};
|
|
54
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
3
|
exports.MySqlProcessor = void 0;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const database_processor_1 = require("./base/database-processor");
|
|
6
|
+
const promise_1 = tslib_1.__importDefault(require("mysql2-stream-fix/promise"));
|
|
7
|
+
class MySqlProcessor extends database_processor_1.DatabaseProcessor {
|
|
8
|
+
connection;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super(config);
|
|
11
|
+
this.connection = config.connection;
|
|
12
|
+
}
|
|
13
|
+
async process(processStream) {
|
|
14
|
+
const dbConnection = promise_1.default.createPool(this.connection);
|
|
15
|
+
const query = dbConnection.pool.query(this.query).stream();
|
|
16
|
+
await processStream(query);
|
|
17
|
+
await dbConnection.end();
|
|
64
18
|
}
|
|
65
|
-
|
|
66
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var dbConnection, query;
|
|
68
|
-
return __generator(this, function (_a) {
|
|
69
|
-
switch (_a.label) {
|
|
70
|
-
case 0:
|
|
71
|
-
dbConnection = promise_1.default.createPool(this.connection);
|
|
72
|
-
query = dbConnection.pool.query(this.query).stream();
|
|
73
|
-
return [4 /*yield*/, processStream(query)];
|
|
74
|
-
case 1:
|
|
75
|
-
_a.sent();
|
|
76
|
-
return [4 /*yield*/, dbConnection.end()];
|
|
77
|
-
case 2:
|
|
78
|
-
_a.sent();
|
|
79
|
-
return [2 /*return*/];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
return MySqlProcessor;
|
|
85
|
-
}(database_processor_1.DatabaseProcessor));
|
|
19
|
+
}
|
|
86
20
|
exports.MySqlProcessor = MySqlProcessor;
|
|
@@ -1,88 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
-
function step(op) {
|
|
29
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
31
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
-
switch (op[0]) {
|
|
34
|
-
case 0: case 1: t = op; break;
|
|
35
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
-
default:
|
|
39
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
-
if (t[2]) _.ops.pop();
|
|
44
|
-
_.trys.pop(); continue;
|
|
45
|
-
}
|
|
46
|
-
op = body.call(thisArg, _);
|
|
47
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
3
|
exports.PostgresProcessor = void 0;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const database_processor_1 = require("./base/database-processor");
|
|
6
|
+
const QueryStream = require('pg-query-stream');
|
|
7
|
+
class PostgresProcessor extends database_processor_1.DatabaseProcessor {
|
|
8
|
+
connection;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super(config);
|
|
11
|
+
this.connection = config.connection;
|
|
12
|
+
}
|
|
13
|
+
async process(processStream) {
|
|
14
|
+
const query = new QueryStream(this.query);
|
|
15
|
+
const db = await (0, utils_1.getDb)(this.connection, 'postgres');
|
|
16
|
+
const dbConnection = await db.connect();
|
|
17
|
+
const stream = dbConnection.client.query(query);
|
|
18
|
+
await processStream(stream);
|
|
19
|
+
dbConnection.done();
|
|
62
20
|
}
|
|
63
|
-
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var query, db, dbConnection, stream;
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0:
|
|
69
|
-
query = new QueryStream(this.query);
|
|
70
|
-
return [4 /*yield*/, utils_1.getDb(this.connection, 'postgres')];
|
|
71
|
-
case 1:
|
|
72
|
-
db = _a.sent();
|
|
73
|
-
return [4 /*yield*/, db.connect()];
|
|
74
|
-
case 2:
|
|
75
|
-
dbConnection = _a.sent();
|
|
76
|
-
stream = dbConnection.client.query(query);
|
|
77
|
-
return [4 /*yield*/, processStream(stream)];
|
|
78
|
-
case 3:
|
|
79
|
-
_a.sent();
|
|
80
|
-
dbConnection.done();
|
|
81
|
-
return [2 /*return*/];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
return PostgresProcessor;
|
|
87
|
-
}(database_processor_1.DatabaseProcessor));
|
|
21
|
+
}
|
|
88
22
|
exports.PostgresProcessor = PostgresProcessor;
|