import { InstanceHolder } from "../holder/instance-holder.mjs"; import { IHolderStorage } from "../holder/holder-storage.interface.mjs"; import { LifecycleEventBus } from "../lifecycle/lifecycle-event-bus.mjs"; //#region src/internal/core/service-invalidator.d.mts interface ClearAllOptions { /** Whether to wait for all services to settle before starting (default: true) */ waitForSettlement?: boolean; } interface InvalidationOptions { /** Whether to emit events after invalidation (default: true) */ emitEvents?: boolean; /** Custom event emitter function */ onInvalidated?: (instanceName: string) => Promise; /** Whether to cascade invalidation to dependents (default: false - events handle it) */ cascade?: boolean; } /** * Manages graceful service cleanup with event-based invalidation. * * Uses event subscriptions instead of manual dependent finding. * When a service is created, it subscribes to destroy events of its dependencies. * When a dependency is destroyed, the event automatically invalidates dependents. */ declare class ServiceInvalidator { private readonly eventBus; private readonly logger; constructor(eventBus: LifecycleEventBus | null, logger?: Console | null); /** * Invalidates a service using a specific storage. * Event-based invalidation means dependents are automatically invalidated * via destroy event subscriptions - no need to manually find dependents. * * @param service The instance name to invalidate * @param storage The storage to use for this invalidation * @param options Additional options for invalidation behavior */ invalidateWithStorage(service: string, storage: IHolderStorage, options?: InvalidationOptions): Promise; /** * Sets up destroy event subscriptions for a service's dependencies. * Called when a service is successfully instantiated. * * @param serviceName The name of the service * @param dependencies The set of dependency names * @param storage The storage to use for invalidation * @param holder The holder for the service (to add unsubscribe to destroy listeners) */ setupDependencySubscriptions(serviceName: string, dependencies: Set, storage: IHolderStorage, holder: InstanceHolder): void; /** * Gracefully clears all services in a specific storage. * This allows clearing request-scoped services using a RequestStorage. */ clearAllWithStorage(storage: IHolderStorage, options?: ClearAllOptions): Promise; /** * Waits for all services in a specific storage to settle. */ readyWithStorage(storage: IHolderStorage): Promise; /** * Invalidates a single holder using a specific storage. */ private invalidateHolderWithStorage; /** * Common invalidation logic for holders based on their status. */ private invalidateHolderByStatus; /** * Destroys a holder using a specific storage. */ private destroyHolderWithStorage; /** * Waits for a holder to settle (either created, destroyed, or error state). */ private waitForHolderToSettle; /** * Emits events to listeners for instance lifecycle events. */ private emitInstanceEvent; } //#endregion export { ClearAllOptions, InvalidationOptions, ServiceInvalidator }; //# sourceMappingURL=service-invalidator.d.mts.map