import type { MongoStorage } from '../index.js'; import type { CacheConfig, Logger } from '../../../types/index.js'; import type { Chat, WASocket } from '@whiskeysockets/baileys'; import CRUD from './CRUD.js'; import type { Db, ObjectId, WithId } from './CRUD.js'; type ChatAliasMeta = { canonicalJid?: string; lid?: string; pn?: string; aliasJids?: string[]; _dirty?: boolean; }; type ChatsDoc = Chat & ChatAliasMeta & { _id: string | ObjectId; }; declare class Chats extends CRUD { protected readonly storage: MongoStorage; protected readonly sock: WASocket | null; static collectionName: string; private cache; constructor(storage: MongoStorage, mongodb: Db, sock: WASocket | null, logger: Logger | null, cacheConfig: CacheConfig['chats'] | null); private indexes; private getCachedChats; private setCachedChats; private markAsDirty; private resolveChatIdentity; private hydrateChatAliasMeta; private mergeChatDocs; /** * Getter to expose the raw MongoDB collection. */ getCollection(): import("mongodb").Collection; /** * Retrieve chats. * - If `id` (jid) is provided, returns the doc that contains that jid or `null` if not found. * - If `id` is not provided, returns an array of all documents. * * @param id Chat jid (Optional) */ get(id: string | undefined): Promise | null>; get(): Promise[]>; /** * Utility to group chats by canonical ID. */ private groupChats; /** * Utility to normalize chat. */ private normalizeChat; /** * Utility to generate bulkWrite operations for chats. */ private generateChatOps; /** * Set multiple chats (upsert). */ set({ chats, isLatest }: { chats: Chat[]; isLatest?: boolean; }): Promise; /** * Upsert chats. * If the doc for the given chat id doesn't exist, create it. * Otherwise, update the existing doc by adding or updating the chat key. * Additionally, moves the chat to the "top" of the collection by updating a `conversationTimestamp` field.. */ upsert(chats: Chat[]): Promise; /** * Update existing chats based on partial updates. * No longer fetch all docs. Directly attempt updates. */ update(updates: Partial[]): Promise; /** * Merge PN/LID alias chat docs under one canonical chat id. */ mergeAliases({ canonicalJid, aliasJids }: { canonicalJid: string; aliasJids: string[]; }): Promise; /** * Delete chats by their IDs. */ del(ids: string[]): Promise; /** * Clear unread count of chat. */ clearUnreadCount(id: string): void; } export default Chats;