bellboy 8.2.1 → 8.3.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.
package/README.md CHANGED
@@ -310,6 +310,7 @@ Each processor in `bellboy` is a class which has a single responsibility of proc
310
310
  - [PostgresProcessor](#postgres-processor) processes data received from a **PostgreSQL** SELECT.
311
311
  - [MySqlProcessor](#mysql-processor) processes data received from a **MySQL** SELECT.
312
312
  - [MssqlProcessor](#mssql-processor) processes data received from a **MSSQL** SELECT.
313
+ - [FirebirdProcessor](#firebird-processor) processes data received from a **Firebird** SELECT.
313
314
  - [DynamicProcessor](#dynamic-processor) processes **dynamically generated** data.
314
315
  - [TailProcessor](#tail-processor) processes **new lines** added to the file.
315
316
 
@@ -546,6 +547,21 @@ Processes a MySQL `SELECT` query row by row.
546
547
  - **port**
547
548
  - **database**
548
549
 
550
+ ### FirebirdProcessor <div id='firebird-processor'/>
551
+
552
+ Processes a Firebird `SELECT` query row by row.
553
+
554
+ #### Options
555
+
556
+ - [Processor options](#processor-options)
557
+ - **query** `string` `required`\
558
+ Query to execute.
559
+ - **connection** `object` `required`
560
+ - **user**
561
+ - **password**
562
+ - **host**
563
+ - **database**
564
+
549
565
  ### MssqlProcessor <div id='mssql-processor'/>
550
566
 
551
567
  Processes a MSSQL `SELECT` query row by row.
package/lib/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export { JsonProcessor } from './processors/json-processor';
12
12
  export { MqttProcessor } from './processors/mqtt-processor';
13
13
  export { TailProcessor } from './processors/tail-processor';
14
14
  export { DelimitedProcessor } from './processors/delimited-processor';
15
+ export { FirebirdProcessor } from './processors/firebird-processor';
15
16
  export { Destination } from './destinations/base/destination';
16
17
  export { DatabaseDestination } from './destinations/base/database-destination';
17
18
  export { HttpDestination } from './destinations/http-destination';
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Reporter = exports.getDb = exports.MySqlDestination = exports.StdoutDestination = exports.PostgresDestination = exports.MssqlDestination = exports.HttpDestination = exports.DatabaseDestination = exports.Destination = exports.DelimitedProcessor = exports.TailProcessor = exports.MqttProcessor = exports.JsonProcessor = exports.DynamicProcessor = exports.HttpProcessor = exports.MssqlProcessor = exports.MySqlProcessor = exports.PostgresProcessor = exports.ExcelProcessor = exports.DirectoryProcessor = exports.DatabaseProcessor = exports.Processor = exports.Job = void 0;
3
+ exports.Reporter = exports.getDb = exports.MySqlDestination = exports.StdoutDestination = exports.PostgresDestination = exports.MssqlDestination = exports.HttpDestination = exports.DatabaseDestination = exports.Destination = exports.FirebirdProcessor = exports.DelimitedProcessor = exports.TailProcessor = exports.MqttProcessor = exports.JsonProcessor = exports.DynamicProcessor = exports.HttpProcessor = exports.MssqlProcessor = exports.MySqlProcessor = exports.PostgresProcessor = exports.ExcelProcessor = exports.DirectoryProcessor = exports.DatabaseProcessor = exports.Processor = exports.Job = void 0;
4
4
  var job_1 = require("./job");
5
5
  Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return job_1.Job; } });
6
6
  var processor_1 = require("./processors/base/processor");
@@ -29,6 +29,8 @@ var tail_processor_1 = require("./processors/tail-processor");
29
29
  Object.defineProperty(exports, "TailProcessor", { enumerable: true, get: function () { return tail_processor_1.TailProcessor; } });
30
30
  var delimited_processor_1 = require("./processors/delimited-processor");
31
31
  Object.defineProperty(exports, "DelimitedProcessor", { enumerable: true, get: function () { return delimited_processor_1.DelimitedProcessor; } });
32
+ var firebird_processor_1 = require("./processors/firebird-processor");
33
+ Object.defineProperty(exports, "FirebirdProcessor", { enumerable: true, get: function () { return firebird_processor_1.FirebirdProcessor; } });
32
34
  var destination_1 = require("./destinations/base/destination");
33
35
  Object.defineProperty(exports, "Destination", { enumerable: true, get: function () { return destination_1.Destination; } });
34
36
  var database_destination_1 = require("./destinations/base/database-destination");
@@ -0,0 +1,7 @@
1
+ import { IFirebirdDbConnection, IFirebirdProcessorConfig, processStream } from '../types';
2
+ import { DatabaseProcessor } from './base/database-processor';
3
+ export declare class FirebirdProcessor extends DatabaseProcessor {
4
+ protected connection: IFirebirdDbConnection;
5
+ constructor(config: IFirebirdProcessorConfig);
6
+ process(processStream: processStream): Promise<void>;
7
+ }
@@ -0,0 +1,105 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.FirebirdProcessor = void 0;
56
+ var node_firebird_1 = __importDefault(require("node-firebird"));
57
+ var stream_1 = require("stream");
58
+ var database_processor_1 = require("./base/database-processor");
59
+ var FirebirdProcessor = /** @class */ (function (_super) {
60
+ __extends(FirebirdProcessor, _super);
61
+ function FirebirdProcessor(config) {
62
+ var _this = _super.call(this, config) || this;
63
+ _this.connection = config.connection;
64
+ return _this;
65
+ }
66
+ FirebirdProcessor.prototype.process = function (processStream) {
67
+ return __awaiter(this, void 0, void 0, function () {
68
+ var db, stream;
69
+ var _this = this;
70
+ return __generator(this, function (_a) {
71
+ switch (_a.label) {
72
+ case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
73
+ node_firebird_1.default.attach(_this.connection, function (err, db) {
74
+ if (err)
75
+ reject(err);
76
+ else
77
+ resolve(db);
78
+ });
79
+ })];
80
+ case 1:
81
+ db = _a.sent();
82
+ stream = new stream_1.Readable({
83
+ objectMode: true,
84
+ read: function () { }
85
+ });
86
+ db.sequentially(this.query, [], function (row) {
87
+ if (!stream.push(row)) { }
88
+ }, function (err) {
89
+ if (err) {
90
+ stream.emit('error', err);
91
+ }
92
+ stream.push(null);
93
+ db.detach();
94
+ });
95
+ return [4 /*yield*/, processStream(stream)];
96
+ case 2:
97
+ _a.sent();
98
+ return [2 /*return*/];
99
+ }
100
+ });
101
+ });
102
+ };
103
+ return FirebirdProcessor;
104
+ }(database_processor_1.DatabaseProcessor));
105
+ exports.FirebirdProcessor = FirebirdProcessor;
package/lib/types.d.ts CHANGED
@@ -16,6 +16,13 @@ export interface IPostgresDbConnection {
16
16
  database?: string;
17
17
  schema?: string;
18
18
  }
19
+ export interface IFirebirdDbConnection {
20
+ port?: number;
21
+ user?: string;
22
+ password?: string;
23
+ host?: string;
24
+ database?: string;
25
+ }
19
26
  export interface ITdsDriver {
20
27
  ConnectionPool: any;
21
28
  Transaction: any;
@@ -143,6 +150,9 @@ export interface IMssqlProcessorConfig extends IDatabaseProcessorConfig {
143
150
  export interface IPostgresProcessorConfig extends IDatabaseProcessorConfig {
144
151
  connection: IPostgresDbConnection;
145
152
  }
153
+ export interface IFirebirdProcessorConfig extends IDatabaseProcessorConfig {
154
+ connection: IFirebirdDbConnection;
155
+ }
146
156
  export interface IMySqlProcessorConfig extends IDatabaseProcessorConfig {
147
157
  connection: IMySqlDbConnection;
148
158
  }
@@ -162,7 +172,7 @@ export interface IBellboyEvent {
162
172
  timestamp: number;
163
173
  jobStopped: boolean;
164
174
  }
165
- export declare type DbTypes = 'postgres' | 'mssql' | 'mysql';
175
+ export declare type DbTypes = 'postgres' | 'mssql' | 'mysql' | 'firebird';
166
176
  export declare type event = (...args: any) => Promise<any>;
167
177
  export declare type extendedEvent = (bellboyEvent: IBellboyEvent) => Promise<any>;
168
178
  export declare type sheetGetter = (sheets: IWorksheet[]) => Promise<string[]>;
package/lib/utils.js CHANGED
@@ -126,14 +126,17 @@ function getDb(databaseConfig, dbType) {
126
126
  _a = dbType;
127
127
  switch (_a) {
128
128
  case 'mssql': return [3 /*break*/, 1];
129
- case 'mysql': return [3 /*break*/, 3];
130
- case 'postgres': return [3 /*break*/, 4];
129
+ case 'firebird': return [3 /*break*/, 3];
130
+ case 'mysql': return [3 /*break*/, 5];
131
+ case 'postgres': return [3 /*break*/, 6];
131
132
  }
132
- return [3 /*break*/, 4];
133
+ return [3 /*break*/, 6];
133
134
  case 1: return [4 /*yield*/, getMssqlDb(databaseConfig)];
134
135
  case 2: return [2 /*return*/, _b.sent()];
135
- case 3: return [2 /*return*/, getMySqlDb(databaseConfig)];
136
- case 4: return [2 /*return*/, getPostgresDb(databaseConfig)];
136
+ case 3: return [4 /*yield*/, getFirebirdDb(databaseConfig)];
137
+ case 4: return [2 /*return*/, _b.sent()];
138
+ case 5: return [2 /*return*/, getMySqlDb(databaseConfig)];
139
+ case 6: return [2 /*return*/, getPostgresDb(databaseConfig)];
137
140
  }
138
141
  });
139
142
  });
