/** * Utility functions for parsing and matching RabbitMQ style routing keys. * Supports wildcard patterns used in topic exchanges. * * RabbitMQ routing key patterns: * - * (asterisk) matches exactly one word * - # (hash) matches zero or more words * - Words are separated by dots (.) * * @example * ```typescript * import { matchesRoutingPattern } from './util/routing'; * * matchesRoutingPattern('user.created', 'user.*'); // true * matchesRoutingPattern('user.profile.updated', 'user.#'); // true * ``` */ /** * Converts a RabbitMQ routing pattern to a regular expression * * @param {string} pattern - The routing pattern with wildcards * @returns {RegExp} Regular expression that matches the pattern * * @example * ```typescript * const regex = patternToRegex('user.*.created'); * regex.test('user.profile.created'); // true * regex.test('user.account.created'); // true * regex.test('user.created'); // false (missing middle word) * ``` */ export declare function patternToRegex(pattern: string): RegExp; /** * Checks if a routing key matches a RabbitMQ routing pattern * * @param {string} routingKey - The actual routing key to test * @param {string} pattern - The pattern to match against (may contain * and #) * @returns {boolean} True if the routing key matches the pattern * * @example * ```typescript * matchesRoutingPattern('user.123.created', 'user.*.created'); // true * matchesRoutingPattern('user.profile.photo.updated', 'user.#.updated'); // true * matchesRoutingPattern('order.cancelled', 'user.*'); // false * ``` */ export declare function matchesRoutingPattern(routingKey: string, pattern: string): boolean; /** * Finds all patterns that match a given routing key * * @param {string} routingKey - The routing key to match * @param {string[]} patterns - Array of patterns to test against * @returns {string[]} Array of matching patterns * * @example * ```typescript * const patterns = ['user.*', 'user.#', '*.created', '#']; * findMatchingPatterns('user.created', patterns); * // Returns: ['user.*', 'user.#', '*.created', '#'] * ``` */ export declare function findMatchingPatterns(routingKey: string, patterns: string[]): string[]; /** * Splits a routing key into its component words * * @param {string} routingKey - The routing key to split * @returns {string[]} Array of words from the routing key * * @example * ```typescript * parseRoutingKey('user.profile.updated'); * // Returns: ['user', 'profile', 'updated'] * ``` */ export declare function parseRoutingKey(routingKey: string): string[]; /** * Validates if a routing key follows RabbitMQ conventions * * @param {string} routingKey - The routing key to validate * @returns {boolean} True if the routing key is valid * * @example * ```typescript * isValidRoutingKey('user.created'); // true * isValidRoutingKey('user..created'); // false (empty segment) * isValidRoutingKey('.user.created'); // false (starts with dot) * ``` */ export declare function isValidRoutingKey(routingKey: string): boolean; /** * Creates a routing key from an array of words * * @param {string[]} words - Array of words to join * @returns {string} The constructed routing key * * @example * ```typescript * buildRoutingKey(['user', 'profile', 'updated']); * // Returns: 'user.profile.updated' * ``` */ export declare function buildRoutingKey(words: string[]): string;