/** * Pattern Matching Utilities * * Convert glob patterns to regex for key matching. * Includes ReDoS protection to prevent denial-of-service attacks. */ /** * Convert a glob pattern to a RegExp. * * Supports: * - `*` matches any sequence of characters (including empty) * - `?` matches exactly one character * * @param pattern - Glob pattern (e.g., "user:*:profile") * @returns RegExp for matching keys * @throws StoragePatternError if pattern is invalid or too complex * * @example * ```typescript * const regex = globToRegex('user:*:profile'); * regex.test('user:123:profile'); // true * regex.test('user:abc:profile'); // true * regex.test('user:profile'); // false (missing segment) * * const regex2 = globToRegex('session:???'); * regex2.test('session:abc'); // true * regex2.test('session:ab'); // false (too short) * regex2.test('session:abcd'); // false (too long) * ``` */ export declare function globToRegex(pattern: string): RegExp; /** * Test if a key matches a glob pattern. * * @param key - Key to test * @param pattern - Glob pattern * @returns true if key matches pattern * * @example * ```typescript * matchesPattern('user:123:profile', 'user:*:profile'); // true * matchesPattern('session:abc', 'session:???'); // true * matchesPattern('other:key', 'user:*'); // false * ``` */ export declare function matchesPattern(key: string, pattern: string): boolean; /** * Check if a pattern is valid without throwing. * * @param pattern - Glob pattern to validate * @returns Object with valid flag and optional error message */ export declare function validatePattern(pattern: string): { valid: boolean; error?: string; }; /** * Escape a string for use as a literal in a glob pattern. * Escapes * and ? characters. * * @param literal - String to escape * @returns Escaped string safe for use in patterns * * @example * ```typescript * const id = 'user*123?'; * const pattern = `key:${escapeGlob(id)}:*`; * // pattern = 'key:user\\*123\\?:*' * ``` */ export declare function escapeGlob(literal: string): string;