@@ -186,6 +189,29 @@ function getPostgresDb(databaseConfig) {
186
189
  setCachedDbConnection(databaseConfig, db, pgp.end);
187
190
  return db;
188
191
  }
192
+ function getFirebirdDb(databaseConfig) {
193
+ return __awaiter(this, void 0, void 0, function () {
194
+ var Firebird, db;
195
+ return __generator(this, function (_a) {
196
+ switch (_a.label) {
197
+ case 0:
198
+ Firebird = require('node-firebird');
199
+ return [4 /*yield*/, new Promise(function (resolve, reject) {
200
+ Firebird.attach(databaseConfig, function (err, db) {
201
+ if (err)
202
+ reject(err);
203
+ else
204
+ resolve(db);
205
+ });
206
+ })];
207
+ case 1:
208
+ db = _a.sent();
209
+ setCachedDbConnection(databaseConfig, db, db.detach.bind(db));
210
+ return [2 /*return*/, db];
211
+ }
212
+ });
213
+ });
214
+ }
189
215
  function closeDbConnection(databaseConfig) {
190
216
  return __awaiter(this, void 0, void 0, function () {
191
217
  var dbConnection;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "bellboy",
3
- "version": "8.2.1",
3
+ "version": "8.3.0",
4
4
  "description": "Highly performant JavaScript data stream ETL engine.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index",
7
7
  "scripts": {
8
8
  "build": "tsc -p .",
9
- "test": "jest --coverage ./tests/postgres-destination.spec.ts",
9
+ "test": "jest --coverage",
10
10
  "lint": "tslint -c tslint.json -p tsconfig.json",
11
11
  "codecov": "codecov"
12
12
  },
@@ -57,6 +57,7 @@
57
57
  "iconv-lite": "^0.6.3",
58
58
  "mssql": "8.1.0",
59
59
  "mysql2-stream-fix": "^3.9.1",
60
+ "node-firebird": "1.1.8",
60
61
  "pg": "8.0.3",
61
62
  "pg-promise": "10.5.3",
62
63
  "pg-query-stream": "3.0.7",