@wabot-dev/framework 0.1.0-beta.51 → 0.1.0-beta.52

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,17 +1,29 @@
1
1
  import { __decorate } from 'tslib';
2
2
  import { singleton } from '../../core/injection/index.js';
3
+ import { Logger } from '../../core/logger/Logger.js';
3
4
 
4
5
  let JobsEventsHub = class JobsEventsHub {
6
+ logger = new Logger('wabot:jobs-events-hub');
5
7
  jobsEventsListener = null;
6
8
  notifyJobCreated(job) {
7
- if (!this.jobsEventsListener) {
8
- return;
9
- }
10
- this.jobsEventsListener({
11
- jobId: job.id,
12
- commandName: job.commandName,
13
- type: 'created',
14
- });
9
+ const timer = setTimeout(async () => {
10
+ if (!this.jobsEventsListener) {
11
+ return;
12
+ }
13
+ try {
14
+ await this.jobsEventsListener({
15
+ jobId: job.id,
16
+ commandName: job.commandName,
17
+ type: 'created',
18
+ });
19
+ }
20
+ catch (err) {
21
+ this.logger.error(err);
22
+ }
23
+ finally {
24
+ clearTimeout(timer);
25
+ }
26
+ }, 1000);
15
27
  }
16
28
  listenJobsEvents(listener) {
17
29
  this.jobsEventsListener = listener;
@@ -357,6 +357,7 @@ interface IJobEvent extends IStorableData {
357
357
  }
358
358
  type IJobEventListener = (event: IJobEvent) => void | Promise<void>;
359
359
  declare class JobsEventsHub {
360
+ private logger;
360
361
  private jobsEventsListener;
361
362
  notifyJobCreated(job: Job): void;
362
363
  listenJobsEvents(listener: IJobEventListener): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.1.0-beta.51",
3
+ "version": "0.1.0-beta.52",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",