/** * Base Plugin Source * * Abstract base class for all plugin sources with common functionality. * Integrates retry logic, enhanced caching, request building, and logging. * * @since v1.0.0 * @updated v1.37.0 - Integrated source utilities */ import { type OperationLogger, createLogger } from '../../infrastructure/logger.js'; import type { IPluginSource, PluginInfo, PluginSourceType, SourceRequestOptions } from '../types/index.js'; import { type RetryOptions } from './utils/retry-decorator.js'; import { type CacheStats, SourceCache } from './utils/source-cache.js'; export { SourceError } from './source-error.js'; /** * Default request options */ export declare const DEFAULT_REQUEST_OPTIONS: Required; /** * Base source configuration options */ export interface BaseSourceOptions { /** Cache TTL in milliseconds (default: 5 minutes) */ cacheTtl?: number; /** Maximum cache entries (default: 500) */ maxCacheSize?: number; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; /** User agent string */ userAgent?: string; /** Enable retry with exponential backoff (default: true) */ enableRetry?: boolean; /** Retry options */ retryOptions?: RetryOptions; /** Enable debug logging (default: false) */ debug?: boolean; } /** * Abstract base class for plugin sources * * Provides common functionality: * - TTL-based caching with statistics * - Retry logic with exponential backoff * - Structured logging with operation tracking * - Request building with auth support */ export declare abstract class BasePluginSource implements IPluginSource { abstract readonly id: string; abstract readonly name: string; abstract readonly type: PluginSourceType; enabled: boolean; priority: number; /** Cache with statistics, pattern invalidation, and LRU eviction */ protected cache: SourceCache; /** Logger instance for this source */ protected log: ReturnType; protected lastError: string | null; private readonly enableRetry; private readonly retryOptions; /** * Per-request fetch timeout in milliseconds. Phase 3 audit, finding API [5]: * `BaseSourceOptions.timeout` was previously accepted but never applied to * fetch calls — sources had no network-level hang protection. Now wired * into `fetchJson` via `AbortSignal.timeout(this.fetchTimeout)`. */ protected readonly fetchTimeout: number; constructor(options?: BaseSourceOptions); /** * Initialize the source (called after construction) * Override in subclasses to set source-specific configuration */ protected initialize(): void; /** * Get plugin information by identifier */ abstract getPluginInfo(identifier: string): Promise; /** * Search for plugins */ abstract searchPlugins(query: string, limit?: number): Promise; /** * Get latest version for a plugin */ abstract getLatestVersion(identifier: string): Promise; /** * Check if source supports a Minecraft version */ supportsMinecraftVersion(_mcVersion: string): Promise; /** * Get the last error message */ getLastError(): string | null; /** * Clear the cache */ clearCache(): void; /** * Get cache statistics */ getCacheStats(): CacheStats; /** * Invalidate cache entries matching a pattern */ invalidateCache(pattern?: RegExp | string): number; /** * Run an async operation, returning null on 404 SourceErrors. * Rethrows all other errors. */ protected handle404(fn: () => Promise): Promise; /** * Start a logging operation for tracking */ protected startOperation(name: string, context?: Record): OperationLogger; /** * Build headers for requests */ protected buildHeaders(additional?: Record): Record; /** * Make a fetch request with error handling */ protected fetchJson(url: string, options?: RequestInit): Promise; /** * Make a fetch request with automatic retry on retryable errors */ protected fetchJsonWithRetry(url: string, options?: RequestInit): Promise; /** * Get from enhanced cache or fetch with automatic caching * Uses the new SourceCache with statistics tracking */ protected cachedFetchEnhanced(key: string, fetcher: () => Promise, options?: { useCache?: boolean; ttlMs?: number; }): Promise; } //# sourceMappingURL=base.d.ts.map