UNPKG

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

Version:

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

117 lines 4.63 kB
"use strict"; /** * @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 * } * ``` */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); // ===================================================== // SHARED TYPES & UTILITIES // ===================================================== /** * 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. */ __exportStar(require("./shared"), exports); // ===================================================== // USER MESSAGE TYPES // ===================================================== /** * 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. */ __exportStar(require("./messages"), exports); // ===================================================== // SERVICE EVENT TYPES // ===================================================== /** * 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. */ __exportStar(require("./events"), exports); // ===================================================== // TEXT FORMATTING TYPES // ===================================================== /** * 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. */ __exportStar(require("./text-entities"), exports); // ===================================================== // RAW EXPORT FORMAT TYPES // ===================================================== /** * 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. */ __exportStar(require("./raw-export"), exports); //# sourceMappingURL=index.js.map