/** * JSONPath Helper Functions * * Simple JSONPath implementation for extracting values from objects. * Supports basic JSONPath expressions like $.field, $.nested.field, $.array[0].field * Also supports wildcard [*] notation for extracting all array elements. */ import type { Logger } from './types.js'; /** * Validate a JSONPath expression (without wildcards) * Supports: $.field, $.nested.field, $.array[0], $.array[0].field * * @param path - JSONPath expression to validate * @returns true if valid, false otherwise * * @example * ```typescript * is_valid_jsonpath('$.document_type'); // true * is_valid_jsonpath('$.data.nested.value'); // true * is_valid_jsonpath('$.items[0].name'); // true * is_valid_jsonpath('document_type'); // false (missing $.) * is_valid_jsonpath('$document_type'); // false (missing .) * is_valid_jsonpath('$.items[*].name'); // false (use is_valid_jsonpath_with_wildcards) * ``` */ export declare function is_valid_jsonpath(path: string): boolean; /** * Validate a JSONPath expression that may contain wildcards [*] * Supports: $.field, $.nested.field, $.array[*], $.array[*].field * * @param path - JSONPath expression to validate * @returns true if valid, false otherwise * * @example * ```typescript * is_valid_jsonpath_with_wildcards('$.items[*].name'); // true * is_valid_jsonpath_with_wildcards('$.types[*]'); // true * is_valid_jsonpath_with_wildcards('$.document_type'); // true (also valid without wildcards) * ``` */ export declare function is_valid_jsonpath_with_wildcards(path: string): boolean; /** * Check if a JSONPath expression contains wildcard [*] notation * * @param path - JSONPath expression to check * @returns true if path contains [*], false otherwise * * @example * ```typescript * has_wildcard_notation('$.items[*].name'); // true * has_wildcard_notation('$.items[0].name'); // false * has_wildcard_notation('$.document_type'); // false * ``` */ export declare function has_wildcard_notation(path: string): boolean; /** * Extract a value from an object using JSONPath expression * Does NOT support wildcard [*] notation - use extract_jsonpath_values instead * * @param obj - The object to extract from * @param path - JSONPath expression (e.g., "$.document_type", "$.data.nested") * @param logger - Logger instance for debugging * @returns The extracted value as string, or null if not found * * @example * ```typescript * const obj = { document_type: 'invoice', data: { total: 100 } }; * * extract_jsonpath_value(obj, '$.document_type', logger); * // Returns: 'invoice' * * extract_jsonpath_value(obj, '$.data.total', logger); * // Returns: '100' * * extract_jsonpath_value(obj, '$.missing', logger); * // Returns: null * ``` */ export declare function extract_jsonpath_value(obj: Record, path: string, logger: Logger): string | null; /** * Extract ALL matching values from an object using JSONPath with wildcard [*] support * Returns an array of string values for all matched paths. * * @param obj - The object to extract from * @param path - JSONPath expression (e.g., "$.items[*].name", "$.types[*]") * @param logger - Logger instance for debugging * @returns Array of extracted values as strings (empty array if no matches) * * @example * ```typescript * const obj = { * document_types: [ * { name: 'invoice' }, * { name: 'receipt' } * ] * }; * * extract_jsonpath_values(obj, '$.document_types[*].name', logger); * // Returns: ['invoice', 'receipt'] * * extract_jsonpath_values(obj, '$.missing[*]', logger); * // Returns: [] * * // Also works without wildcards (returns single-element array) * extract_jsonpath_values(obj, '$.document_types[0].name', logger); * // Returns: ['invoice'] * ``` */ export declare function extract_jsonpath_values(obj: Record, path: string, logger: Logger): string[]; /** * Extract a raw value from an object using JSONPath expression * Unlike extract_jsonpath_value, this returns the actual value without string conversion * Does NOT support wildcard [*] notation * * @param obj - The object to extract from * @param path - JSONPath expression * @param logger - Logger instance * @returns The extracted value (any type), or undefined if not found */ export declare function extract_jsonpath_raw(obj: Record, path: string, logger: Logger): unknown; //# sourceMappingURL=jsonpath_helper.d.ts.map