/** * Multi-source catalog federation (v0.8) — helpers for building the list of * catalog sources that `catalog-resolver` will iterate through. * * Priority layering (ascending = lower wins collisions, higher wins): * -1 bundled always present, ultimate fallback * 0 official remote DEFAULT_CATALOG_URL (implicit unless a replace-source * of priority >= 0 is present) * 100 user sources ~/.config/slaminar/defaults.json → catalog.sources[] * 200 team sources /.slaminar/config.json → catalogSources[] * 500 env sources SLAMINAR_CATALOG_SOURCES * 999 CLI adhoc `--catalog [--catalog-mode ]` * * Legacy v0.3–v0.7 fields (`catalogUrl`/`catalogMode`) are migrated into a * synthetic source at the appropriate layer on load. No file is rewritten * automatically — the next explicit save replaces them naturally. */ import type { CatalogMode, CatalogSource, CatalogSourceScope, CatalogSourceType } from '../types/index.js'; export declare const BUNDLED_SOURCE_ID = "bundled"; export declare const OFFICIAL_SOURCE_ID = "official"; export declare const SCOPE_PRIORITY: Record; export declare function inferSourceType(uri: string): CatalogSourceType; /** * Deterministic, stable ID for a source when the user didn't provide one. * Combines a slug with a short hash so two sources sharing a slug (e.g., * different paths ending in `catalog.json`) still collide-free. */ export declare function generateSourceId(uri: string, scope: CatalogSourceScope): string; export declare function bundledSource(): CatalogSource; export declare function officialSource(): CatalogSource; export interface MigrateLegacyInput { url: string; mode: CatalogMode; scope: CatalogSourceScope; addedAt?: string; } /** * Synthesize a `CatalogSource` from a legacy single-URL config value. * Returns `null` when the URL is empty — callers treat absence as "no layer". */ export declare function migrateSingleUrlToSource(input: MigrateLegacyInput): CatalogSource | null; /** * Parse the `SLAMINAR_CATALOG_SOURCES` env var. Format: * * :[,:...] * * where `mode` is `extend` or `replace` and `uri` can contain anything except * a literal comma. An empty / undefined input yields no sources. */ export declare function parseEnvSources(envVar: string | undefined): CatalogSource[]; /** * Build an ad-hoc CLI source for the `--catalog ` flag. Returns `null` * when the url is empty so callers can chain safely. */ export declare function makeCliAdhocSource(url: string | undefined | null, mode: CatalogMode | undefined): CatalogSource | null; export interface LoadEffectiveSourcesOptions { projectRoot?: string; cliSource?: CatalogSource | null; envVar?: string; } /** * Build the ordered (priority-ascending) list of sources that the resolver * will iterate over. Disabled sources are **kept** in the returned array so * the UI can surface them; resolver skips them when fetching. * * Order: * bundled (-1) * official (0) ← dropped if any user/team/env/CLI source * at priority >= 0 has mode='replace' * user defaults sources (100+) * team project sources (200+) * env sources (500) * CLI adhoc (999) */ export declare function loadEffectiveSources(options?: LoadEffectiveSourcesOptions): CatalogSource[]; export type PersistentSourceScope = 'user' | 'project'; export declare function readUserSources(): CatalogSource[]; export declare function writeUserSources(sources: CatalogSource[]): string; export declare function readTeamSources(projectRoot: string): CatalogSource[]; export declare function writeTeamSources(projectRoot: string, sources: CatalogSource[]): void; export interface AddSourceInput { uri: string; mode: CatalogMode; scope: PersistentSourceScope; id?: string; priority?: number; trust?: CatalogSource['trust']; projectRoot?: string; } /** * Persist a new source at the given scope. Duplicates (same id or same uri) * within the scope are replaced to keep the array idempotent under re-runs. */ export declare function addSource(input: AddSourceInput): CatalogSource; export interface RemoveSourceInput { identifier: string; scope: PersistentSourceScope; projectRoot?: string; } export declare function removeSource(input: RemoveSourceInput): boolean; export declare function setSourceEnabled(identifier: string, enabled: boolean, scope: PersistentSourceScope, projectRoot?: string): boolean; /** * Aggregate sources from every persistent scope + env + bundled/official * for display (`catalog source list`). Unlike `loadEffectiveSources`, this * does NOT include the CLI adhoc source (since `list` is not invoked with * a pending flag). */ export declare function listAllSources(projectRoot?: string): CatalogSource[];