import type { InferZodV3Output, ZodV3ObjectLike } from './core/zod-v3-types.js'; import type { BaseGetConfigOptions } from './core/types.js'; /** Options for getConfig function */ export interface GetConfigOptions extends BaseGetConfigOptions { /** Zod schema used to validate the configuration */ schema: S; } /** * Loads and validates configuration from JSON files and environment variables. * * Configuration is loaded in the following order (later sources override earlier): * 1. Config files (configPath or default 'config/config.json') * 2. Secrets files (secretsPath or default 'secrets/secrets.json') * 3. Environment sources (`envSources`, defaults to [process.env]) * 4. Later `envSources` entries override earlier ones * * @param options - Configuration options * @returns Validated and typed configuration object * @throws ZodError if configuration doesn't match the schema * @throws Error if config files exist but contain invalid JSON * * @example * const schema = z.object({ * PORT: z.number().default(3000), * DATABASE_URL: z.string().url(), * }); * * const config = getConfig({ schema }); * console.log(config.PORT); // Type-safe access * * @example * // With debug mode * const config = getConfig({ schema, debug: true }); * // Logs: [zonv] Loading config from: config/config.json * // Logs: [zonv] Applied env var: PORT = 8080 * * @example * // With custom delimiter * const config = getConfig({ schema, delimiter: '__' }); * // Now uses 'server__port' instead of 'server___port' for nested paths * * @example * // With multiple env-like sources * const config = getConfig({ schema, envSources: [import.meta.env, process.env] }); */ export declare const getConfig: ({ schema, configPath, secretsPath, env, debug, envSources, delimiter }: GetConfigOptions) => InferZodV3Output; /** * Loads and validates configuration from JSON files and environment variables asynchronously. * * This is the async version of getConfig. It loads files in parallel for better performance. * * Configuration is loaded in the following order (later sources override earlier): * 1. Config files (configPath or default 'config/config.json') * 2. Secrets files (secretsPath or default 'secrets/secrets.json') * 3. Environment sources (`envSources`, defaults to [process.env]) * 4. Later `envSources` entries override earlier ones * * @param options - Configuration options * @returns Promise resolving to validated and typed configuration object * @throws ZodError if configuration doesn't match the schema * @throws Error if config files exist but contain invalid JSON * * @example * const schema = z.object({ * PORT: z.number().default(3000), * DATABASE_URL: z.string().url(), * }); * * const config = await getConfigAsync({ schema }); * console.log(config.PORT); // Type-safe access */ export declare const getConfigAsync: ({ schema, configPath, secretsPath, env, debug, envSources, delimiter, }: GetConfigOptions) => Promise>;