UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

134 lines (133 loc) 4.01 kB
/** * Plain Text File Processor * * Processes plain text files (.txt, .text, .log) with line and word counting, * encoding detection, and automatic truncation for large files. * * Priority: 110 (lower priority - catch-all for text files) * * @module processors/markup/TextProcessor * * @example * ```typescript * import { textProcessor, processText, isTextFile } from "./markup/TextProcessor.js"; * * // Check if file is a plain text file * if (isTextFile(mimetype, filename)) { * const result = await processText(fileInfo); * if (result.success) { * console.log('Content:', result.data.content); * console.log('Lines:', result.data.lineCount); * console.log('Words:', result.data.wordCount); * if (result.data.truncated) { * console.warn('File was truncated due to size'); * } * } * } * ``` */ import { BaseFileProcessor } from "../base/BaseFileProcessor.js"; import type { FileInfo, ProcessorFileProcessingResult, ProcessOptions, ProcessedText } from "../../types/index.js"; /** * Text Processor - handles plain text files. * * Features: * - Line and word counting * - Automatic truncation for large files * - UTF-8 encoding support * * Priority: 110 (lower priority - catch-all for text files) * * @example * ```typescript * const processor = new TextProcessor(); * * const result = await processor.processFile({ * id: 'txt-123', * name: 'readme.txt', * mimetype: 'text/plain', * size: 1024, * url: 'https://example.com/readme.txt', * }); * * if (result.success) { * console.log('Content:', result.data.content); * console.log('Lines:', result.data.lineCount); * } * ``` */ export declare class TextProcessor extends BaseFileProcessor<ProcessedText> { constructor(); /** * Build processed text result with content analysis. * Counts lines and words, and truncates if necessary. * * @param buffer - Downloaded file content * @param fileInfo - Original file information * @returns Processed text result with content analysis */ protected buildProcessedResult(buffer: Buffer, fileInfo: FileInfo): ProcessedText; } /** * Singleton text processor instance. * Use this for most processing needs. * * @example * ```typescript * import { textProcessor } from "./markup/TextProcessor.js"; * * const result = await textProcessor.processFile(fileInfo); * ``` */ export declare const textProcessor: TextProcessor; /** * Check if a file is a plain text file. * * @param mimetype - MIME type of the file * @param filename - Filename (for extension-based detection) * @returns true if the file is a plain text file * * @example * ```typescript * if (isTextFile('text/plain', 'readme.txt')) { * // Handle as plain text * } * * // Also works with just filename * if (isTextFile('', 'debug.log')) { * // Handle as text based on extension * } * ``` */ export declare function isTextFile(mimetype: string, filename: string): boolean; /** * Process a single plain text file. * Convenience function that uses the singleton processor. * * @param fileInfo - File information (can include URL or buffer) * @param options - Optional processing options (auth headers, timeout, retry config) * @returns Processing result with text content and analysis * * @example * ```typescript * const result = await processText({ * id: 'txt-123', * name: 'notes.txt', * mimetype: 'text/plain', * size: 2048, * buffer: textBuffer, * }); * * if (result.success) { * console.log('Content:', result.data.content); * console.log('Lines:', result.data.lineCount); * console.log('Words:', result.data.wordCount); * if (result.data.truncated) { * console.warn('Content was truncated'); * } * } else { * console.error('Processing failed:', result.error.userMessage); * } * ``` */ export declare function processText(fileInfo: FileInfo, options?: ProcessOptions): Promise<ProcessorFileProcessingResult<ProcessedText>>;