import { b as DocumentFormat, E as ExtractOptions, D as DiscoveredDocument, a as DiscoveredPdf, I as IndexDocumentsOptions, d as IndexedDocument, c as IndexPdfsOptions, e as IndexedPdf, U as UrlOrEntry } from './types-DZE2UBNA.js'; /** * Reduce a URL to `protocol//host`, scrubbed. Used in failure logs so * we don't disclose path / query / fragment in error output. Falls * back to `[invalid-url]` for non-URL strings. */ declare function scrubUrl(url: string): string; interface ExtractedMetadata { pages: number; format?: DocumentFormat; infoTitle?: string; } /** * Infer the document format from a URL by extension. Returns `null` if * the URL doesn't end in a recognized document extension. Case-insensitive. * Added in 1.1. */ declare function detectFormatFromUrl(url: string): DocumentFormat | null; /** * Detect the document family (PDF vs ZIP-based Office) from the leading * bytes. Returns `'pdf'`, `'office'`, or `null` if the bytes match neither * signature. Added in 1.1 as a defense against format-mismatch attacks * (e.g., a `.pdf` URL serving DOCX bytes). * * Note: this distinguishes PDF from Office but NOT between docx/pptx/xlsx * (all three share the ZIP magic). The URL extension is used to * discriminate within the Office family; `officeparser` itself will fail * if the ZIP contents don't match the declared sub-format. */ declare function detectFormatFamilyFromBytes(bytes: Uint8Array): 'pdf' | 'office' | null; /** * Return a redacted form of a URL safe for logging in CI: origin only, * path / query / fragment dropped. Internal infrastructure (path, * query-string secrets) doesn't leak into public CI logs. * * Control characters in the host are replaced with `?` so an attacker * can't smuggle terminal escapes / CRLF into log output. */ /** * Categorize a parse error message into a short tag. The full message is * suppressed in CI logs because it can disclose details about the * document (e.g. PasswordException tells the attacker the URL is * encrypted). * * The `format` parameter (added in 1.1) selects format-appropriate * categories. Defaults to `'pdf'` for back-compat with 1.0.x callers. */ declare function categorizeParseError(msg: string, format?: DocumentFormat): string; interface ExtractResult { text: string; source: 'cache' | 'fresh' | 'failed'; /** Document format. Added in 1.1; undefined for cache hits written by 1.0.x. */ format?: DocumentFormat; pages?: number; infoTitle?: string; } declare function extractPdfText(url: string, options?: ExtractOptions): Promise; declare function extractPdfMetadata(url: string, options?: ExtractOptions): Promise; /** * Extract text from a document URL with cache-source attribution. * Auto-detects the format from the URL extension (`.pdf`/`.docx`/ * `.pptx`/`.xlsx`), with `options.format` as an override and a final * fallback to PDF for unrecognized URLs. Added in 1.1. */ declare function extractDocumentTextWithSource(url: string, options?: ExtractOptions): Promise; /** * Extract text from a document URL (PDF / DOCX / PPTX / XLSX). * Auto-detects format. Added in 1.1. */ declare function extractDocumentText(url: string, options?: ExtractOptions): Promise; /** * Extract structural metadata (pages / slides / sheets, info-dict title * if PDF) without committing to a text payload. Auto-detects format. * Added in 1.1. */ declare function extractDocumentMetadata(url: string, options?: ExtractOptions): Promise; /** * Scan a markdown body for PDF URLs (1.0.x-compatible). Returns * `{ url, title }` entries only — no `format` field — exactly as 1.0.x * did. Filters out non-PDF discoveries that the underlying multi-format * scanner picks up. For new code that wants all document formats, * prefer `extractDocumentUrlsFromMarkdown`. */ declare function extractPdfUrlsFromMarkdown(body: string): DiscoveredPdf[]; /** * Scan a markdown body for document URLs (PDF, DOCX, PPTX, XLSX). Each * discovered URL is returned with its inferred format set on the * `format` field. Added in 1.1. */ declare function extractDocumentUrlsFromMarkdown(body: string): DiscoveredDocument[]; /** * Derive a human-readable title from a document URL by stripping the * extension, converting separators to spaces, and title-casing. Works * for PDF, DOCX, PPTX, XLSX URLs. * * Examples: * `https://example.com/annual-report-2024.pdf` → `Annual Report 2024` * `https://example.com/meeting-agenda.docx` → `Meeting Agenda` */ declare function titleFromUrl(url: string): string; declare function safeJSONForHTML(obj: unknown, indent?: number): string; /** * Index a list of PDF URLs into searchable rows. Hardcoded to PDF * parsing regardless of URL extension — preserves 1.0.x behavior. For * mixed-format URL lists (PDF + DOCX + PPTX + XLSX), use * `indexDocuments` (added in 1.1) instead. */ declare function indexPdfs(urls: UrlOrEntry[], options?: IndexPdfsOptions): Promise; /** * Index a list of document URLs (PDF, DOCX, PPTX, XLSX) into searchable * rows. Auto-detects each URL's format from its extension and routes to * the appropriate extractor. Added in 1.1. * * URLs without a recognizable extension fall back to PDF parsing for * back-compat with 1.0.x. Pass `options.format` to override per-call. */ declare function indexDocuments(urls: UrlOrEntry[], options?: IndexDocumentsOptions): Promise; /** * Scan a markdown body for PDF URLs and index each. Hardcoded to PDF * parsing — preserves 1.0.x behavior. For multi-format scanning, use * `extractDocumentsFromBody` (added in 1.1). */ declare function extractPdfsFromBody(body: string, options?: IndexPdfsOptions): Promise; /** * Scan a markdown body for document URLs (PDF, DOCX, PPTX, XLSX) and * index each. Linked URLs use the link text as the title; bare URLs use * the info-dict (PDF) or a humanized filename. Added in 1.1. */ declare function extractDocumentsFromBody(body: string, options?: IndexDocumentsOptions): Promise; export { DiscoveredDocument, DiscoveredPdf, DocumentFormat, ExtractOptions, IndexDocumentsOptions, IndexPdfsOptions, IndexedDocument, IndexedPdf, UrlOrEntry, categorizeParseError, detectFormatFamilyFromBytes, detectFormatFromUrl, extractDocumentMetadata, extractDocumentText, extractDocumentTextWithSource, extractDocumentUrlsFromMarkdown, extractDocumentsFromBody, extractPdfMetadata, extractPdfText, extractPdfUrlsFromMarkdown, extractPdfsFromBody, indexDocuments, indexPdfs, safeJSONForHTML, scrubUrl, titleFromUrl };