/** * Navidrome MCP Server - Library Manager Service * Copyright (C) 2025 * SPDX-License-Identifier: AGPL-3.0-or-later */ import type { NavidromeClient } from '../client/navidrome-client.js'; import type { Config } from '../config.js'; interface LibraryInfo { id: number; name: string; path: string; remotePath: string; lastScanAt: string; lastScanStartedAt: string; fullScanInProgress: boolean; updatedAt: string; createdAt: string; totalSongs: number; totalAlbums: number; totalArtists: number; totalFolders: number; totalFiles: number; totalMissingFiles: number; totalSize: number; totalDuration: number; defaultNewUsers: boolean; } interface UserInfo { id: string; userName: string; name: string; email: string; isAdmin: boolean; lastLoginAt: string | null; lastAccessAt: string | null; createdAt: string; updatedAt: string; libraries: LibraryInfo[]; } /** A name and ID pair for a library picker. */ interface LibraryChoice { id: number; name: string; } /** * The libraries the logged-in user can see, for the settings page. It reads no library stats, so a * non-admin user gets the list too. Throws when Navidrome gives no usable list. */ export declare function listUserLibraries(client: NavidromeClient): Promise; declare class LibraryManager { private static instance; private userInfo; private activeLibraryIds; private enrichedLibraryIds; private initialized; private initPromise; private constructor(); static getInstance(): LibraryManager; /** * A JWT without a uid, or a user payload without libraries, soft-fails and leaves requests * unscoped. A rejected /user/{uid} lookup rethrows, since a refused valid uid is a real fault. */ initialize(client: NavidromeClient, config: Config): Promise; /** * A false or a throw leaves the previous snapshot in place. Navidrome's /api/user/{id} returns * zeroed library stats and timestamps, so the real values come from /api/library. */ private loadUserLibraries; /** * The Navidrome docs mark /api/library admin-only. A library it does not cover stays out of * `enrichedIds`, so its zeroed stats are reported as unavailable instead of as zero. */ private enrichLibraryStats; /** * Lets a long-lived server report current scans and libraries added after startup. A failed * reload keeps the previous snapshot, and a library the reload finds starts inactive. */ refresh(client: NavidromeClient): Promise; /** * A removed library's ID matches nothing, so an active set of only removed IDs would empty every * listing. */ private pruneActiveLibraries; private applyDefaultConfiguration; getAvailableLibraries(): LibraryInfo[]; getActiveLibraryIds(): number[]; getLibrariesWithActiveStatus(): Array; /** One unknown ID rejects the entire request, so the selection never differs from the request. */ setActiveLibraries(libraryIds: number[]): void; /** Navidrome's web UI repeats library_id once per library, such as library_id=1&library_id=2. */ getLibraryQueryParams(): URLSearchParams; getUserInfo(): UserInfo | null; isInitialized(): boolean; /** False when /api/library gave no stats for the library, so its zeroed stats mean nothing. */ hasLibraryStats(id: number): boolean; /** Lets a new runtime load another user's libraries, and isolates tests. */ reset(): void; } export declare const libraryManager: LibraryManager; export {}; //# sourceMappingURL=library-manager.d.ts.map