import type { WASocket } from '@whiskeysockets/baileys'; import type { CacheConfig, Logger, MigrationPolicyConfig, MongoClient } from '../../types/index.js'; import { AuthCreds, AuthKeys, Chats, Contacts, GroupsMetadata, JidMappings, MessageArchive, Migrations, Messages, PPs, Presence, State } from './handlers/index.js'; import type { ResolvedJid } from './handlers/JidMappings.js'; declare class MongoStorage { readonly sessionId: string; private readonly mongo; private readonly logger; private readonly cacheConfigs; private isRegistered; ready: Promise; private readonly migrationsConfig; private iAuthCreds; private iAuthKeys; private iChats; private iContacts; private iGroupsMetadata; private iJidMappings; private iMessageArchive; private iMigrations; private iMessages; private iPPs; private iPresence; private iState; constructor(sessionId: string, mongo: MongoClient, logger?: Logger | null, cacheConfigs?: CacheConfig | null, migrationsConfig?: MigrationPolicyConfig | null); private initialize; /** * Ensures that the MongoDB client is connected. * If already connected, it skips the connection process. * @param mongo MongoClient instance */ private ensureMongoConnected; /** * Construct handlers and start listening to the events * * @param ignoreEvents An array of events that won't be listened to */ register(sock?: WASocket | null): void; /** * Dispose handler instances */ private dispose; /** * Remove all event listeners and dispose the handler instances */ stop(): void; /** * Get auth creds handler instance * * @returns AuthCreds handler instance if registered or else return null */ authCreds(): AuthCreds | null; /** * Get auth keys handler instance * * @returns AuthKeys handler instance if registered or else return null */ authKeys(): AuthKeys | null; /** * Get chats handler instance * * @returns Chats handler instance if registered or else return null */ chats(): Chats | null; /** * Get contacts handler instance * * @returns Contacts handler instance if registered or else return null */ contacts(): Contacts | null; /** * Get groups metadata handler instance * * @returns Groups metadata handler instance if registered or else return null */ groupsMetadata(): GroupsMetadata | null; /** * Get JID mappings handler instance * * @returns JID mappings handler instance if registered or else return null */ jidMappings(): JidMappings | null; /** * Get message archive handler instance * * @returns Message Archive handler instance if registered or else return null */ messageArchive(): MessageArchive | null; /** * Get migrations handler instance * * @returns Migrations handler instance if registered or else return null */ migrations(): Migrations | null; /** * Get messages handler instance * * @returns Messages handler instance if registered or else return null */ messages(): Messages | null; /** * Get pps handler instance * * @returns PPs handler instance if registered or else return null */ pps(): PPs | null; /** * Get presence handler instance * * @returns Presence handler instance if registered or else return null */ presence(): Presence | null; /** * Get state handler instance * * @returns State handler instance if registered or else return null */ state(): State | null; reconcileMappingAliases(mapping: ResolvedJid): Promise; private globalMigrationsCollection; private discoverLegacySessionIdsForFrozenCohort; private getOrFreezeLegacyCohort; private shouldRunLegacyBackfill; /** * One-time migration that merges historical PN/LID split data into canonical LID records. * The migration is idempotent and tracked in the `migrations` collection. */ runPnLidBackfillIfNeeded(options?: { force?: boolean; }): Promise; /** * Gracefully shut down storage without deleting data. * Cleans up handlers and closes the MongoDB connection. */ graceful(): Promise; /** * Permanently deletes all related collections from MongoDB */ destroy(): Promise; } export default MongoStorage;