/** * Frame Payload Validation Helper * * Provides external callers with a way to pre-validate Frame payloads before ingestion. * Uses Zod schemas from memory/frames/types.ts with enhanced error reporting. * * @module memory/validation/frame-validator */ /** * Validation error with field path information */ export interface FrameValidationError { /** Dot-notation path to the field (e.g., "status_snapshot.next_action") */ path: string; /** Human-readable error message */ message: string; /** Error code for programmatic handling */ code: string; } /** * Warning about unknown fields (partial validation support) */ export interface FrameValidationWarning { /** Dot-notation path to the unknown field */ path: string; /** Warning message */ message: string; } /** * Result of Frame payload validation */ export interface FrameValidationResult { /** Whether the payload is valid for ingestion */ valid: boolean; /** Array of validation errors (empty if valid) */ errors: FrameValidationError[]; /** Array of warnings for unknown fields (partial validation) */ warnings: FrameValidationWarning[]; } /** * Validate a Frame payload before ingestion. * * This function provides external callers with a way to pre-validate Frame data * before calling saveFrame(). It returns structured errors with field paths and * warnings for unknown fields. * * @param data - The payload to validate (unknown type for maximum flexibility) * @returns FrameValidationResult with valid flag, errors, and warnings * * @example * ```typescript * import { validateFramePayload } from '@smartergpt/lex/memory'; * * const payload = { * id: 'frame-001', * timestamp: '2025-11-27T10:00:00Z', * branch: 'feature/my-feature', * module_scope: ['core'], * summary_caption: 'Implemented feature X', * reference_point: 'feature x complete', * status_snapshot: { next_action: 'PR review' } * }; * * const result = validateFramePayload(payload); * if (result.valid) { * // Safe to ingest * saveFrame(db, payload as Frame); * } else { * console.error('Validation errors:', result.errors); * } * * // Check for unknown fields * if (result.warnings.length > 0) { * console.warn('Unknown fields:', result.warnings); * } * ``` */ export declare function validateFramePayload(data: unknown): FrameValidationResult;