import type { Snapshot, User, Workspace } from '@prisma/client'; import { Flatten, Payload } from './types'; export interface WorkspaceEvents { deleted: Payload; blob: { deleted: Payload<{ workspaceId: Workspace['id']; name: string; }>; }; } export interface DocEvents { updated: Payload< Pick & { previous: Pick; } >; deleted: Payload>; } export interface UserEvents { updated: Payload>; deleted: Payload; } /** * Event definitions can be extended by * * @example * * declare module './event/def' { * interface UserEvents { * created: Payload; * } * } * * assert() */ export interface EventDefinitions { workspace: WorkspaceEvents; snapshot: DocEvents; user: UserEvents; } export type EventKV = Flatten; export type Event = keyof EventKV; export type EventPayload = EventKV[E]; export type { Payload };