import { _ as URLBuilder, c as Client, d as Dependency, f as Maintainer, p as Package, t as Registry, v as Version } from "./registry.mjs"; import { Storage } from "unstorage"; //#region src/cache/paths.d.ts /** * Resolve the cache directory using the current platform convention. * * @returns {string} The absolute cache directory path. */ declare function getCacheDir(): string; //#endregion //#region src/cache/storage.d.ts /** * Configure the storage backend before the first cache operation. * * @param storage - Storage backend to use. */ declare function configureStorage(storage: Storage): void; /** * Get or create the shared storage backend. * * @returns {Storage} The configured or filesystem-backed storage. */ declare function getStorage(): Storage; /** * Get storage scoped to one registry ecosystem. * * @param ecosystem - Registry ecosystem key. * @returns {Storage} Namespaced storage for the ecosystem. */ declare function getEcosystemStorage(ecosystem: string): Storage; /** * Compute a SHA-256 integrity value for JSON-serializable data. * * @param value - Value to hash. * @returns {string} The prefixed hexadecimal digest. */ declare function computeIntegrity(value: unknown): string; /** Dispose the storage instance. Call on process exit. */ declare function disposeStorage(): Promise; /** Clear all cached data. */ declare function clearStorage(): Promise; //#endregion //#region src/cache/cached-registry.d.ts /** * CachedRegistry wraps any Registry and adds caching backed by unstorage * with a lockfile for freshness tracking. * * Pass a custom `storage` to use a non-default driver (e.g. Cloudflare KV). * If omitted, uses the globally configured storage (see `configureStorage()`). */ declare class CachedRegistry extends Registry { readonly inner: Registry; readonly storage: Storage; private readonly lockfileStorage; private readonly inflight; constructor(inner: Registry, storage?: Storage); ecosystem(): string; urls(): URLBuilder; fetchPackage(name: string, signal?: AbortSignal): Promise; fetchVersions(name: string, signal?: AbortSignal): Promise; fetchDependencies(name: string, version: string, signal?: AbortSignal): Promise; fetchMaintainers(name: string, signal?: AbortSignal): Promise; /** * Read a fresh cached value or fetch and persist its replacement. * * @param name - Package name. * @param type - Cached data type. * @param version - Package version when the cache entry is versioned. * @param fetcher - Upstream operation used after a cache miss. * @param signal - Optional cancellation signal. * @param extraMeta - Optional lockfile metadata derived from the fetched value. * @returns {Promise} The cached or freshly fetched value. */ private cached; } //#endregion //#region src/cache/lockfile.d.ts /** Default TTL per data type (seconds). */ declare const DEFAULT_TTL: { readonly package: 3600; readonly versions: 1800; readonly dependencies: 86400; readonly maintainers: 86400; }; type EntryType = keyof typeof DEFAULT_TTL; /** A single cached entry tracked in the lockfile. */ interface LockfileEntry { /** PURL-style key: 'npm:lodash', 'cargo:serde' */ key: string; /** What kind of data: package, versions, dependencies, maintainers */ type: EntryType; /** Unix timestamp (ms) when fetched */ fetchedAt: number; /** TTL in seconds */ ttl: number; /** Latest version at time of caching (for package entries) */ latestVersion?: string; /** Content hash (sha256 of JSON-serialized value) for integrity */ integrity: string; } /** The full lockfile structure. */ interface Lockfile { version: number; entries: Record; } /** * Read the lockfile, falling back to an empty valid structure. * * @param storage - Optional storage backend. * @returns {Promise} The stored or empty lockfile. */ declare function readLockfile(storage?: Storage): Promise; /** * Persist the lockfile. * * @param lockfile - Lockfile to persist. * @param storage - Optional storage backend. */ declare function writeLockfile(lockfile: Lockfile, storage?: Storage): Promise; /** * Build a stable cache key. * * @param ecosystem - Registry ecosystem. * @param name - Package name. * @param type - Cached data type. * @param version - Optional package version. * @returns {string} The cache key. */ declare function cacheKey(ecosystem: string, name: string, type: EntryType, version?: string): string; /** * Check whether a lockfile entry is fresh. * * @param entry - Entry to inspect. * @returns {boolean} Whether the entry is still valid. */ declare function isFresh(entry: LockfileEntry): boolean; /** * Read a fresh lockfile entry. * * @param lockfile - Lockfile to inspect. * @param key - Cache key. * @returns {LockfileEntry | null} The fresh entry, or null. */ declare function getFreshEntry(lockfile: Lockfile, key: string): LockfileEntry | null; /** * Upsert an in-memory lockfile entry without persisting it. * * @param lockfile - Lockfile to mutate. * @param entry - Entry to store. */ declare function setEntry(lockfile: Lockfile, entry: LockfileEntry): void; /** * Remove an in-memory lockfile entry. * * @param lockfile - Lockfile to mutate. * @param key - Cache key to remove. */ declare function removeEntry(lockfile: Lockfile, key: string): void; /** * Remove every stale in-memory entry. * * @param lockfile - Lockfile to prune. * @returns {number} The number of removed entries. */ declare function pruneStale(lockfile: Lockfile): number; //#endregion //#region src/cache/index.d.ts /** Options for creating a cached registry. */ interface CreateCachedOptions { /** Custom base URL for the registry API. */ baseURL?: string; /** Custom HTTP client. */ client?: Client; /** Custom unstorage instance. Overrides the globally configured storage. */ storage?: Storage; } /** * Create a registry with cache and lockfile tracking. * * @param ecosystem - Registry ecosystem key. * @param options - Optional registry, client, and storage overrides. * @returns {Promise} A cached registry instance. */ declare function createCached(ecosystem: string, options?: CreateCachedOptions): Promise; //#endregion export { getCacheDir as S, computeIntegrity as _, Lockfile as a, getEcosystemStorage as b, getFreshEntry as c, readLockfile as d, removeEntry as f, clearStorage as g, CachedRegistry as h, EntryType as i, isFresh as l, writeLockfile as m, createCached as n, LockfileEntry as o, setEntry as p, DEFAULT_TTL as r, cacheKey as s, CreateCachedOptions as t, pruneStale as u, configureStorage as v, getStorage as x, disposeStorage as y }; //# sourceMappingURL=index2.d.mts.map