import 'reflect-metadata'; import { ServiceIdentifier } from './abstraction'; /** * A dependency injection container. Manages the registration and resolution of dependencies. * Each module or package should create its own instance of `Container`. */ export declare class Container { private _container; /** * Creates a new instance of the `Container`. */ constructor(); /** * Registers a service or factory in the container. * @param id - The service identifier (class or string). * @param instanceOrFactory - The service instance or a factory function. * @param transient - Set to `true` for transient services (new instance each time). Default is `false` (singleton). * @returns A function to unregister the service. * @throws {Error} If a service with the same ID is already registered. */ register(id: ServiceIdentifier | string | (new (...args: any[]) => T), instanceOrFactory: T | (() => T), transient?: boolean): () => void; get(id: ServiceIdentifier | string | (new (...args: any[]) => T)): T | undefined; /** * Resolves dependencies for a class and creates an instance. * @param ctor - The constructor of the class to instantiate. * @returns An instance of the class with dependencies resolved. * @throws {Error} If a dependency cannot be resolved. */ getInstance(ctor: new (...args: any[]) => T): T; /** * Resets the container (primarily for testing). Removes all registered services. */ reset(): void; /** * Gets an array of all registered service identifiers. Useful for debugging or introspection. * @returns An array of registered service identifiers (class constructors or strings). */ getRegisteredServiceIdentifiers(): (ServiceIdentifier | string)[]; } /** * Decorator to mark a class as a service that can be injected. * * @param container - (Optional) The `Container` instance to register the service with. If not provided, a module-scoped container is used. * @returns The decorated constructor function. * @example * ```typescript * import { Container, Service, Inject } from '@brainstack/inject'; * * const customScopeContainer = new Container(); * * @Service(customScopeContainer) * class MyService { ... } * ``` * */ export declare function Service any>(container?: Container): (constructor: T) => T; /** * Decorator to mark a constructor parameter for dependency injection. * @param target - The target class. * @param propertyKey - The name of the constructor (always `'constructor'`). * @param parameterIndex - The index of the parameter to inject. */ export declare function Inject(target: any, propertyKey: string | symbol | undefined, parameterIndex: number): void;