import { InjectorService, LocalsContainer } from "../index.js"; import { ContextLogger, ContextLoggerOptions } from "./ContextLogger.js"; /** * Options for creating a DI context instance. * * @public */ export interface DIContextOptions extends Omit { id: string; platform?: string; } /** * Execution context for dependency injection operations. * * Represents a single execution scope (typically an HTTP request) with its own * scoped provider instances, logger, and lifecycle management. Provides access to * request-scoped services and context-specific data. * * ### Usage * * ```typescript * import {DIContext} from "@tsed/di"; * * const context = new DIContext({id: "req-123"}); * * context.logger.info("Processing request"); * const service = await context.injector.invoke(MyService, context.container); * * await context.destroy(); // Cleanup when done * ``` * * @public */ export declare class DIContext { #private; opts: DIContextOptions; [x: string]: any; readonly PLATFORM: string; constructor(opts: DIContextOptions); /** * Logger attached to the context request. */ get logger(): ContextLogger; /** * Request id generated by @@ContextMiddleware@@. * * ::: tip * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, ""))`. * Dash are removed to simplify tracking logs in Kibana * ::: * * ::: tip * Request id can by customized by changing the server configuration. * * ```typescript * @Configuration({ * logger: { * reqIdBuilder: createUniqId // give your own id generator function * } * }) * class Server { * * } * ``` * ::: * */ get id(): string; get dateStart(): Date; get injector(): InjectorService; get env(): any; /** * The request container used by the Ts.ED DI. It contains all services annotated with `@Scope(ProviderScope.REQUEST)` */ get container(): LocalsContainer; destroy(): Promise; cache(key: string, cb: () => Value): Value; cacheAsync(key: string, cb: () => Promise): Promise; delete(key: any): boolean; get(key: any): T; has(key: any): boolean; set(key: any, value: any): this; } export type BaseContext = DIContext & TsED.Context;