import { ComKey, Item, PriKey } from '@fjell/types'; /** * Base event interface that all events extend. * Provides core event properties with full type safety using the existing PriKey/ComKey system. */ export interface BaseEvent { /** Type of event - "create", "update", "delete", etc. */ eventType: string; /** The key of the item that was affected - maintains full type safety */ key: PriKey | ComKey; /** Which storage backend(s) generated this event - enables filtering by implementation */ scopes: string[]; /** When the event occurred */ timestamp: Date; /** Optional: the full item content - fully typed, no loss of type information */ item?: Item; } /** * Event emitted when an item is created. * The item property is required since we always have the created item data. */ export interface CreateEvent extends BaseEvent { eventType: 'create'; /** The created item - always available for create events */ item: Item; } /** * Event emitted when an item is updated. * Provides detailed change tracking with before/after states. */ export interface UpdateEvent extends BaseEvent { eventType: 'update'; /** List of field names that were changed */ changes: string[]; /** Optional: item state before the update */ before?: Item; /** Optional: item state after the update */ after?: Item; } /** * Event emitted when an item is deleted. * May include the deleted item data for cleanup/undo operations. */ export interface DeleteEvent extends BaseEvent { eventType: 'delete'; /** Optional: the deleted item content - useful for cleanup/undo */ item?: Item; } /** * Event emitted when a custom action is performed on an item. * Allows libraries to define custom event types beyond standard CRUD. */ export interface ActionEvent extends BaseEvent { eventType: 'action'; /** Name of the action that was performed */ actionName: string; /** Optional: action-specific data */ actionData?: Record; } /** * Union type of all standard event types. * Libraries can extend this with custom events if needed. */ export type Event = CreateEvent | UpdateEvent | DeleteEvent | ActionEvent; /** * Type guard to check if an event is a CreateEvent */ export declare function isCreateEvent(event: BaseEvent): event is CreateEvent; /** * Type guard to check if an event is an UpdateEvent */ export declare function isUpdateEvent(event: BaseEvent): event is UpdateEvent; /** * Type guard to check if an event is a DeleteEvent */ export declare function isDeleteEvent(event: BaseEvent): event is DeleteEvent; /** * Type guard to check if an event is an ActionEvent */ export declare function isActionEvent(event: BaseEvent): event is ActionEvent;