UNPKG

@stack.thefennec.dev/telegram-export-parser

Version:

TypeScript library for parsing Telegram Desktop's data export with full type safety

86 lines 3.09 kB
/** * @fileoverview TypeScript type definitions for Telegram export parsing. * * This module provides comprehensive type definitions for all Telegram export data, * including messages, events, text formatting, and shared utilities. * * ## Module Organization * * - **shared**: Core types, constants, and utilities used across the library * - **messages**: User message types (text, media, polls, etc.) * - **events**: Service event types (calls, membership changes, etc.) * - **text-entities**: Rich text formatting and entity types * - **raw-export**: Raw Telegram export format types for parsing * * @example Basic Usage * ```typescript * import { TelegramMessage, TelegramEvent, isTextMessage } from './types' * * const processItem = (item: TelegramMessage | TelegramEvent) => { * if (isTextMessage(item)) { * console.log('Text:', item.textEntities.map(e => e.text).join('')) * } * } * ``` * * @example Type Guards * ```typescript * import { isPhotoMessage, isCallEvent, hasReactions } from './types' * * if (isPhotoMessage(message)) { * // TypeScript knows this is PhotoMessage * console.log(`Photo: ${message.width}x${message.height}`) * } * ``` * * @example Constants and Enums * ```typescript * import { MESSAGE_TYPES, MEDIA_TYPES, EVENT_ACTIONS } from './types' * * // Use constants for type checking * if (item.type === MESSAGE_TYPES.SERVICE) { * // Handle service event * } * ``` */ /** * Core types, constants, and utilities shared across all message and event types. * * Exports: Actor, Reaction, Conversation, TelegramChatExport, type guards, * and fundamental constants like MESSAGE_TYPES, MEDIA_TYPES, etc. */ export * from './shared'; /** * Type definitions for user-generated messages including text, media, * locations, contacts, polls, games, and payment invoices. * * Exports: TelegramMessage union type, specific message interfaces * (TextMessage, PhotoMessage, VideoMessage, etc.), and message type guards. */ export * from './messages'; /** * Type definitions for system-generated service events like calls, * membership changes, group modifications, and other chat actions. * * Exports: TelegramEvent union type, specific event interfaces * (CallEvent, MembershipEvent, etc.), EVENT_ACTIONS constants, and event type guards. */ export * from './events'; /** * Type definitions for rich text formatting entities including bold, italic, * links, mentions, hashtags, and other text styling elements. * * Exports: TextEntity union type, specific entity interfaces, and text * rendering methods for Markdown/HTML conversion. */ export * from './text-entities'; /** * Type definitions for the raw Telegram export JSON format as exported * by Telegram Desktop. Used internally by parsers to transform raw data * into structured, typed objects. * * Exports: Raw message interfaces, export structure types, and parsing utilities. * These are primarily for internal use but available for advanced parsing scenarios. */ export * from './raw-export'; //# sourceMappingURL=index.d.ts.map