/** * A pre-compiled stringify function. * * Generated at boot or on first use from a Zod schema. * Accepts any object and returns a JSON string (minified). * * @example * ```typescript * const stringify = serializer.compile(myZodSchema); * const json = stringify({ id: 1, name: 'Alice' }); * // '{"id":1,"name":"Alice"}' * ``` */ export type StringifyFn = (doc: unknown) => string; /** * AOT JSON serialization engine. * * Compiles Zod schemas into fast stringify functions at boot time * or lazily on first use. Maintains a per-schema cache to avoid * recompilation. */ export interface JsonSerializer { /** * Compile a Zod schema into a fast stringify function. * * Returns `undefined` if `fast-json-stringify` is not available * or if compilation fails (defensive fallback). * * @param schema - Any Zod schema (ZodObject, ZodArray, etc.) * @returns A compiled stringify function, or `undefined` */ compile(schema: unknown): StringifyFn | undefined; /** * Stringify data using a compiled function or native fallback. * * @param data - The data to serialize * @param compiled - Optional pre-compiled stringify function * @returns JSON string */ stringify(data: unknown, compiled?: StringifyFn): string; } /** * Create an AOT JSON serializer. * * The serializer lazy-loads `fast-json-stringify` and provides * compile/stringify methods with automatic fallback. * * @example * ```typescript * const serializer = createSerializer(); * await serializer.init(); // optional: pre-load the fjs module * * const stringify = serializer.compile(myZodSchema); * if (stringify) { * const json = stringify(data); // 2-5x faster * } * ``` */ export declare function createSerializer(): JsonSerializer & { init(): Promise; }; /** * Global singleton serializer. * * Shared across the engine so all Presenters and response helpers * use the same cache and fjs module reference. */ export declare const defaultSerializer: JsonSerializer & { init(): Promise; }; //# sourceMappingURL=JsonSerializer.d.ts.map