/** * TypedStorage Types * * Type definitions for the TypedStorage wrapper that provides * type-safe JSON serialization on top of StorageAdapter. */ import type { z } from '@frontmcp/lazy-zod'; import type { SetOptions } from './types'; /** * Options for TypedStorage wrapper */ export interface TypedStorageOptions { /** * Optional Zod schema for validation on read. * If provided, values will be validated after deserialization. */ schema?: z.ZodType; /** * Whether to throw an error when data fails validation. * If false (default), returns null for invalid data. * @default false */ throwOnInvalid?: boolean; /** * Custom serialization function. * @default JSON.stringify */ serialize?: (value: T) => string; /** * Custom deserialization function. * @default JSON.parse */ deserialize?: (raw: string) => unknown; } /** * Options for typed set operations. * Re-export for convenience. */ export type TypedSetOptions = SetOptions; /** * Entry for batch set operations with typed values. */ export interface TypedSetEntry { key: string; value: T; options?: TypedSetOptions; }