/** * open-library.ts — shared helpers to open the LocalIndex and the configured * Catalog source. * * Lazy-loads the `@skaile/workspaces/library` subpath and returns the * LocalIndex instance (backed by `@libsql/client`; runs on Node and Bun). * The catalog-source helper reads * `~/.skaile/config.yaml` (and project-level overlay if `projectDir` is given) * to decide between {@link RemoteCatalogSource} (default — points at * `https://skaile.store`) and a {@link LocalCatalogSource} bound to the most * recent local library registered via `skaile source add`. */ /** Thrown by {@link openCatalogSource} when `catalog.url` is the `local` sentinel. */ export declare class LocalCatalogDisabledError extends Error { constructor(message: string); } /** * Open the LocalIndex with the full kind registry. Exits with code 1 * if the library directory cannot be created. * * @returns A `LocalIndex` instance ready for use. * @docLink cli/dev-guide#open-library */ export declare function openLibrary(): Promise; /** * Resolve the configured **remote** Catalog source for the CLI. * * Reads `~/.skaile/config.yaml` (plus the optional project-level overlay) and * returns a {@link RemoteCatalogSource} pointing at `catalog.url` (default: * `https://skaile.store`). The `cache_ttl: 0` config flag flips the source * into air-gapped mode: network reads are disabled, only `skaile update` * performs refreshes. * * **Local-mode rejection.** If the resolved config has `catalog.url: local` * this helper throws — callers wanting the dispatched local-or-remote source * must use {@link resolveCatalogSource}. Remote-only consumers like * `skaile update --catalog-only` rely on this strict behaviour. * * @param opts - Project directory (overlays project config) and explicit overrides. * @returns A configured {@link RemoteCatalogSource}. * @throws When `catalog.url` is the `local` sentinel. * @docLink cli/dev-guide#open-library */ export declare function openCatalogSource(opts?: { projectDir?: string; baseUrlOverride?: string; /** Override the user-config path for tests. */ userConfigFile?: string; }): Promise; /** * Resolved catalog source plus a close handle for releasing any underlying * resources (e.g. the `LocalIndex` SQLite connection in local mode). * * Callers MUST invoke `close()` when done — typically in a `finally` block. * For remote-mode sources `close()` is a no-op, but the contract is uniform * so consumers don't have to branch. * * @docLink cli/dev-guide#open-library */ export interface ResolvedCatalogSource { /** The {@link ICatalogSource} ready for use. */ source: import("@skaile/workspaces/library").ICatalogSource; /** Release any underlying resources (SQLite handle in local mode). */ close(): void; } /** * Resolve the configured Catalog source — local or remote — based on * `~/.skaile/config.yaml`. * * Dispatch: * - `catalog.url: local` → opens {@link LocalIndex}, picks the most recently * registered local library whose `path` still exists on disk, and returns a * {@link LocalCatalogSource} bound to that library. Throws if no usable * local library is registered. * - any URL → returns {@link RemoteCatalogSource} (same as * {@link openCatalogSource}). * * The returned `close()` releases the underlying `LocalIndex` SQLite handle * in local mode (no-op in remote mode). Callers MUST invoke it — typically in * a `finally` block — to satisfy `library/CLAUDE.md` § "Notes for Consumers". * * @param opts - Project directory (overlays project config) and explicit overrides. * @returns A `ResolvedCatalogSource` carrying the source and a close handle. * @throws When `local` is configured but no usable local library is registered. * @docLink cli/dev-guide#open-library */ export declare function resolveCatalogSource(opts?: { projectDir?: string; baseUrlOverride?: string; /** Override the user-config path for tests. */ userConfigFile?: string; }): Promise; /** * Open the LibraryManager bound to the active LocalIndex. * Caller owns lifetime — must call `close()` (returned helper closes the * underlying LocalIndex). * * @docLink cli/dev-guide#open-library */ export declare function openLibraryManager(): Promise<{ manager: import("@skaile/workspaces/library").LibraryManager; library: import("@skaile/workspaces/library").LocalIndex; close: () => void; }>; //# sourceMappingURL=open-library.d.ts.map