/** * Represents a nested object structure where each level has a type and value. * The value can be either another NestedObject or any other type. */ export interface NestedObject { /** The type identifier for this level of the object */ type: string; /** The value, which can be another NestedObject or any other type */ value: NestedObject | any; } /** * Result of compiling a nested object to an i18n key structure */ export interface I18nKeyResult { /** The compiled i18n key (e.g., "Module.Identity.InvalidSignature") */ key: string; /** The final value at the end of the nested structure */ value: any; } /** * Compiles a nested object structure into an i18n key and extracts its final value. * * This function recursively traverses a nested object structure, building a dot-separated * key path from the type properties and extracting the final value. * * @param obj - The nested object to compile * @returns An object containing the compiled key and the final value * * @example * ```typescript * const input = { * type: 'Module', * value: { * type: 'Identity', * value: { * type: 'InvalidSignature', * value: 'Invalid signature provided' * } * } * } * * const result = compileToI18nKey(input) * console.log(result.key) // "Module.Identity.InvalidSignature" * console.log(result.value) // "Invalid signature provided" * ``` */ export declare function compileToI18nKey(obj: NestedObject): I18nKeyResult; /** * Retrieves a value from a nested object using a dot-separated key path. * * This function traverses a nested object structure using the provided key path, * validating that each level matches the expected type. * * @param obj - The nested object to search in * @param key - The dot-separated key path (e.g., "Module.Identity.InvalidSignature") * @returns The value found at the end of the key path * @throws {Error} When the key path doesn't match the object structure * * @example * ```typescript * const errorDefinitions = { * type: 'Module', * value: { * type: 'Identity', * value: { * type: 'InvalidSignature', * value: 'Invalid signature provided' * } * } * } * * const value = getValueFromKey(errorDefinitions, 'Module.Identity.InvalidSignature') * console.log(value) // "Invalid signature provided" * ``` */ export declare function getValueFromKey(obj: NestedObject, key: string): any; /** * Creates a nested object structure from a flat key-value mapping. * * This utility function helps build nested object structures from flat data, * which can then be used with the other i18n functions. * * @param key - The dot-separated key path * @param value - The value to store at the end of the path * @returns A nested object structure * * @example * ```typescript * const obj = createNestedObject('Module.Identity.InvalidSignature', 'Invalid signature') * // Results in: * // { * // type: 'Module', * // value: { * // type: 'Identity', * // value: { * // type: 'InvalidSignature', * // value: 'Invalid signature' * // } * // } * // } * ``` */ export declare function createNestedObject(key: string, value: any): NestedObject; /** * Merges multiple nested objects into a single structure. * * This function combines multiple nested object structures, creating a unified * structure that can be used for i18n key compilation. * * @param objects - Array of nested objects to merge * @returns A single merged nested object * * @example * ```typescript * const obj1 = createNestedObject('Module.Identity.InvalidSignature', 'Invalid signature') * const obj2 = createNestedObject('Module.Identity.NotFound', 'Identity not found') * const merged = mergeNestedObjects([obj1, obj2]) * ``` */ export declare function mergeNestedObjects(objects: NestedObject[]): NestedObject; /** * Validates that a nested object structure is properly formed. * * @param obj - The object to validate * @param visited - Set of visited objects to detect circular references * @returns True if the object is valid, false otherwise */ export declare function validateNestedObject(obj: any, visited?: Set): obj is NestedObject;