/** * Driver Registry * * Manages multiple driver delegates for Rebase backend. * Allows different databases for different collections. * * Usage: * - Single DB: Pass a single DataDriver → maps to "(default)" * - Multiple DBs: Pass a map of { dbId: DataDriver } * - Collections use `databaseId` property to specify which driver to use * - Collections without `databaseId` fallback to "(default)" */ import { DataDriver } from "@rebasepro/types"; /** * The default driver identifier used when: * - A single driver is provided (not a map) * - A collection doesn't specify a databaseId */ export declare const DEFAULT_DRIVER_ID = "(default)"; /** * Registry for managing multiple driver delegates */ export interface DriverRegistry { /** * Register a driver delegate with an ID * @param id - Unique identifier for this driver (e.g., "analytics", "users") * @param delegate - The DataDriver instance */ register(id: string, delegate: DataDriver): void; /** * Get the default driver delegate (id = "(default)") * @throws Error if no default driver is registered */ getDefault(): DataDriver; /** * Get a driver delegate by ID * @param id - Driver identifier, or undefined/null for default * @returns The DataDriver, or undefined if not found */ get(id: string | undefined | null): DataDriver | undefined; /** * Get a driver delegate by ID, with fallback to default * @param id - Driver identifier, or undefined/null for default * @returns The DataDriver (falls back to default if id not found) * @throws Error if neither the specified nor default driver exists */ getOrDefault(id: string | undefined | null): DataDriver; /** * Check if a driver with the given ID exists */ has(id: string): boolean; /** * List all registered driver IDs */ list(): string[]; /** * Get the number of registered drivers */ size(): number; } /** * Default implementation of DriverRegistry */ export declare class DefaultDriverRegistry implements DriverRegistry { private delegates; /** * Create a DriverRegistry from either a single delegate or a map * @param input - Single DataDriver (maps to "(default)") or Record */ static create(input: DataDriver | Record): DefaultDriverRegistry; register(id: string, delegate: DataDriver): void; getDefault(): DataDriver; get(id: string | undefined | null): DataDriver | undefined; getOrDefault(id: string | undefined | null): DataDriver; has(id: string): boolean; list(): string[]; size(): number; }