/** * Base abstract class for all registries. * * Provides the core structure for managing tokens, definitions, and * dependency graphs. Subclasses implement specific initialization logic. */ import type { Token } from '../interfaces/base.interface.js'; /** * Result of the buildMap phase containing registry structures. */ export type RegistryBuildMapResult = { /** All tokens that are provided (graph nodes) */ tokens: Set; /** Record definition by token */ defs: Map; /** Dependency graph by token */ graph: Map>; }; /** * Registry kind identifier for categorizing registries. */ export type RegistryKind = string; /** * Abstract base class for registries. * * @typeParam Interface - The interface type for registry entries * @typeParam Record - The record type stored in the registry * @typeParam MetadataType - The metadata type for initialization * @typeParam ProviderRegistryType - Optional parent provider registry type */ export declare abstract class RegistryAbstract { /** Default timeout for async operations in milliseconds */ protected asyncTimeoutMs: number; /** Promise that resolves when the registry is fully initialized */ ready: Promise; /** Reference to parent provider registry for dependency resolution */ protected providers: ProviderRegistryType; /** Metadata used for initialization */ protected list: MetadataType; /** All tokens that are provided (graph nodes) */ protected tokens: Set; /** Record definition by token */ protected defs: Map; /** Dependency graph by token */ protected graph: Map>; /** Instantiated entries by token */ protected readonly instances: Map, Interface>; /** * Create a new registry. * * @param name - Registry kind name for identification * @param providers - Parent provider registry * @param metadata - Initialization metadata * @param auto - Whether to automatically build and initialize */ protected constructor(name: RegistryKind, providers: ProviderRegistryType, metadata: MetadataType, auto?: boolean); /** * Build the initial token/record/graph maps from metadata. * Called during construction. * * @param list - Initialization metadata * @returns Registry structures */ protected abstract buildMap(list: MetadataType): RegistryBuildMapResult; /** * Build the dependency graph. * Called after buildMap to establish dependencies. */ protected abstract buildGraph(): void; /** * Initialize the registry by instantiating entries. * Called after buildGraph. * * @returns Promise that resolves when initialization is complete */ protected abstract initialize(): Promise; /** * Check if the registry has any entries. */ hasAny(): boolean; /** * Get all instances as a readonly map. */ getAllInstances(): ReadonlyMap, Interface>; }