bellboy 8.4.1 → 8.5.1

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.
@@ -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
- var stream_1 = require("stream");
54
- var processor_1 = require("./base/processor");
55
- var mqtt = require('async-mqtt');
56
- var MqttProcessor = /** @class */ (function (_super) {
57
- __extends(MqttProcessor, _super);
58
- function MqttProcessor(config) {
59
- var _this = _super.call(this, config) || this;
60
- _this.url = config.url;
61
- _this.topics = config.topics;
62
- return _this;
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
- MqttProcessor.prototype.process = function (processStream) {
65
- return __awaiter(this, void 0, void 0, function () {
66
- var readStream, client;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0:
70
- readStream = new stream_1.Readable({
71
- objectMode: true,
72
- read: function () { },
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
- return MqttProcessor;
96
- }(processor_1.Processor));
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
- var stream_1 = require("stream");
54
- var utils_1 = require("../utils");
55
- var database_processor_1 = require("./base/database-processor");
56
- var MssqlProcessor = /** @class */ (function (_super) {
57
- __extends(MssqlProcessor, _super);
58
- function MssqlProcessor(config) {
59
- var _this = _super.call(this, config) || this;
60
- _this.connection = config.connection;
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
- MssqlProcessor.prototype.process = function (processStream) {
64
- return __awaiter(this, void 0, void 0, function () {
65
- var done, readStream, data, db, dbRequest, processRows;
66
- var _this = this;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0:
70
- done = false;
71
- readStream = new stream_1.Readable({
72
- objectMode: true,
73
- read: function () {
74
- return __awaiter(this, void 0, void 0, function () {
75
- var err_1, rowData;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0:
79
- if (!(data.length === 0)) return [3 /*break*/, 6];
80
- if (!!done) return [3 /*break*/, 5];
81
- _a.label = 1;
82
- case 1:
83
- _a.trys.push([1, 3, , 4]);
84
- return [4 /*yield*/, processRows()];
85
- case 2:
86
- _a.sent();
87
- return [3 /*break*/, 4];
88
- case 3:
89
- err_1 = _a.sent();
90
- this.emit('error', err_1);
91
- return [3 /*break*/, 4];
92
- case 4: return [3 /*break*/, 6];
93
- case 5: return [2 /*return*/, this.push(null)];
94
- case 6:
95
- rowData = data.shift() || null;
96
- this.push(rowData);
97
- return [2 /*return*/];
98
- }
99
- });
100
- });
101
- },
102
- });
103
- data = [];
104
- return [4 /*yield*/, utils_1.getDb(this.connection, 'mssql')];
105
- case 1:
106
- db = _a.sent();
107
- dbRequest = db.request();
108
- dbRequest.on('error', function (err) {
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
- return [4 /*yield*/, processStream(readStream)];
175
- case 2:
176
- _a.sent();
177
- return [4 /*yield*/, utils_1.closeDbConnection(this.connection)];
178
- case 3:
179
- _a.sent();
180
- return [2 /*return*/];
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
- return MssqlProcessor;
186
- }(database_processor_1.DatabaseProcessor));
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
- var database_processor_1 = require("./base/database-processor");
57
- var promise_1 = __importDefault(require("mysql2-stream-fix/promise"));
58
- var MySqlProcessor = /** @class */ (function (_super) {
59
- __extends(MySqlProcessor, _super);
60
- function MySqlProcessor(config) {
61
- var _this = _super.call(this, config) || this;
62
- _this.connection = config.connection;
63
- return _this;
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
- MySqlProcessor.prototype.process = function (processStream) {
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
- var utils_1 = require("../utils");
54
- var database_processor_1 = require("./base/database-processor");
55
- var QueryStream = require('pg-query-stream');
56
- var PostgresProcessor = /** @class */ (function (_super) {
57
- __extends(PostgresProcessor, _super);
58
- function PostgresProcessor(config) {
59
- var _this = _super.call(this, config) || this;
60
- _this.connection = config.connection;
61
- return _this;
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
- PostgresProcessor.prototype.process = function (processStream) {
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;