bellboy 6.7.2 → 7.0.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
@@ -137,21 +137,24 @@ job.on("startProcessingStream", async (...args: any) => {
137
137
  ```
138
138
 
139
139
  ```ts
140
- job.on('startProcessingRow', async (row: any)) => {
141
- // Row has been received and is about to be processed inside `recordGenerator` method.
140
+ job.on("startProcessingRow", async (row: any) => {
141
+ // Row has been received and is about to be processed inside `recordGenerator` method.
142
142
  });
143
143
  ```
144
144
 
145
145
  ```ts
146
- job.on('rowGenerated', async (destinationIndex: number, generatedRow: any)) => {
147
- // Row has been generated using `recordGenerator` method.
146
+ job.on("rowGenerated", async (destinationIndex: number, generatedRow: any) => {
147
+ // Row has been generated using `recordGenerator` method.
148
148
  });
149
149
  ```
150
150
 
151
151
  ```ts
152
- job.on('rowGenerationError', async (destinationIndex: number, row: any, error: any)) => {
152
+ job.on(
153
+ "rowGenerationError",
154
+ async (destinationIndex: number, row: any, error: any) => {
153
155
  // Record generation (`recordGenerator` method) has thrown an error.
154
- });
156
+ }
157
+ );
155
158
  ```
156
159
 
157
160
  ```ts
@@ -676,7 +679,9 @@ class CustomDestination extends bellboy.Destination {
676
679
 
677
680
  [Official stdout reporter](https://github.com/claviz/bellboy-stdout-reporter)
678
681
 
679
- Reporter is a job wrapper which can operate with [job instance](#job) (for example, listen to events using job `on` method). To create a new reporter, you must extend `Reporter` class and implement `report` function, which will be executed during job instance initialization. This function accepts one parameter:
682
+ Reporter is a job wrapper which can operate with [job instance](#job) (for example, listen to events using job `on` method). To create a new reporter, you must extend `Reporter` class and implement `report` function, which will be executed during job instance initialization.
683
+ Reporter event listeners (`on`, `onAny`) are added before any other user-defined listeners.
684
+ This function accepts one parameter:
680
685
 
681
686
  - **job** `Job` `required`\
682
687
  [Job](#job) instance
package/lib/job.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare class Job implements IJob {
16
16
  protected stopped: boolean;
17
17
  protected jobId: string;
18
18
  protected jobName?: string;
19
+ private settingReporterEvents;
19
20
  constructor(processor: IProcessor, destinations: IDestination[], config?: IJobConfig);
20
21
  stop(message?: string): void;
21
22
  run(): Promise<void>;
package/lib/job.js CHANGED
@@ -63,6 +63,7 @@ var Job = /** @class */ (function () {
63
63
  this.anyEvent = [];
64
64
  this.stopped = false;
65
65
  this.jobId = shortid_1.generate();
66
+ this.settingReporterEvents = false;
66
67
  this.jobName = config === null || config === void 0 ? void 0 : config.jobName;
67
68
  this.reporters = config.reporters || [];
68
69
  }
@@ -74,6 +75,7 @@ var Job = /** @class */ (function () {
74
75
  return __generator(this, function (_a) {
75
76
  switch (_a.label) {
76
77
  case 0:
78
+ this.settingReporterEvents = true;
77
79
  i = 0;
78
80
  _a.label = 1;
79
81
  case 1:
@@ -86,6 +88,7 @@ var Job = /** @class */ (function () {
86
88
  i++;
87
89
  return [3 /*break*/, 1];
88
90
  case 4:
91
+ this.settingReporterEvents = false;
89
92
  this.stop = function (message) {
90
93
  _this.stopped = true;
91
94
  if (readStream && (readStream instanceof stream_1.Readable)) {
@@ -278,16 +281,19 @@ var Job = /** @class */ (function () {
278
281
  });
279
282
  };
280
283
  Job.prototype.on = function (eventName, event, extendedEvent) {
281
- var existingEvent = this.events[eventName];
282
- if (!existingEvent) {
283
- this.events[eventName] = [{ event: event, extendedEvent: extendedEvent, }];
284
- }
285
- else {
286
- this.events[eventName].push({ event: event, extendedEvent: extendedEvent, });
284
+ var eventEntry = { event: event, extendedEvent: extendedEvent };
285
+ if (!this.events[eventName]) {
286
+ this.events[eventName] = [];
287
287
  }
288
+ this.settingReporterEvents
289
+ ? this.events[eventName].unshift(eventEntry)
290
+ : this.events[eventName].push(eventEntry);
288
291
  };
289
292
  Job.prototype.onAny = function (event, extendedEvent) {
290
- this.anyEvent.push({ event: event, extendedEvent: extendedEvent, });
293
+ var eventEntry = { event: event, extendedEvent: extendedEvent };
294
+ this.settingReporterEvents
295
+ ? this.anyEvent.unshift(eventEntry)
296
+ : this.anyEvent.push(eventEntry);
291
297
  };
292
298
  Job.prototype.flushRows = function (rows) {
293
299
  return __awaiter(this, void 0, void 0, function () {
package/lib/utils.js CHANGED
@@ -165,7 +165,9 @@ function getValueFromJSONChunk() {
165
165
  return new stream_1.Transform({
166
166
  objectMode: true,
167
167
  transform: function (chunk, encoding, callback) {
168
- this.push(chunk.value);
168
+ if (chunk.value) {
169
+ this.push(chunk.value);
170
+ }
169
171
  callback();
170
172
  }
171
173
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bellboy",
3
- "version": "6.7.2",
3
+ "version": "7.0.0",
4
4
  "description": "Highly performant JavaScript data stream ETL engine.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index",