UNPKG

@sethdouglasford/claude-flow

Version:

Claude Code Flow - Advanced AI-powered development workflows with SPARC methodology

301 lines 7.9 kB
/** * Enterprise Configuration Management for Claude-Flow * Features: Security masking, change tracking, multi-format support, credential management */ import { Config } from "../utils/types.js"; interface FormatParser { parse(content: string): Partial<Config>; stringify(obj: Partial<Config>): string; extension: string; } interface ConfigChange { timestamp: string; path: string; oldValue: unknown; newValue: unknown; user?: string; reason?: string; source: "cli" | "api" | "file" | "env"; } interface SecurityClassification { level: "public" | "internal" | "confidential" | "secret"; maskPattern?: string; encrypted?: boolean; } interface ValidationRule { type: string; required?: boolean; min?: number; max?: number; values?: string[]; pattern?: RegExp; validator?: (value: unknown, config: Config) => string | null; dependencies?: string[]; } interface ConfigExport { version: string; exported: string; profile?: string; config: Config; diff?: any; } /** * Security classifications for configuration paths */ declare const SECURITY_CLASSIFICATIONS: Record<string, SecurityClassification>; /** * Sensitive configuration paths that should be masked in output */ declare const SENSITIVE_PATHS: string[]; /** * Configuration manager */ export declare class ConfigManager { private static instance; private config; private configPath?; private profiles; private currentProfile?; private userConfigDir; private changeHistory; private encryptionKey?; private validationRules; private formatParsers; private constructor(); /** * Gets the singleton instance */ static getInstance(): ConfigManager; /** * Initializes encryption key for sensitive configuration values */ private initializeEncryption; /** * Sets up validation rules for configuration paths */ private setupValidationRules; /** * Loads configuration from file and environment */ load(configPath?: string): Promise<void>; /** * Helper method to safely merge partial configs */ private mergeConfigs; /** * Gets the current configuration with optional security masking */ get(maskSensitive?: boolean): Config; /** * Gets configuration with security masking applied */ getSecure(): Config; /** * Updates configuration values with change tracking */ update(updates: Partial<Config>, options?: { user?: string; reason?: string; source?: "cli" | "api" | "file" | "env"; }): Config; /** * Loads default configuration */ loadDefault(): void; /** * Saves configuration to file with format support */ save(path?: string, format?: string): Promise<void>; /** * Gets configuration suitable for saving (excludes runtime-only values) */ private getConfigForSaving; /** * Gets user configuration directory */ private getUserConfigDir; /** * Creates user config directory if it doesn't exist */ private ensureUserConfigDir; /** * Loads all profiles from the profiles directory */ loadProfiles(): Promise<void>; /** * Applies a named profile */ applyProfile(profileName: string): Promise<void>; /** * Saves current configuration as a profile */ saveProfile(profileName: string, config?: Partial<Config>): Promise<void>; /** * Deletes a profile */ deleteProfile(profileName: string): Promise<void>; /** * Lists all available profiles */ listProfiles(): Promise<string[]>; /** * Gets a specific profile configuration */ getProfile(profileName: string): Promise<Partial<Config> | undefined>; /** * Gets the current active profile name */ getCurrentProfile(): string | undefined; /** * Sets a configuration value by path with change tracking and validation */ set(path: string, value: unknown, options?: { user?: string; reason?: string; source?: "cli" | "api" | "file" | "env"; }): void; /** * Gets a configuration value by path with decryption for sensitive values */ getValue(path: string, decrypt?: boolean): unknown; /** * Resets configuration to defaults */ reset(): void; /** * Gets configuration schema for validation */ getSchema(): any; /** * Validates a value against schema */ private validateValue; /** * Gets configuration diff between current and default */ getDiff(): any; /** * Exports configuration with metadata */ export(): ConfigExport; /** * Imports configuration from export */ import(data: ConfigExport): void; /** * Loads configuration from file with format detection */ private loadFromFile; /** * Detects configuration file format */ private detectFormat; /** * Loads configuration from environment variables */ private loadFromEnv; /** * Auto-detect AWS credentials and configure Bedrock integration */ private detectAndConfigureAWS; /** * Check if AWS credentials are available from various sources */ private checkAWSCredentials; /** * Validates configuration with dependency checking */ private validateWithDependencies; /** * Validates a specific configuration path */ private validatePath; /** * Gets a value from a configuration object by path */ private getValueByPath; /** * Legacy validate method for backward compatibility */ private validate; /** * Gets available configuration templates */ getAvailableTemplates(): string[]; /** * Creates a configuration from a template */ createTemplate(templateName: string): Config; /** * Gets format parsers for different config file formats */ getFormatParsers(): Record<string, { stringify: (obj: Partial<Config>) => string; parse: (str: string) => Partial<Config>; }>; /** * Validates a configuration file */ validateFile(configPath: string): Promise<{ valid: boolean; errors: string[]; }>; /** * Backs up the current configuration */ backup(backupPath?: string): Promise<string>; /** * Restores configuration from a backup */ restore(backupPath: string): Promise<void>; /** * Gets configuration path history */ getPathHistory(): string[]; /** * Gets configuration change history */ getChangeHistory(): Array<{ timestamp: Date; path: string; oldValue: unknown; newValue: unknown; }>; /** * Masks sensitive values in configuration */ private maskSensitiveValues; /** * Tracks configuration changes */ private trackChanges; /** * Track changes from config updates */ private trackConfigChanges; /** * Records a configuration change */ private recordChange; /** * Checks if a configuration path is sensitive */ private isSensitivePath; /** * Encrypts a value if encryption is enabled */ private encryptValue; /** * Checks if a value is encrypted */ private isEncryptedValue; /** * Decrypts a value if it's encrypted */ private decryptValue; } export declare const configManager: ConfigManager; export declare function loadConfig(path?: string): Promise<Config>; export type { FormatParser, ConfigChange, SecurityClassification, ValidationRule, }; export { SENSITIVE_PATHS, SECURITY_CLASSIFICATIONS, }; //# sourceMappingURL=config.d.ts.map