/** * Dependency Injection Container Interface. * * Supports three lifetime scopes: * - singleton: One instance for the container's lifetime * - scoped: One instance per child scope * - transient: New instance on every resolve */ /** * Service lifetime scope. */ export type Lifetime = 'singleton' | 'scoped' | 'transient'; /** * Factory function that creates a service instance. */ export type Factory = () => Promise; /** * Synchronous factory function. */ export type SyncFactory = () => T; /** * Service registration metadata. */ export interface IRegistration { readonly factory: Factory; readonly lifetime: Lifetime; } /** * Disposable interface for services that need cleanup. */ export interface IDisposable { dispose(): Promise; } /** * DI Container interface. */ export interface IContainer { /** * Register a service factory with a lifetime scope. * * @param token - Unique symbol identifying the service * @param factory - Async factory function that creates the service * @param lifetime - How long the instance should live */ register(token: symbol, factory: Factory, lifetime: Lifetime): void; /** * Register a service factory synchronously. * * @param token - Unique symbol identifying the service * @param factory - Sync factory function that creates the service * @param lifetime - How long the instance should live */ registerSync(token: symbol, factory: SyncFactory, lifetime: Lifetime): void; /** * Register an existing instance as a singleton. * * @param token - Unique symbol identifying the service * @param instance - The instance to register */ registerInstance(token: symbol, instance: T): void; /** * Resolve a service by its token. * * @param token - The service token to resolve * @returns The service instance * @throws Error if the token is not registered */ resolve(token: symbol): Promise; /** * Check if a service is registered. * * @param token - The service token to check */ isRegistered(token: symbol): boolean; /** * Create a child scope for scoped services. * Singletons are shared with the parent. * Scoped services get new instances in the child. */ createScope(): IContainer; /** * Dispose the container and all disposable singletons. * Child scopes should be disposed before their parent. */ dispose(): Promise; } //# sourceMappingURL=IContainer.d.ts.map