UNPKG

@unchainedshop/core-events

Version:

Event history and tracking module for the Unchained Engine

39 lines (38 loc) 1.42 kB
import { mongodb, type ModuleInput } from '@unchainedshop/mongodb'; import { type SortOption, type DateFilterInput } from '@unchainedshop/utils'; import { type Event } from '../db/EventsCollection.ts'; export interface EventReport { emitCount: number; type: string; } export interface EventQuery { types?: string[]; queryString?: string; created?: { end?: Date; start?: 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: Omit<Event, "_id" | "created"> & Pick<Partial<Event>, "_id" | "created">) => Promise<string>; findEvent: ({ eventId, ...rest }: mongodb.Filter<Event> & { eventId: string; }, options?: mongodb.FindOptions) => Promise<Event | null>; 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>>;