/** * SMI-915: Metrics Exporter * * Exports aggregated metrics to various formats for analysis and reporting. * Supports: * - JSON export with full metrics data * - CSV export for spreadsheet analysis * - Weekly/daily/custom period exports * - Retention metrics (optional) */ /** * Validates that a path does not escape the allowed base directory. * Prevents path traversal attacks using sequences like '../'. * * @param inputPath - The path to validate (can be relative or absolute) * @param baseDir - The allowed base directory * @returns The resolved, sanitized absolute path * @throws Error if the path attempts to escape the base directory */ export declare function validatePath(inputPath: string, baseDir: string): string; import type { MetricsAggregator, GlobalMetrics, AggregationPeriod } from './metrics-aggregator.js'; import type { SkillMetrics } from './types.js'; /** * Exported metrics structure */ export interface MetricsExport { /** ISO timestamp when export was generated */ exportedAt: string; /** Period information */ period: { /** ISO timestamp of period start */ start: string; /** ISO timestamp of period end */ end: string; /** Human-readable label (e.g., "2026-W01") */ label: string; }; /** Global metrics across all skills */ global: GlobalMetrics; /** Per-skill metrics keyed by skill ID */ skills: Record; /** Optional retention data by skill */ retention?: Record; } /** * Export configuration options */ export interface ExportOptions { /** Directory for output files (defaults to ~/.skillsmith/exports) */ outputDir?: string; /** Output format (defaults to 'json') */ format?: 'json' | 'csv'; /** Include retention rate calculations (defaults to false) */ includeRetention?: boolean; /** Retention period in days for calculation (defaults to 7) */ retentionDays?: number; } /** * Exports metrics to files in various formats */ export declare class MetricsExporter { private aggregator; /** * Create a metrics exporter * * @param aggregator - MetricsAggregator instance */ constructor(aggregator: MetricsAggregator); /** * Get ISO week label (e.g., "2026-W01") * * @param date - Date to get week label for * @returns ISO week label string */ private getWeekLabel; /** * Get day label (e.g., "2026-01-01") * * @param date - Date to get label for * @returns ISO date string (YYYY-MM-DD) */ private getDayLabel; /** * Export metrics for the last N days * * @param days - Number of days to include * @param options - Export options * @returns Exported metrics data */ exportLastNDays(days: number, options?: ExportOptions): MetricsExport; /** * Export metrics for a specific week * * @param date - Any date within the desired week (defaults to current week) * @param options - Export options * @returns Exported metrics data */ exportWeek(date?: Date, options?: ExportOptions): MetricsExport; /** * Export metrics for a specific day * * @param date - The date to export (defaults to today) * @param options - Export options * @returns Exported metrics data */ exportDay(date?: Date, options?: ExportOptions): MetricsExport; /** * Export metrics for a time period * * @param period - Aggregation period * @param options - Export options * @returns Exported metrics data */ export(period: AggregationPeriod, options?: ExportOptions): MetricsExport; /** * Save export data to a file * * @param data - Metrics export data * @param options - Export options * @param allowedBaseDir - Optional base directory to restrict path access (defaults to DEFAULT_EXPORT_DIR) * @returns Path to the saved file * @throws Error if outputDir attempts to escape the allowedBaseDir */ saveToFile(data: MetricsExport, options?: ExportOptions, allowedBaseDir?: string): string; /** * Convert export data to CSV format * * @param data - Metrics export data * @returns CSV string */ private toCSV; /** * Escape a string for CSV output * * @param value - String to escape * @returns Escaped string */ private escapeCSV; /** * Export to JSON string (for programmatic use) * * @param data - Metrics export data * @param pretty - Whether to format with indentation (defaults to true) * @returns JSON string */ toJSON(data: MetricsExport, pretty?: boolean): string; } //# sourceMappingURL=metrics-exporter.d.ts.map