/** * Sources Cache - Local manifest of available sources * * Maintains a local copy of user sources to avoid repeated API calls during extraction. * Sources are fetched from the API and cached locally with a timestamp for staleness tracking. * * Cache File Location: ~/.bragdoc/cache/data/sources.yml * * Synchronization Strategy: * - On every extract: fetch fresh sources from API and update cache * - Fallback: if API unavailable, use cached sources with staleness warning * - Staleness warning: log warning if lastSynced > 7 days old */ import type { ApiClient } from '../api/client'; /** * Source type - mirrors database Source table */ export interface CachedSource { id: string; userId: string; projectId: string; name: string; type: 'git' | 'github' | 'jira'; config: Record; isArchived: boolean; createdAt: string; updatedAt: string; } /** * Sources Cache - Manages local source manifest synchronization * * Caches sources locally to optimize extraction performance and provide * fallback when API is temporarily unavailable. * * @example * const cache = new SourcesCache(); * await cache.sync(apiClient); // Fetch fresh sources * const sources = cache.getByProjectId(projectId); * for (const source of sources) { * console.log(`${source.name}: ${source.type}`); * } */ export declare class SourcesCache { private readonly cachePath; private sources; private lastSynced; constructor(); /** * Load sources from cache file. * * Reads sources.yml from disk and populates in-memory cache. * Handles missing file gracefully (returns empty cache). * * @throws Error if YAML parse fails or file system error occurs */ load(): Promise; /** * Save sources to cache file. * * Writes sources.yml with current sources and updates lastSynced timestamp. * Creates cache directory if it doesn't exist. * * @throws Error if write fails */ save(): Promise; /** * Synchronize sources with API. * * Fetches latest sources from API and updates local cache. * Falls back to cached sources with warning if API unavailable. * Logs staleness warning if cache is > 7 days old. * * @param apiClient - Authenticated API client * @throws Error only if both API fetch and cache load fail completely */ sync(apiClient: ApiClient): Promise; /** * Get all sources for a project. * * Returns active (non-archived) sources belonging to the specified project. * * @param projectId - UUID of the project * @returns Array of sources for this project, empty if none found */ getByProjectId(projectId: string): CachedSource[]; /** * Get a specific source by ID. * * @param sourceId - UUID of the source * @returns Source object or null if not found */ getById(sourceId: string): CachedSource | null; /** * Get all sources (for debugging/inspection). * * @returns Array of all cached sources */ getAll(): CachedSource[]; /** * Get number of cached sources. * * @returns Total count of sources in cache */ count(): number; /** * Get cache staleness info. * * @returns Date of last sync or null if never synced */ getLastSynced(): Date | null; } //# sourceMappingURL=sources.d.ts.map