2021-04-22 10:07:10 +02:00
|
|
|
import { IUnleashConfig } from '../types/option';
|
|
|
|
import { IUnleashStores } from '../types/stores';
|
|
|
|
import { Logger } from '../logger';
|
2021-08-12 15:04:37 +02:00
|
|
|
import { IEventStore } from '../types/stores/event-store';
|
2021-11-12 13:15:51 +01:00
|
|
|
import { IEvent } from '../types/events';
|
2021-04-22 10:07:10 +02:00
|
|
|
|
|
|
|
export default class EventService {
|
|
|
|
private logger: Logger;
|
|
|
|
|
2021-08-12 15:04:37 +02:00
|
|
|
private eventStore: IEventStore;
|
2021-04-22 10:07:10 +02:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
{ eventStore }: Pick<IUnleashStores, 'eventStore'>,
|
|
|
|
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
|
|
|
|
) {
|
|
|
|
this.logger = getLogger('services/event-service.ts');
|
|
|
|
this.eventStore = eventStore;
|
|
|
|
}
|
|
|
|
|
|
|
|
async getEvents(): Promise<IEvent[]> {
|
|
|
|
return this.eventStore.getEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
async getEventsForToggle(name: string): Promise<IEvent[]> {
|
2021-11-12 13:15:51 +01:00
|
|
|
return this.eventStore.getEventsForFeature(name);
|
2021-04-22 10:07:10 +02:00
|
|
|
}
|
2021-09-20 12:13:38 +02:00
|
|
|
|
|
|
|
async getEventsForProject(project: string): Promise<IEvent[]> {
|
|
|
|
return this.eventStore.getEventsFilterByProject(project);
|
|
|
|
}
|
2021-04-22 10:07:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = EventService;
|