import type { CslItem } from "./csl-json/types"; import { type FindOptions, type ILibrary, type RemoveOptions, type RemoveResult, type UpdateOptions, type UpdateResult } from "./library-interface.js"; export type { FindOptions, IdentifierType, ILibrary, UpdateOptions, UpdateResult, } from "./library-interface.js"; /** * Library manager for CSL-JSON references. * Implements ILibrary interface for use with operations layer. */ export declare class Library implements ILibrary { private filePath; private references; private currentHash; private dirty; private uuidIndex; private idIndex; private doiIndex; private pmidIndex; private isbnIndex; private constructor(); /** * Load library from file. * If the file does not exist, creates an empty library file. */ static load(filePath: string): Promise; /** * Save library to file. * * currentHash is derived from the in-memory serialized bytes (not from * re-reading the file after writing). That closes a race where an * external writer could overwrite the file between our write and a * disk-read hash, poisoning currentHash with the external content's * hash and causing a later reload() to silently skip the external * change as a "self-write". */ save(): Promise; /** * Whether the in-memory state has unsaved changes relative to disk. * Cleared by save() and reload(). */ isDirty(): boolean; /** * Reloads the library from file if it was modified externally. * Self-writes (detected via hash comparison) are skipped. * @returns true if reload occurred, false if skipped (self-write detected) */ reload(): Promise; /** * Add a reference to the library * @param item - The CSL item to add * @returns The added CSL item (with generated ID and UUID) */ add(item: CslItem): Promise; /** * Remove a reference by citation ID or UUID. * @param identifier - The citation ID or UUID of the reference to remove * @param options - Remove options (byUuid to use UUID lookup) * @returns Remove result with removed status and the removed item */ remove(identifier: string, options?: RemoveOptions): Promise; /** * Update a reference by citation ID or UUID. * @param identifier - The citation ID or UUID of the reference to update * @param updates - Partial updates to apply to the reference * @param options - Update options (byUuid to use UUID lookup, onIdCollision for collision handling) * @returns Update result with updated item, success status, and any ID changes */ update(identifier: string, updates: Partial, options?: UpdateOptions): Promise; /** * Find a reference by citation ID or UUID. * @param identifier - The citation ID or UUID of the reference to find * @param options - Find options (byUuid to use UUID lookup) * @returns The CSL item if found, undefined otherwise */ find(identifier: string, options?: FindOptions): Promise; /** * Get all references */ getAll(): Promise; /** * Get the file path */ getFilePath(): string; /** * Get the current file hash * Returns null if the library has not been loaded or saved yet */ getCurrentHash(): string | null; /** * Add reference to all indices */ private addToIndices; /** * Remove reference from all indices and array */ private removeReference; /** * Update a reference with partial updates. * Preserves uuid and created_at, updates timestamp. */ private updateReference; /** * Resolve the new ID, handling collisions based on options. */ private resolveNewId; /** * Check if there are actual changes between existing item and updates. * Ignores protected fields (uuid, created_at, timestamp). */ private hasChanges; /** * Check if custom fields have changes (excluding protected fields). */ private hasCustomFieldChanges; /** * Build the updated CslItem, preserving uuid and created_at. */ private buildUpdatedItem; /** * Remove a reference from all indices. */ private removeFromIndices; /** * Generate an alphabetic suffix for ID collision resolution. * 0 -> 'a', 1 -> 'b', ..., 25 -> 'z', 26 -> 'aa', etc. */ private generateSuffix; /** * Resolve ID collision by appending alphabetic suffix. */ private resolveIdCollision; } //# sourceMappingURL=library.d.ts.map