import { z } from "zod"; export interface SettingsUtils { /** * Safely parses a JSON string and validates the result against a Zod schema. * Returns the validated value when parsing and validation succeed, otherwise `null`. * The return type is inferred from the schema — no type assertions needed. * * @param jsonString - The JSON string to parse, or `null`. * @param schema - A Zod schema that describes the expected shape of the parsed value. * @example * ```ts * const result = safeParse('{"name":"Ada"}', z.object({ name: z.string() })); * // result: { name: "Ada" } * * const num = safeParse("42", z.number()); * // num: 42 * * const miss = safeParse('{"a":1}', z.object({ b: z.string() })); * // miss: null * ``` */ safeParse: (jsonString: string | null, schema: z.ZodType) => TValue | null; /** * Checks whether a string is valid, non-null JSON. * * Returns `false` for the JSON literal `"null"` to match the legacy behaviour * where `JSON.parse(str) !== null` was required. * * @param jsonString - The string to test. * @returns `true` when the string can be parsed as non-null JSON. */ isJSON: (jsonString: string) => boolean; /** * Safely converts a value to a JSON string using a Zod validation pipeline. * * - Returns the value unchanged if it is already a string. * - Returns `null` for `null` / `undefined` or if serialisation fails * (e.g. circular references). * * @param value - The value to stringify. * @returns The JSON string representation, or `null` on failure. * @example * ```ts * safeStringify({ a: 1 }) // '{"a":1}' * safeStringify("hello") // "hello" * safeStringify(null) // null * ``` */ safeStringify: (value: unknown) => string | null; } /** * Hook providing safe JSON parsing and stringification utilities with Zod validation. * * Returns stable callbacks for: * - `safeParse` - Parse JSON and validate against a schema * - `isJSON` - Check if a string is valid JSON * - `safeStringify` - Convert a value to JSON string * * @example * ```ts * const { safeParse, safeStringify, isJSON } = useSettingsUtils(); * * const data = safeParse(rawJson, mySchema); * const json = safeStringify(myObject); * const valid = isJSON(someString); * ``` */ export declare const useSettingsUtils: () => SettingsUtils;