import type { InjectScope } from './constants.js'; import type { ILogger } from './logger/types.js'; export type Type = new (...args: any[]) => T; export type MaybePromise = T | Promise; export type TSelector = Type | string | symbol | object; export type TValueFactory = (dependencies: Dependencies, context?: Scope extends InjectScope.REQUEST ? Context | undefined : never) => MaybePromise; export type TTargetOptions = Scope extends InjectScope.REQUEST ? Record : never> = { /** * The factory function to produce the value for the provider. */ valueFactory?: TValueFactory; /** * A list of dependencies to be injected into this provider. */ inject?: Dependencies[]; /** * The scope of the provider, defining its lifecycle and behavior. */ scope?: Scope; }; export type TStorageEntry = Scope extends InjectScope.REQUEST ? Record : never> = { contextMap: Scope extends InjectScope.REQUEST ? WeakMap : never; value?: Value | null; } & TTargetOptions; export type TContainerOptions = { /** * Provides a logger instance to be used within the container. * Defaults to a simple console-based logger if none is provided. * * @Type ILogger * @default ConsoleLoggerImpl */ logger: ILogger | Type | (() => ILogger); }; /** * Represents a lifecycle hook that invokes logic when the container * is built. */ export interface IOnFinalized { /** * Called during the container build process for the specific target. */ onFinalized(): MaybePromise; } /** * Represents a lifecycle hook that invokes logic when the implementing class or component * is being initialized. */ export interface IOnInitialized { /** * Called during the initialization process of the class or component. */ onInitialized(): MaybePromise; }