import { LinkedDirectMessage, DirectMessageEventContainer, GDPRConversation } from "../types/GDPRDMs"; /** Register the number of messages in each year, month and day, and let you access those messages. */ interface ConversationIndex { count: number; years: { [year: string]: { count: number; months: { [months: string]: { count: number; days: { [day: string]: { count: number; messages: LinkedDirectMessage[]; }; }; }; }; }; }; } interface DirectMessageIndex { [id: string]: LinkedDirectMessage; } interface DirectMessageDateIndex { [year: string]: { [month: string]: { [day: string]: DirectMessageIndex; }; }; } interface ConversationInfo { participants: Set; me: string; } interface FullConversationInfo extends ConversationInfo { id: string; } declare abstract class ConversationBase { /** Handle infomations of this conversation like owner and participants. */ protected info: ConversationInfo; protected _length: number; protected _index: DirectMessageIndex; protected _index_by_date: DirectMessageDateIndex; protected _all: LinkedDirectMessage[]; protected register(msg: LinkedDirectMessage): void; protected unregisterAll(): void; /** Get direct messages from a specific month. */ month(month: string | number, year: string | number): SubConversation; /** Find direct messages that matches a query on their text. */ find(query: RegExp): SubConversation; /** Find context around a single direct message. */ around(id: string, context?: number): { before: LinkedDirectMessage[]; current: LinkedDirectMessage; after: LinkedDirectMessage[]; }; /** Get all messages recived or sended by a specific user (by ID) */ from(id: string): SubConversation; /** Get all messages recived or sended by a pool of users (by ID) */ from(ids: Iterable): SubConversation; /** Get all messages sended by a specific user (by ID) */ sender(id: string): SubConversation; /** Get all messages sended by a pool of users (by ID) */ sender(ids: Iterable): SubConversation; /** Get all messages received by a specific user (by ID) */ recipient(id: string): SubConversation; /** Get all messages received by a pool of users (by ID) */ recipient(ids: Iterable): SubConversation; /** Get all the direct messages between two dates. */ between(since: Date, until: Date): SubConversation; /** Get all the direct messages between two specific messages (ids). */ between(since_id: string, until_id: string): SubConversation; protected betweenIds(id1: string, id2: string): SubConversation; /** Retreives a single message (undefined if message does not exists). */ single(id: string): LinkedDirectMessage; /** Check if message {id} exists in this conversation. */ has(id: string): boolean; /** * Get conversation from a specific day (default to current day) * * @param day The day to search in. Can be a `Date` or a `string`-ified date. * If this param is not specified, {day} will be coerced to today. */ day(day?: Date | string): SubConversation; /** * Get conversation of the same day as {day}, but also in previous years. * * {day} can be omitted (refers to today), be a `Date` object, or be a `string`-ified date. */ fromThatDay(day?: Date | string): SubConversation; /** Iterates all over the direct messages stored in this conversation. */ [Symbol.iterator](): Generator; /** Participants IDs */ get participants(): Set; /** * Participants IDs, but without yourself. * If .size > 1, conversation is a group conversation */ get real_participants(): Set; /** True if this conversation is a group conversation. */ get is_group_conversation(): boolean; /** All the messages in this conversation */ get all(): LinkedDirectMessage[]; /** Count of total messages, messages per year, month, day, plus the messages themselves. */ get index(): ConversationIndex; protected get index_by_date(): DirectMessageDateIndex; /** Messages sorted by year, month and day, without any other informations */ get raw_index(): DirectMessageDateIndex; /** Map message IDs to messages objets. */ get id_index(): DirectMessageIndex; /** Number of messages in this conversation */ get length(): number; get infos(): ConversationInfo; /** First DM in this conversation. Access to next messages with LinkedDirectMessage.next */ get first(): LinkedDirectMessage; /** Last DM in this conversation. Access to previous messages with LinkedDirectMessage.previous */ get last(): LinkedDirectMessage; /** * Get all the events related to this conversation, sorted by date, from oldest to newest. * * By default, this does not include messages, only other events, like conversation join or * name change. * * To include messages, use `true` as first parameter. */ events(include_messages?: boolean): Generator; } /** * Conversation between the owner of archive and one or more participants. */ export declare class Conversation extends ConversationBase { protected info: FullConversationInfo; protected unindexed: DirectMessageEventContainer[]; /** Quick access to first and last DMs */ protected _first: LinkedDirectMessage; protected _last: LinkedDirectMessage; protected _names: string[]; /** * Create a new Conversation instance, from raw GDPR conversation. * Need self user_id to recognize which user is you. * * Note that **.add()** is automatically call with the given conversation. */ constructor(conv: GDPRConversation, me_id: string); /** * Add a new conversation part to actual conversation. * Actual conversation and new part must have the same ID. * * After you've imported all parts, you **must** call **.indexate()** to see messages ! */ add(conv: GDPRConversation): void; /** `true` if a conversation is indexed. If `false`, a call to `.indexate()` is required. */ get indexed(): boolean; /** * Index imported messages. * Needed to see all DMs. * * Should be call after you've imported all with **.add()**. */ indexate(): void; /** Conversation ID */ get id(): string; get first(): LinkedDirectMessage; get last(): LinkedDirectMessage; /** Conversation custom name, if somebody has set it. Could be `undefined`. */ get name(): string; /** All the custom names given to this conversation. */ get names(): string[]; } /** * A big conversation that contains every message. * * Every message will be linked to its original conversation through the `.conversation` property. */ export declare class GlobalConversation extends ConversationBase { constructor(convs: Conversation[]); } /** Part of a real conversation that have its own index and message count. */ export declare class SubConversation extends ConversationBase { constructor(messages: LinkedDirectMessage[], me_id: string); } export default Conversation;