type TRuleType = "string" | "number" | "boolean" | "object" | "array"; type TRulesSchema, TOutput extends Record> = { [K in keyof TInput]?: { output?: keyof TOutput | string; type?: TRuleType; fallback?: unknown; getValue?: (value: TInput[K], fallback: unknown) => unknown; }; }; export type TGetObjWithFallbacksArgs = Parameters; export type TGetObjWithFallbacksReturn = ReturnType; /** * Gets an object with fixed keys and values * @template TInput,TOutput * @param {TInput} data Source data * @param {TRulesSchema} [rules={}] Rules for transformation * @param {Partial>} [fallbacks={}] Fallback for each type of values * @returns {TOutput & Partial} Transformed object * @throws {TypeError} getObjWithFallbacks: data must be a plain object * @throws {TypeError} getObjWithFallbacks: rules must be a plain object * @throws {TypeError} getObjWithFallbacks: rules validation failed * @example * // Normalize incomplete API data before rendering a user card * const user = getObjWithFallbacks( * { name: "", age: undefined }, * { * name: { type: "string", fallback: "Anonymous" }, * age: { type: "number", fallback: 0 }, * } * ); // { name: "Anonymous", age: 0 } * @example * // Rename an API field and provide a global fallback for missing strings * const product = getObjWithFallbacks( * { product_name: null }, * { product_name: { output: "name", type: "string" } }, * { string: "Untitled product" } * ); // { name: "Untitled product" } */ export declare const getObjWithFallbacks: , TOutput extends Record = Record>(data: TInput, rules?: TRulesSchema, fallbacks?: Partial>) => TOutput & Partial; export {};