import * as z3 from 'zod/v3'; import * as z from 'zod/v4/core'; type SchemaConfig = z3.AnyZodObject | z.$ZodType>; type ZodV4Output = T extends z.$ZodType ? z.infer : never; type InferredDataConfig = S extends z3.ZodType ? T : ZodV4Output; type InferredErrorConfig = S extends z3.ZodType ? z3.ZodError : S extends z.$ZodType ? z.$ZodError : never; type BaseAdapter = { /** * Name of the adapter */ name: string; /** * Separator to use for creating nested objects from flat keys (e.g., "." or "_") * When provided, keys like "database.host" or "database_host" will be converted to { database: { host: value } } * Only top-level keys get split, nested keys are not affected. */ nestingSeparator?: string; } & SharedConfigOptions; /** * Adapter type */ type Adapter = BaseAdapter & { /** * Read the config */ read: () => Promise>; }; /** * Synchronous adapter type */ type SyncAdapter = BaseAdapter & { /** * Read the config */ read: () => InferredDataConfig; }; type BaseConfig = { /** * Schema to validate the config against */ schema: S; /** * Function to call on success */ onSuccess?: (data: InferredDataConfig) => void; /** * Function to call on error */ onError?: (error: InferredErrorConfig) => void; /** * Logger to use */ logger?: Logger; } & SharedConfigOptions; /** * Config type */ type Config = BaseConfig & { /** * Adapters to use */ adapters?: Array | Adapter | SyncAdapter; }; /** * Synchronous config type */ type SyncConfig = BaseConfig & { /** * Adapters to use */ adapters?: Array | SyncAdapter; }; /** * Logger type */ type Logger = { /** * Log a warning */ warn: (message: string) => void; }; /** * Base adapter props */ type BaseAdapterProps = { /** * Regular expression to match keys to be processed. */ regex?: RegExp; } & SharedConfigOptions; /** * Shared config options between global config and adapter config */ type SharedConfigOptions = { /** * Whether to suppress errors */ silent?: boolean; /** * How to handle casing differences. */ keyMatching?: KeyMatching; /** * Function to transform key-value pairs before processing. * If the function returns false, the key-value pair will be dropped. */ transform?: Transform; }; /** * Transform type */ type Transform = (obj: { key: string; value: unknown; }) => { key: string; value: unknown; } | false; /** * Key matching type */ type KeyMatching = "lenient" | "strict"; export { Adapter as A, BaseAdapterProps as B, Config as C, InferredDataConfig as I, Logger as L, SchemaConfig as S, SyncConfig as a, SyncAdapter as b };