UNPKG

@agility/cli

Version:

Agility CLI for working with your content. (Public Beta)

189 lines (188 loc) 8.05 kB
export type OperationType = "pull" | "push" | "sync"; export type EntityType = "model" | "container" | "list" | "content" | "page" | "asset" | "gallery" | "template" | "sitemap" | "auth" | "system" | "summary"; export type Action = "downloaded" | "uploaded" | "skipped" | "exists" | "reset" | "synced" | "update" | "updated" | "up-to-date" | "created" | "deleted" | "validated" | "authenticated" | "started" | "ended" | "failed" | "error" | "progressed"; export type Status = "success" | "failed" | "skipped" | "conflict" | "pending" | "in_progress" | "info"; export type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR"; export interface LogEntry { logLevel: LogLevel; message: string; timestamp: string; entity?: any; } export interface LogConfig { logToConsole: boolean; logToFile: boolean; showColors: boolean; useStructuredFormat: boolean; } export interface StructuredLogSummary { entityType: EntityType; successful: number; failed: number; skipped: number; total: number; } export declare class Logs { private logs; private config; private operationType; private startTime; private endTime?; private guidColorMap; private entityType?; private guid?; private availableColors; constructor(operationType: OperationType, entityType?: EntityType, guid?: string); /** * Set the GUID for this logger instance (for cases where it's set after construction) */ setGuid(guid: string): void; /** * Get the GUID for this logger instance */ getGuid(): string | undefined; /** * Configure logging behavior */ configure(config: Partial<LogConfig>): void; /** * Single logging function - handles everything based on configuration */ log(logLevel: LogLevel, message: string, entity?: any): void; /** * Log a summary of the operation, including counts and proper formatting. * Handles empty results, pluralization, and avoids type errors. */ changeDetectionSummary(entityType: EntityType, successful: number, skipped: number): void; syncOperationsSummary(entityType: EntityType, successful: number, skipped: number): void; /** * Simple info logging method */ info(message: string): void; /** * Log to file only (no console output) */ fileOnly(message: string): void; /** * Quick convenience methods for common patterns */ success(message: string, entity?: any): void; error(message: string, entity?: any): void; warning(message: string, entity?: any): void; debug(message: string, entity?: any): void; /** * Log a structured data element with consistent formatting */ logDataElement(entityType: EntityType, action: Action, status: Status, itemName: string, guid?: string, details?: string, locale?: string, channel?: string): void; /** * Single summary function - takes entity type and counts */ /** * Logs a summary of the operation, including counts and proper formatting. * Handles empty results, pluralization, and avoids type errors. */ summary(operationType: OperationType, successful: number, failed: number, skipped: number): void; /** * Save logs to file and return the file path (don't log it immediately) */ saveLogs(): string | null; /** * Clear logs without saving */ clearLogs(): void; /** * Get current log count */ getLogCount(): number; /** * Get logs by level (for debugging) */ private outputToConsole; private formatLogForFile; private generateTimestamp; private stripAnsiCodes; /** * Initialize color mapping for all GUIDs from state */ private initializeGuidColors; /** * Format GUID with its assigned color */ private formatGuidWithColor; initializeLogsInState(logs: LogEntry[]): void; displayLogs(): void; displayLog(log: LogEntry): void; startTimer(): void; endTimer(): void; /** * Structured entity logging - each entity type has its own methods */ asset: { downloaded: (entity: any, details?: string) => void; uploaded: (entity: any, details?: string, targetGuid?: string) => void; skipped: (entity: any, details?: string, targetGuid?: string) => void; error: (payload: any, apiError: any, targetGuid?: string) => void; }; model: { downloaded: (entity: any, details?: string) => void; created: (entity: any, details?: string, targetGuid?: string) => void; updated: (entity: any, details?: string, targetGuid?: string) => void; uploaded: (entity: any, details?: string) => void; skipped: (entity: any, details?: string, targetGuid?: string) => void; error: (payload: any, apiError: any, targetGuid?: string) => void; }; container: { downloaded: (entity: any, details?: string) => void; created: (entity: any, details?: string, targetGuid?: string) => void; updated: (entity: any, details?: string, targetGuid?: string) => void; uploaded: (entity: any, details?: string) => void; skipped: (entity: any, details?: string, targetGuid?: string) => void; error: (payload: any, apiError: any, targetGuid?: string) => void; }; content: { downloaded: (entity: any, details?: string, locale?: string) => void; uploaded: (entity: any, details?: string, locale?: string, targetGuid?: string) => void; created: (entity: any, details?: string, locale?: string, targetGuid?: string) => void; updated: (entity: any, details?: string, locale?: string, targetGuid?: string) => void; skipped: (entity: any, details?: string, locale?: string, targetGuid?: string) => void; error: (payload: any, apiError: any, locale?: string, targetGuid?: string) => void; }; template: { downloaded: (entity: any, details?: string) => void; uploaded: (entity: any, details?: string) => void; created: (entity: any, details?: string, targetGuid?: string) => void; updated: (entity: any, details?: string, targetGuid?: string) => void; skipped: (entity: any, details?: string, targetGuid?: string) => void; error: (payload: any, apiError: any, targetGuid?: string) => void; }; page: { downloaded: (entity: any, details?: string, locale?: string) => void; uploaded: (entity: any, details?: string, locale?: string, targetGuid?: string) => void; updated: (entity: any, details?: string, locale?: string, channel?: string, targetGuid?: string) => void; created: (entity: any, details?: string, locale?: string, channel?: string, targetGuid?: string) => void; skipped: (entity: any, details?: string, locale?: string, channel?: string, targetGuid?: string) => void; error: (payload: any, apiError: any, locale?: string, channel?: string, targetGuid?: string) => void; }; gallery: { downloaded: (entity: any, details?: string) => void; created: (entity: any, details?: string, targetGuid?: string) => void; updated: (entity: any, details?: string, targetGuid?: string) => void; skipped: (entity: any, details?: string, targetGuid?: string) => void; exists: (entity: any, details?: string) => void; error: (gallery: any, apiError: any, payload?: any, targetGuid?: string) => void; }; sitemap: { downloaded: (entity: any, details?: string) => void; uploaded: (entity: any, details?: string) => void; skipped: (entity: any, details?: string) => void; error: (payload: any, apiError: any) => void; }; /** * Log operation header with state information */ logOperationHeader(): void; /** * Log orchestrator summary with timing, counts, and completion status */ orchestratorSummary(results: any[], elapsedTime: number, success: boolean, logFilePaths?: string[]): void; }