bellboy 6.6.0 → 6.6.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.
@@ -50,7 +50,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
50
  };
51
51
  Object.defineProperty(exports, "__esModule", { value: true });
52
52
  exports.MssqlProcessor = void 0;
53
- var stream_1 = require("stream");
54
53
  var utils_1 = require("../utils");
55
54
  var database_processor_1 = require("./base/database-processor");
56
55
  var MssqlProcessor = /** @class */ (function (_super) {
@@ -60,109 +59,20 @@ var MssqlProcessor = /** @class */ (function (_super) {
60
59
  }
61
60
  MssqlProcessor.prototype.process = function (processStream) {
62
61
  return __awaiter(this, void 0, void 0, function () {
63
- var done, readStream, data, db, dbRequest, processRows;
64
- var _this = this;
62
+ var db, dbRequest, readStream;
65
63
  return __generator(this, function (_a) {
66
64
  switch (_a.label) {
67
- case 0:
68
- done = false;
69
- readStream = new stream_1.Readable({
70
- objectMode: true,
71
- read: function () {
72
- return __awaiter(this, void 0, void 0, function () {
73
- var err_1, rowData;
74
- return __generator(this, function (_a) {
75
- switch (_a.label) {
76
- case 0:
77
- if (!(data.length === 0)) return [3 /*break*/, 6];
78
- if (!!done) return [3 /*break*/, 5];
79
- _a.label = 1;
80
- case 1:
81
- _a.trys.push([1, 3, , 4]);
82
- return [4 /*yield*/, processRows()];
83
- case 2:
84
- _a.sent();
85
- return [3 /*break*/, 4];
86
- case 3:
87
- err_1 = _a.sent();
88
- this.emit('error', err_1);
89
- return [3 /*break*/, 4];
90
- case 4: return [3 /*break*/, 6];
91
- case 5: return [2 /*return*/, this.push(null)];
92
- case 6:
93
- rowData = data.shift();
94
- this.push(rowData);
95
- return [2 /*return*/];
96
- }
97
- });
98
- });
99
- },
100
- });
101
- data = [];
102
- return [4 /*yield*/, utils_1.getDb(this.connection, 'mssql')];
65
+ case 0: return [4 /*yield*/, utils_1.getDb(this.connection, 'mssql')];
103
66
  case 1:
104
67
  db = _a.sent();
105
68
  dbRequest = db.request();
106
- dbRequest.stream = true;
69
+ readStream = dbRequest.toReadableStream();
107
70
  dbRequest.query(this.query);
108
- processRows = function () { return __awaiter(_this, void 0, void 0, function () {
109
- var _this = this;
110
- return __generator(this, function (_a) {
111
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
112
- function removeListeners() {
113
- dbRequest.removeListener('row', onRow);
114
- dbRequest.removeListener('done', onDone);
115
- dbRequest.removeListener('error', onError);
116
- }
117
- function onRow(row) {
118
- return __awaiter(this, void 0, void 0, function () {
119
- return __generator(this, function (_a) {
120
- data.push(row);
121
- if (data.length >= 10000) {
122
- dbRequest.pause();
123
- removeListeners();
124
- resolve();
125
- }
126
- return [2 /*return*/];
127
- });
128
- });
129
- }
130
- function onDone() {
131
- return __awaiter(this, void 0, void 0, function () {
132
- return __generator(this, function (_a) {
133
- done = true;
134
- removeListeners();
135
- resolve();
136
- return [2 /*return*/];
137
- });
138
- });
139
- }
140
- function onError(err) {
141
- return __awaiter(this, void 0, void 0, function () {
142
- return __generator(this, function (_a) {
143
- removeListeners();
144
- reject(err);
145
- return [2 /*return*/];
146
- });
147
- });
148
- }
149
- return __generator(this, function (_a) {
150
- ;
151
- ;
152
- ;
153
- ;
154
- dbRequest.on('row', onRow);
155
- dbRequest.on('done', onDone);
156
- dbRequest.on('error', onError);
157
- dbRequest.resume();
158
- return [2 /*return*/];
159
- });
160
- }); })];
161
- });
162
- }); };
163
- dbRequest.pause();
164
71
  return [4 /*yield*/, processStream(readStream)];
165
72
  case 2:
73
+ _a.sent();
74
+ return [4 /*yield*/, db.close()];
75
+ case 3:
166
76
  _a.sent();
167
77
  return [2 /*return*/];
168
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bellboy",
3
- "version": "6.6.0",
3
+ "version": "6.6.1",
4
4
  "description": "Highly performant JavaScript data stream ETL engine.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index",
@@ -29,7 +29,7 @@
29
29
  "devDependencies": {
30
30
  "@types/axios": "^0.14.0",
31
31
  "@types/jest": "^25.2.1",
32
- "@types/mssql": "^6.0.7",
32
+ "@types/mssql": "^7.1.5",
33
33
  "@types/node": "^14.10.2",
34
34
  "@types/request-promise": "^4.1.43",
35
35
  "@types/shortid": "0.0.29",