import { z } from "@hono/zod-openapi"; //#region src/utils/jmespath-utils.d.ts /** * Result of validating a JMESPath expression or regex pattern. */ interface ValidationResult { valid: boolean; error?: string; } /** * Maximum allowed length for JMESPath expressions. */ declare const MAX_EXPRESSION_LENGTH = 1000; /** * Validates a JMESPath expression by attempting to compile it. * Uses the jmespath package which is already available in the codebase. * * @param expression - The JMESPath expression to validate * @returns ValidationResult with valid flag and optional error message * * @example * ```typescript * const result = validateJMESPath('body.user.id'); * if (!result.valid) { * console.error(result.error); * } * ``` */ declare function validateJMESPath(expression: string): ValidationResult; /** * Validates a regex pattern by attempting to construct a RegExp object. * Returns clear error messages for common regex issues. * * @param pattern - The regex pattern to validate (without delimiters) * @returns ValidationResult with valid flag and optional error message * * @example * ```typescript * const result = validateRegex('v\\d+,(.+)'); * if (!result.valid) { * console.error(result.error); * } * ``` */ declare function validateRegex(pattern: string): ValidationResult; /** * Compiles a JMESPath expression. * Wrapper around jmespath.compile() with proper typing. * * @param expression - The JMESPath expression to compile * @returns The compiled expression object * @throws Error if the expression is invalid */ declare function compileJMESPath(expression: string): unknown; /** * Safely searches data using a JMESPath expression. * Wrapper around jmespath.search() with proper typing. * * @param data - The object to search (e.g., template context, webhook body, tool result) * @param expression - The JMESPath expression * @returns The search result * * @example * ```typescript * const data = { users: [{ name: 'Alice' }] }; * const name = searchJMESPath(data, 'users[0].name'); * // name is 'Alice' * * // Common use cases: * // - Template contexts: { headers: {...}, body: {...} } * // - Webhook payloads: { event: "...", data: {...} } * // - Tool results: { status: "success", result: {...} } * ``` */ declare function searchJMESPath(data: Record, expression: string): T; /** * Normalize a JMESPath expression by wrapping property names with dashes in quotes. * JMESPath requires identifiers with special characters (like dashes) to be quoted. * * @param path - The JMESPath expression to normalize * @returns The normalized JMESPath expression * * @example * ```typescript * normalizeJMESPath('headers.x-tenant-id'); * // Returns: 'headers."x-tenant-id"' * * normalizeJMESPath('api-responses[0].response-code'); * // Returns: '"api-responses"[0]."response-code"' * * normalizeJMESPath('simple.path'); * // Returns: 'simple.path' (unchanged) * ``` */ declare function normalizeJMESPath(path: string): string; /** * Dangerous patterns that should not appear in JMESPath expressions. * These patterns are checked during secure validation to prevent injection attacks. */ declare const DANGEROUS_PATTERNS: RegExp[]; /** * Options for secure JMESPath validation. */ interface SecurityOptions { maxLength?: number; dangerousPatterns?: RegExp[]; } /** * Validates a JMESPath expression with security checks. * Performs checks in order of cost: length (O(1)), patterns (O(n)), compile (expensive). * * @param expression - The JMESPath expression to validate * @param options - Optional security options * @returns ValidationResult with valid flag and optional error message * * @example * ```typescript * const result = validateJMESPathSecure('body.user.id'); * if (!result.valid) { * console.error(result.error); * } * * // With custom options * const result2 = validateJMESPathSecure('expression', { maxLength: 500 }); * ``` */ declare function validateJMESPathSecure(expression: string, options?: SecurityOptions): ValidationResult; /** * Options for jmespathString Zod schema factory. */ interface JMESPathStringOptions { maxLength?: number; } /** * Creates a Zod string schema for JMESPath expressions with OpenAPI-visible constraints. * Includes maxLength constraint and a description with valid/invalid examples. * * @param options - Optional configuration for the schema * @returns A Zod string schema with maxLength and description * * @example * ```typescript * const schema = z.object({ * transform: jmespathString().optional(), * }); * ``` */ declare function jmespathString(options?: JMESPathStringOptions): z.ZodString; //#endregion export { DANGEROUS_PATTERNS, JMESPathStringOptions, MAX_EXPRESSION_LENGTH, SecurityOptions, ValidationResult, compileJMESPath, jmespathString, normalizeJMESPath, searchJMESPath, validateJMESPath, validateJMESPathSecure, validateRegex };