/** * SMI-914: Analytics Storage with SQLite * SMI-898: Path traversal protection for database paths * * Provides persistent storage for skill usage events with: * - SQLite database in ~/.skillsmith/analytics.db * - 30-day rolling window for data retention * - Efficient indexes for querying by skill and timestamp * - Secure path validation to prevent path traversal attacks */ import type { SkillUsageEvent, SkillMetrics } from './types.js'; /** * SQLite storage for skill usage analytics */ export declare class AnalyticsStorage { private db; /** * @deprecated Use AnalyticsStorage.create(dbPath) — async factory with WASM fallback. * This constructor always throws to prevent silent data loss. */ constructor(_dbPath?: string); /** * Async factory — supports both native and WASM SQLite. * * @param dbPath - Optional custom database path (defaults to ~/.skillsmith/analytics.db) * @returns Fully initialised AnalyticsStorage instance * @throws Error if dbPath contains path traversal attempt * * @see SMI-898: Path traversal protection * - Validates custom dbPath against path traversal attacks * - Rejects paths with ".." or outside allowed directories */ static create(dbPath?: string): Promise; /** * Initialize database schema */ private initSchema; /** * Record a skill usage event * * @param event - The usage event to record */ recordEvent(event: SkillUsageEvent): void; /** * Get all events for a skill * * @param skillId - The skill identifier * @param limit - Maximum number of events to return * @returns Array of usage events */ getEventsForSkill(skillId: string, limit?: number): SkillUsageEvent[]; /** * Get aggregated metrics for a skill * * @param skillId - The skill identifier * @returns Aggregated metrics or null if no data */ getMetricsForSkill(skillId: string): SkillMetrics | null; /** * Delete events older than retention period * * @returns Number of deleted events */ cleanup(): number; /** * Get total event count * * @returns Number of stored events */ getEventCount(): number; /** * Get event count by outcome * * @returns Object with counts per outcome type */ getOutcomeCounts(): Record; /** * Close database connection */ close(): void; } //# sourceMappingURL=storage.d.ts.map