@data-fair/lib-node 2.8.0 → 2.8.2
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/events-queue.d.ts +6 -3
- package/events-queue.js +4 -2
- package/package.json +1 -1
package/events-queue.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type Event } from '@data-fair/lib-common-types/event/index.js';
|
|
2
2
|
import { type Notification } from '@data-fair/lib-common-types/notification/index.js';
|
|
3
3
|
import { SessionState } from '@data-fair/lib-common-types/session/index.js';
|
|
4
|
-
type EventsQueueOptions = {
|
|
4
|
+
export type EventsQueueOptions = {
|
|
5
5
|
eventsUrl: string;
|
|
6
6
|
eventsSecret: string;
|
|
7
|
+
inactive?: boolean;
|
|
7
8
|
};
|
|
9
|
+
export type PushEvent = Omit<Event, 'date'>;
|
|
10
|
+
export type PushNotification = Omit<Notification, 'date'>;
|
|
8
11
|
export declare class EventsQueue {
|
|
9
12
|
_options: EventsQueueOptions | undefined;
|
|
10
13
|
eventsQueue: Event[];
|
|
@@ -16,8 +19,8 @@ export declare class EventsQueue {
|
|
|
16
19
|
stop: () => Promise<void>;
|
|
17
20
|
loop(): Promise<void>;
|
|
18
21
|
drain(): Promise<void>;
|
|
19
|
-
pushEvent(event:
|
|
20
|
-
pushNotification(notification:
|
|
22
|
+
pushEvent(event: PushEvent, sessionState?: SessionState): void;
|
|
23
|
+
pushNotification(notification: PushNotification): void;
|
|
21
24
|
}
|
|
22
25
|
declare const eventsQueue: EventsQueue;
|
|
23
26
|
export default eventsQueue;
|
package/events-queue.js
CHANGED
|
@@ -66,7 +66,8 @@ export class EventsQueue {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
pushEvent (event, sessionState) {
|
|
69
|
-
this.options()
|
|
69
|
+
const options = this.options()
|
|
70
|
+
if (options.inactive) { return }
|
|
70
71
|
if (this.stopped) { throw new Error('events queue has been stopped') }
|
|
71
72
|
event.date = new Date().toISOString()
|
|
72
73
|
debug('pushEvent', event)
|
|
@@ -97,7 +98,8 @@ export class EventsQueue {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
pushNotification (notification) {
|
|
100
|
-
this.options()
|
|
101
|
+
const options = this.options()
|
|
102
|
+
if (options.inactive) { return }
|
|
101
103
|
if (this.stopped) { throw new Error('notifications queue has been stopped') }
|
|
102
104
|
notification.date = new Date().toISOString()
|
|
103
105
|
debug('pushNotification', notification)
|