import { type CartridgeMapping } from '../code/cartridges.js'; /** * Options for creating a path normalizer. */ export interface PathNormalizerOptions { /** * Local path to the cartridges directory (simple mode). * All cartridge references will be prefixed with this path. * @example "./cartridges" or "/Users/dev/project/cartridges" */ cartridgePath?: string; /** * Discovered cartridge mappings (precise mode). * Each cartridge is mapped to its actual local path. * Takes precedence over cartridgePath for known cartridges. */ cartridges?: CartridgeMapping[]; } /** * Creates a path normalizer function for converting remote cartridge paths * to local paths in log messages. * * Supports two modes: * 1. **Cartridge mappings** (precise): Uses discovered cartridges to map each * cartridge name to its actual local path. Best for projects with cartridges * in different locations. * 2. **Cartridge path** (simple): Prefixes all paths with a base directory. * Best when all cartridges are in a single directory. * * @param options - Normalizer options * @returns Function that normalizes paths in a message string, or undefined if no options provided * * @example * ```typescript * // Using discovered cartridges (recommended) * const cartridges = findCartridges('./my-project'); * const normalize = createPathNormalizer({ cartridges }); * * // Using simple cartridge path * const normalize = createPathNormalizer({ cartridgePath: './cartridges' }); * * // Input: "(app_storefront/cartridge/controllers/Home.js:45)" * // Output: "(./cartridges/app_storefront/cartridge/controllers/Home.js:45)" * const normalized = normalize(logMessage); * ``` */ export declare function createPathNormalizer(options: PathNormalizerOptions): ((message: string) => string) | undefined; /** * Discovers cartridges and creates a path normalizer automatically. * * This is a convenience function that combines `findCartridges` with * `createPathNormalizer` for easy setup. Cartridge paths are converted * to relative paths from the current project directory. * * @param directory - Directory to search for cartridges (defaults to cwd) * @returns Path normalizer function, or undefined if no cartridges found * * @example * ```typescript * // Auto-discover cartridges from current directory * const normalize = discoverAndCreateNormalizer(); * * // Auto-discover from specific directory * const normalize = discoverAndCreateNormalizer('./my-project'); * ``` */ export declare function discoverAndCreateNormalizer(directory?: string): ((message: string) => string) | undefined; /** * Extracts all cartridge paths from a message. * * Useful for testing or analysis of log messages. * * @param message - Log message to extract paths from * @returns Array of extracted paths * * @example * ```typescript * const paths = extractPaths("Error at (app_storefront/cartridge/controllers/Home.js:45)"); * // Returns: ["app_storefront/cartridge/controllers/Home.js:45"] * ``` */ export declare function extractPaths(message: string): string[];