import { type DittoDB } from '@/db.ts'; import { type Event } from '@/deps.ts'; import { type DittoFilter } from '@/filter.ts'; import { type EventData } from '@/types.ts'; /** Additional options to apply to the whole subscription. */ interface GetEventsOpts { /** Signal to abort the request. */ signal?: AbortSignal; /** Event limit for the whole subscription. */ limit?: number; /** Relays to use, if applicable. */ relays?: WebSocket['url'][]; } /** Options when storing an event. */ interface StoreEventOpts { /** Event data to store. */ data?: EventData; /** Relays to use, if applicable. */ relays?: WebSocket['url'][]; } type AuthorStats = Omit; type EventStats = Omit; /** Internal Event representation used by Ditto, including extra keys. */ interface DittoEvent extends Event { author?: DittoEvent<0>; author_stats?: AuthorStats; event_stats?: EventStats; } /** Storage interface for Nostr events. */ interface EventStore { /** Add an event to the store. */ storeEvent(event: Event, opts?: StoreEventOpts): Promise; /** Get events from filters. */ getEvents(filters: DittoFilter[], opts?: GetEventsOpts): Promise[]>; /** Get the number of events from filters. */ countEvents(filters: DittoFilter[]): Promise; /** Delete events from filters. */ deleteEvents(filters: DittoFilter[]): Promise; } export type { DittoEvent, EventStore, GetEventsOpts, StoreEventOpts };