import type { MongoStorage } from '../index.js'; import type { CacheConfig, Logger } from '../../../types/index.js'; import type { Contact, WASocket } from '@whiskeysockets/baileys'; import CRUD from './CRUD.js'; import type { Db, ObjectId, WithId } from './CRUD.js'; type ContactAliasMeta = { canonicalJid?: string; lid?: string; pn?: string; aliasJids?: string[]; _dirty?: boolean; }; type ContactsDoc = Contact & ContactAliasMeta & { _id: string | ObjectId; }; declare class Contacts 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['contacts'] | null); private indexes; private getCachedContacts; private setCachedContacts; private markAsDirty; private resolveContactIdentity; private normalizeContact; /** * Getter to expose the raw MongoDB collection. */ getCollection(): import("mongodb").Collection; /** * Retrieve contacts. * - If `id` is provided, returns the contact doc for that specific ID or `null` if not found. * - If `id` is not provided, returns an array of all contact docs. * * @param id Contact jid (Optional) */ get(id: string | undefined): Promise | null>; get(): Promise[]>; /** * Set multiple contacts (upsert). */ set({ contacts }: { contacts: Contact[]; }): Promise; /** * Upsert contacts. * If the doc for the given contact id doesn't exist, create it. * Otherwise, update the existing doc by adding or updating the contact key. */ upsert(contacts: Contact[]): Promise; update(updates: Partial[]): Promise; } export default Contacts;