UNPKG

@unchainedshop/core-events

Version:

This package defines the event module which ensures the emitted events are written to the database as an Event History and offers a core module to search for events.

36 lines 1.33 kB
import { mongodb, ModuleInput } from '@unchainedshop/mongodb'; import { SortOption, DateFilterInput } from '@unchainedshop/utils'; import { Event } from '../db/EventsCollection.js'; export interface EventReport { emitCount: number; type: string; } export interface EventQuery { types?: string[]; queryString?: string; created?: Date; } export declare const buildFindSelector: ({ types, queryString, created }: EventQuery) => { type?: any; $text?: any; created?: any; }; export declare const configureEventsModule: ({ db }: ModuleInput<Record<string, never>>) => Promise<{ create: (doc: Event) => Promise<string>; findEvent: ({ eventId, ...rest }: mongodb.Filter<Event> & { eventId: string; }, options?: mongodb.FindOptions) => Promise<Event>; findEvents: ({ limit, offset, sort, ...query }: EventQuery & { limit?: number; offset?: number; sort?: SortOption[]; }) => Promise<Event[]>; type: (event: Event) => string; count: (query: EventQuery) => Promise<number>; getReport: ({ dateRange, types }?: { dateRange?: DateFilterInput; types?: string[]; }) => Promise<EventReport[]>; }>; export type EventsModule = Awaited<ReturnType<typeof configureEventsModule>>; //# sourceMappingURL=configureEventsModule.d.ts.map