/** * SelectUtils — Zod Reflection & Shallow Field Filter * * Utilities for the `_select` context window optimization feature. * * - `extractZodKeys()`: Recursively unwraps Zod wrappers (Optional, * Nullable, Default, Effects, Array) to reach the inner ZodObject * and extract its top-level keys. Fails gracefully (returns []) * for schemas without a discoverable shape. * * - `pickFields()`: Shallow (top-level only) field filter. Keeps * only the keys requested by the AI's `_select` parameter. * Nested objects are returned whole — no recursive GraphQL-style * traversal. This resolves 95% of real-world overfetching. * * @module * @internal */ import { type ZodType } from 'zod'; /** * Recursively unwrap a Zod schema to extract the top-level object keys. * * Peels through layers of modifiers (Optional → Nullable → Default → * Effects → Array) until it finds a ZodObject, then returns * `Object.keys(shape)`. * * Returns `[]` for schemas that don't resolve to an object shape * (e.g. `z.string()`, `z.any()`, `z.record()`), which gracefully * disables `_select` injection for that Presenter. * * @param schema - Any Zod schema (ZodType) * @returns Array of top-level key names, or `[]` if not extractable * * @example * ```typescript * extractZodKeys(z.object({ id: z.string(), name: z.string() })) * // → ['id', 'name'] * * extractZodKeys(z.object({ id: z.string() }).optional().array()) * // → ['id'] * * extractZodKeys(z.string()) * // → [] * ``` */ export declare function extractZodKeys(schema: ZodType): string[]; /** * Shallow (top-level only) field picker. * * Keeps only the keys present in `selectSet`. Nested objects are * returned whole — no recursive path traversal. This is by design: * the `_select` enum only lists root-level keys, matching 95% of * real-world overfetching scenarios with O(1) complexity. * * @param data - The validated object to filter * @param selectSet - Set of top-level keys to keep * @returns A new object with only the selected keys * * @example * ```typescript * pickFields({ id: '1', status: 'paid', amount: 100 }, new Set(['status'])) * // → { status: 'paid' } * ``` */ export declare function pickFields(data: Record, selectSet: Set): Record; /** * Apply `_select` filtering to validated data. * * Handles both single objects and arrays. When `isArray` is true, * each item in the array is filtered independently. * * @param data - Validated data (single object or array) * @param selectFields - Array of top-level keys to keep * @param isArray - Whether `data` is an array * @returns The filtered data (same shape as input, fewer fields) */ export declare function applySelectFilter(data: T | T[], selectFields: string[], isArray: boolean): T | T[]; //# sourceMappingURL=SelectUtils.d.ts.map