import type { ProviderNode, AppEnvironments } from '../types.ts'; /** * ProvidersManager handles the complete lifecycle of service providers in an AdonisJS application. * It manages provider registration, booting, starting, readying, and shutdown phases. * * Service providers are classes that register services, bind dependencies, and set up * application components during different phases of the application lifecycle. * * Lifecycle phases: * 1. **Register**: Bind services to the IoC container * 2. **Boot**: Initialize services after all providers are registered * 3. **Start**: Start services (e.g., HTTP server, background jobs) * 4. **Ready**: Notify services that application is ready to serve requests * 5. **Shutdown**: Gracefully shutdown services during app termination * * @example * const manager = new ProvidersManager({ environment: 'web', providersState: [app] }) * manager.use([ * { file: () => import('./providers/app_provider'), environment: ['web', 'console'] } * ]) * await manager.register() * await manager.boot() * await manager.start() * await manager.ready() */ export declare class ProvidersManager { #private; /** * Creates a new ProvidersManager instance. * * @param {Object} options - Configuration options * @param {AppEnvironments} options.environment - Current application environment * @param {any[]} options.providersState - Arguments to pass to provider constructors */ constructor(options: { environment: AppEnvironments; providersState: any[]; }); /** * Registers an array of provider nodes to be processed later. * Replaces any previously registered providers. * * @param {ProviderNode[]} list - Array of provider nodes to register * @returns {this} Returns the ProvidersManager instance for method chaining */ use(list: ProviderNode[]): this; /** * Changes the environment context for filtering providers. * Used when the application environment changes after manager creation. * * @param {AppEnvironments} environment - The new environment to set * @returns {this} Returns the ProvidersManager instance for method chaining */ setEnvironment(environment: AppEnvironments): this; /** * Phase 1: Resolves, instantiates, and calls register() on all providers. * Creates provider instances and invokes their register methods to bind services to the IoC container. * Sets up tracking for providers with shutdown methods. * * @returns {Promise} Promise that resolves when all providers are registered */ register(): Promise; /** * Phase 2: Calls boot() method on all registered providers. * Boot phase occurs after all providers have registered their services, * allowing providers to use services from other providers. * * @returns {Promise} Promise that resolves when all providers are booted */ boot(): Promise; /** * Phase 3: Calls start() method on all providers. * Start phase is for launching services like HTTP servers, background workers, etc. * * @returns {Promise} Promise that resolves when all providers are started */ start(): Promise; /** * Phase 4: Calls ready() method on all providers. * Ready phase indicates the application is fully started and ready to serve requests. * Clears the providers array after completion as they're no longer needed. * * @returns {Promise} Promise that resolves when all providers are ready */ ready(): Promise; /** * Phase 5: Calls shutdown() method on providers that implement it. * Shutdown phase allows providers to perform cleanup during graceful app termination. * Only providers with shutdown methods are called. * * @param {boolean} inReverseOrder - Whether to shutdown providers in reverse order (recommended for cleanup) * @returns {Promise} Promise that resolves when all providers are shutdown */ shutdown(inReverseOrder: boolean): Promise; }