/** * @file DLX manifest storage utilities. Manages persistent caching of DLX * package and binary metadata with TTL support and atomic file operations. * Primary API (on {@link DlxManifest}): * * - `getManifestEntry(spec)` — retrieve a manifest entry by spec * - `setPackageEntry(spec, key, details)` — store npm package metadata * - `setBinaryEntry(spec, key, details)` — store binary download metadata * - `getAllPackages()` — enumerate cached package names * - `clear(name)` / `clearAll()` — eviction Features: * - Atomic file operations with locking * - JSON-based persistent storage * - Error-resistant implementation Storage Format: * - Stores in ~/.socket/_dlx/.dlx-manifest.json * - Per-spec manifest entries with timestamps * - Thread-safe operations using process lock utility Usage: * - Update check caching * - Binary metadata tracking * - Rate limiting registry requests */ /** * Details for npm package entries. */ export interface PackageDetails { installed_version: string; size?: number | undefined; update_check?: { last_check: number; last_notification: number; latest_known: string; } | undefined; } /** * Details for binary download entries. */ export interface BinaryDetails { /** * SRI integrity hash (sha512-, aligned with npm). */ integrity: string; platform: string; arch: string; size: number; source: { type: 'download' | 'extract'; url?: string | undefined; path?: string | undefined; }; /** * Update check metadata, using the same structure as packages. */ update_check?: { last_check: number; last_notification: number; latest_known: string; } | undefined; } /** * Unified manifest entry for every cached package and binary. Shared fields at * root, type-specific fields in details. */ export interface DlxManifestEntry { type: 'package' | 'binary'; cache_key: string; timestamp: number; details: PackageDetails | BinaryDetails; } export interface DlxManifestOptions { /** * Custom manifest file path (defaults to ~/.socket/_dlx/.dlx-manifest.json). */ manifestPath?: string | undefined; } /** * Type guard for binary entries. * * @example * ;```typescript * const entry = manifest.getManifestEntry('https://example.com/tool') * if (entry && isBinaryEntry(entry)) { * console.log(entry.details.integrity) * } * ``` */ export declare function isBinaryEntry(entry: DlxManifestEntry): entry is DlxManifestEntry & { details: BinaryDetails; }; /** * Type guard for package entries. * * @example * ;```typescript * const entry = manifest.getManifestEntry('@socketsecurity/cli@^2.0.0') * if (entry && isPackageEntry(entry)) { * console.log(entry.details.installed_version) * } * ``` */ export declare function isPackageEntry(entry: DlxManifestEntry): entry is DlxManifestEntry & { details: PackageDetails; }; /** * DLX manifest storage manager with atomic operations, keyed by spec. Skips * any on-disk entry that doesn't match the {@link DlxManifestEntry} shape * (no `type` field) instead of throwing, so a manifest file is never * corrupted beyond repair by one malformed entry. */ export declare class DlxManifest { private readonly manifestPath; private readonly lockPath; constructor(options?: DlxManifestOptions | undefined); /** * Read the entire manifest file. * * @private */ private readManifest; /** * Write the manifest file atomically. * * @private */ private writeManifest; /** * Clear cached data for a specific entry. */ clear(name: string): Promise; /** * Clear all cached data. */ clearAll(): Promise; /** * Get all cached package names. */ getAllPackages(): string[]; /** * Get a manifest entry by spec (e.g., "@socketsecurity/cli@^2.0.11"). */ getManifestEntry(spec: string): DlxManifestEntry | undefined; /** * Set a binary manifest entry. */ setBinaryEntry(spec: string, cacheKey: string, details: BinaryDetails): Promise; /** * Set a package manifest entry. */ setPackageEntry(spec: string, cacheKey: string, details: PackageDetails): Promise; } export declare const dlxManifest: DlxManifest;