@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and
48 lines (47 loc) • 1.38 kB
TypeScript
/**
* Service Registry for Dependency Injection
* Breaks circular dependencies by providing lazy loading and centralized service management
*/
export interface ServiceFactory<T = unknown> {
(): T | Promise<T>;
}
export interface ServiceRegistration<T = unknown> {
factory: ServiceFactory<T>;
singleton: boolean;
instance?: T;
}
export declare class ServiceRegistry {
private static services;
private static initializing;
/**
* Register a service with optional singleton behavior
*/
static register<T>(name: string, factory: ServiceFactory<T>, options?: {
singleton?: boolean;
}): void;
/**
* Get a service instance with circular dependency detection
*/
static get<T>(name: string): Promise<T>;
/**
* Get a service synchronously (throws if async initialization required)
*/
static getSync<T>(name: string): T;
/**
* Check if a service is registered
*/
static has(name: string): boolean;
/**
* Clear all services (useful for testing)
*/
static clear(): void;
/**
* Get all registered service names
*/
static getRegisteredServices(): string[];
/**
* Register multiple services at once
*/
static registerBatch(services: Record<string, ServiceFactory>): void;
}
export declare const serviceRegistry: typeof ServiceRegistry;