/** * Storage abstraction for BrightChat services. * * This interface lives in brightchain-lib so that ConversationService, * GroupService, and ChannelService can depend on it without importing * brightchain-db. A BrightDb-backed implementation is provided at * construction time from application.ts. * * When no provider is injected (e.g. in unit tests), services fall back * to their existing in-memory Maps. * * Collection names (for BrightDb wiring): * - brightchat_conversations * - brightchat_messages * - brightchat_groups * - brightchat_group_messages * - brightchat_channels * - brightchat_channel_messages * - brightchat_invite_tokens * - brightchat_servers * - brightchat_server_invites */ import { IChannel, ICommunicationMessage, IConversation, IGroup, IInviteToken } from '../communication'; import { IServer, IServerInviteToken } from './server'; /** * Minimal async CRUD collection interface. * * Mirrors the subset of operations that BrightChat services perform * on their internal Maps. Any backing store (BrightDb, in-memory, etc.) * can satisfy this contract. * * The `key` parameter in findById / update / delete is the logical * primary key for the entity (e.g. `id` for most types, `token` for * invite tokens). */ export interface IChatCollection { /** Insert a new document. */ create(doc: T): Promise; /** Find a single document by its primary key, or return null. */ findById(key: string): Promise; /** * Find all documents matching a partial filter. * An empty/undefined filter returns all documents. */ findMany(filter?: Partial): Promise; /** Replace the document with the matching primary key. */ update(key: string, doc: T): Promise; /** Delete the document with the matching primary key. */ delete(key: string): Promise; } /** * Groups all BrightChat collections behind a single injectable provider. * * Services receive this at construction time. Each getter returns a * typed collection backed by BrightDb (or an in-memory fallback). */ export interface IChatStorageProvider { /** Collection for 1-on-1 conversations (`brightchat_conversations`). */ readonly conversations: IChatCollection; /** Collection for conversation messages (`brightchat_messages`). */ readonly messages: IChatCollection; /** Collection for group entities (`brightchat_groups`). */ readonly groups: IChatCollection; /** Collection for group messages (`brightchat_group_messages`). */ readonly groupMessages: IChatCollection; /** Collection for channel entities (`brightchat_channels`). */ readonly channels: IChatCollection; /** Collection for channel messages (`brightchat_channel_messages`). */ readonly channelMessages: IChatCollection; /** Collection for channel invite tokens (`brightchat_invite_tokens`). */ readonly inviteTokens: IChatCollection; /** Collection for server entities (`brightchat_servers`). */ readonly servers: IChatCollection; /** Collection for server invite tokens (`brightchat_server_invites`). */ readonly serverInvites: IChatCollection; } //# sourceMappingURL=chatStorageProvider.d.ts.map