UNPKG

@sailboat-computer/data-storage

Version:

Shared data storage library for sailboat computer v3

106 lines (92 loc) 2.35 kB
/** * Type declarations for @sailboat-computer/config-loader */ declare module '@sailboat-computer/config-loader' { /** * Load configuration options */ export interface LoadConfigOptions { /** * Base directory */ baseDir?: string; /** * Whether to validate configuration against schema */ validate?: boolean; /** * Schema path */ schemaPath?: string; /** * Environment variables to interpolate */ env?: Record<string, string>; /** * Logger */ logger?: { debug: (message: string, meta?: any) => void; info: (message: string, meta?: any) => void; warn: (message: string, meta?: any) => void; error: (message: string, meta?: any) => void; }; } /** * Save configuration options */ export interface SaveConfigOptions { /** * Base directory */ baseDir?: string; /** * Whether to validate configuration against schema */ validate?: boolean; /** * Schema path */ schemaPath?: string; /** * Whether to create backup */ backup?: boolean; /** * Logger */ logger?: { debug: (message: string, meta?: any) => void; info: (message: string, meta?: any) => void; warn: (message: string, meta?: any) => void; error: (message: string, meta?: any) => void; }; } /** * Load configuration * * @param path - Configuration path * @param defaultConfig - Default configuration * @param options - Load options * @returns Configuration */ export function loadConfig<T>(path: string, defaultConfig: T, options?: LoadConfigOptions): Promise<T>; /** * Save configuration * * @param path - Configuration path * @param config - Configuration * @param description - Description * @param author - Author * @param options - Save options */ export function saveConfig<T>(path: string, config: T, description?: string, author?: string, options?: SaveConfigOptions): Promise<void>; /** * Validate configuration * * @param config - Configuration * @param schemaPath - Schema path * @returns Validation result */ export function validateConfig<T>(config: T, schemaPath: string): Promise<boolean>; }