/** * Configuration management with global defaults and per-guild merging * * Provides a high-level API for managing XP system configuration with: * - Global defaults that apply to all guilds * - Per-guild overrides with validation * - Deep merging of nested configuration objects * - Cache invalidation when global config changes * - Level curve validation with type-specific parameter checks * - Multi-store support: Each store has independent config with shared global defaults * * Config precedence (highest to lowest): * 1. Guild-specific config (per store) * 2. Global config defaults (shared across all stores) * 3. System defaults * * @example * ```typescript * // Default store * const config = await getConfig('123456789012345678') * * // Custom store (e.g., reputation system) * const repConfig = await getConfig('123456789012345678', { storeId: 'reputation' }) * ``` */ import type { GuildConfig, GlobalConfig, RoleReward, FlashcoreOptions, LevelCurveConfig } from './types.js'; /** * Default configuration constants */ export declare const DEFAULT_COOLDOWN = 60; export declare const DEFAULT_XP_RATE = 1; export declare const DEFAULT_REWARDS_MODE = "stack"; export declare const DEFAULT_REMOVE_ON_LOSS = false; export declare const DEFAULT_LEADERBOARD_PUBLIC = false; /** * Retrieves guild configuration with all defaults applied * Primary entry point for reading guild configuration * * @param guildId - Guild ID * @param options - Optional Flashcore options (e.g., storeId for multi-store support) * @returns Complete GuildConfig (never null, uses defaults if needed) * * @example * // Default store * const config = await getConfig('123456789012345678') * if (config.cooldownSeconds > 0) { * // Check cooldown before awarding XP * } * * // Custom store (e.g., reputation system) * const repConfig = await getConfig('123456789012345678', { storeId: 'reputation' }) */ export declare function getConfig(guildId: string, options?: FlashcoreOptions): Promise; /** * Updates guild configuration with validation * Merges partial values with existing config * * @param guildId - Guild ID * @param partial - Partial config to merge * @param options - Optional Flashcore options (e.g., storeId for multi-store support) * @returns Complete merged GuildConfig * @throws Error if validation fails * * @example * // Default store * const updated = await setConfig('123...', { * cooldownSeconds: 90, * roleRewards: [ * { level: 5, roleId: '345678901234567890' } * ] * }) * * // Custom store (e.g., reputation system) * const repUpdated = await setConfig('123...', { * cooldownSeconds: 120 * }, { storeId: 'reputation' }) */ export declare function setConfig(guildId: string, partial: Partial, options?: FlashcoreOptions): Promise; /** * Updates global configuration defaults * Clears all guild config caches to force re-merge on next access * * Global config is shared across all stores as base defaults. * Each store can then apply its own guild-specific overrides on top. * * @param config - Partial config to use as global defaults * @throws Error if validation fails * * @example * await setGlobalConfig({ * cooldownSeconds: 90, * xpRate: 1.2 * }) */ export declare function setGlobalConfig(config: GlobalConfig): Promise; /** * Retrieves current global configuration defaults * * Global config is shared across all stores as base defaults. * * @returns GlobalConfig (empty object if not set) * * @example * const global = await getGlobalConfig() * console.log('Global cooldown:', global.cooldownSeconds ?? DEFAULT_COOLDOWN) */ export declare function getGlobalConfig(): Promise; /** * Returns default guild configuration * * @returns GuildConfig with all default values * * @example * const defaults = getDefaultConfig() * console.log('Default cooldown:', defaults.cooldownSeconds) // 60 */ export declare function getDefaultConfig(): GuildConfig; /** * Validates configuration object * * Validates level curve configuration if present, including type-specific * parameter validation (positive numbers, sorted arrays, etc.). * * @param config - Partial config to validate * @returns Validation result with error messages * * @example * const result = validateConfig({ cooldownSeconds: -10 }) * if (!result.valid) { * console.error('Errors:', result.errors) * } * * @example * const result = validateConfig({ * levels: { * type: 'linear', * params: { xpPerLevel: -100 } * } * }) * // result.valid: false * // result.errors: ['levels.params.xpPerLevel must be positive number'] */ export declare function validateConfig(config: Partial): { valid: boolean; errors: string[]; }; /** * Validates level curve configuration * * Performs type-specific validation based on curve type discriminator. * Each curve type has different parameter requirements: * - Quadratic: optional positive coefficients (a, b, c) * - Linear: required positive xpPerLevel * - Exponential: required base > 1 and positive multiplier, maxLevel strongly recommended * - Lookup: required non-empty sorted array of non-negative thresholds * * @param curve - Level curve configuration to validate * @returns Array of error messages (empty if valid) * * @example * const errors = validateLevelCurve({ * type: 'linear', * params: { xpPerLevel: 100 } * }) * // errors: [] (valid) * * @example * const errors = validateLevelCurve({ * type: 'linear', * params: { xpPerLevel: -50 } * }) * // errors: ['levels.params.xpPerLevel must be positive number'] */ export declare function validateLevelCurve(curve: LevelCurveConfig): string[]; /** * Validates role rewards array * * @param rewards - Role rewards to validate * @returns Array of error messages (empty if valid) * * @example * const errors = validateRoleRewards([ * { level: 5, roleId: '123456789012345678' }, * { level: 5, roleId: '234567890123456789' } // duplicate level * ]) * // errors: ['roleRewards contains duplicate levels'] */ export declare function validateRoleRewards(rewards: RoleReward[]): string[]; /** * Validates multipliers object * * @param multipliers - Multipliers to validate * @returns Array of error messages (empty if valid) * * @example * const errors = validateMultipliers({ * server: 2.0, * role: { '123': 1.5 }, * user: { '456': -0.5 } // negative multiplier * }) * // errors: ['multipliers.user[456] must be positive number'] */ export declare function validateMultipliers(multipliers: GuildConfig['multipliers']): string[]; /** * Deep merges guild config with global defaults * Guild values take precedence over global values * * @param guildConfig - Guild-specific config (higher precedence) * @param globalConfig - Global defaults (lower precedence) * @returns Merged GuildConfig * * @example * const merged = mergeWithGlobal( * { cooldownSeconds: 90 }, * { cooldownSeconds: 60, xpRate: 1.5 } * ) * // Result: { cooldownSeconds: 90, xpRate: 1.5, ...defaults } */ export declare function mergeWithGlobal(guildConfig: Partial, globalConfig: GlobalConfig): GuildConfig;