import { ServiceProvider } from './services/providers.js'; import type Cache from './services/cache.js'; import type Config from './services/config.js'; import type Env from './services/env.js'; import type EventManager from './services/event_manager.js'; import type HttpClient from './services/http_client.js'; import type JsonWebToken from './services/jwt_token.js'; import type KongJsonWebToken from './services/jwt_token_kong.js'; import type Logger from './services/logger.js'; import type Namespace from './services/namespace.js'; import type Now from './services/now.js'; import type Redis from './services/redis.js'; import type RestClient from './services/rest_client.js'; import type ValidatorBase from './services/joi.js'; import type AuthKongMiddleware from './middlewares/auth_kong.js'; import type AuthMiddleware from './middlewares/auth.js'; import type DebugMiddleware from './middlewares/debug.js'; import type SessionMiddleware from './middlewares/session.js'; import type TraceMiddleware from './middlewares/trace.js'; import type ValidatorMiddleware from './middlewares/validator.js'; import type ViewCacheMiddleware from './middlewares/view_cache.js'; /** * Injectable dependencies are declared on the target itself, as plain data the * container reads at instantiation time: * - classes use `static dependencies = [...]` * - function factories (no static) use the `Dependencies(...)` helper, which * writes the same property onto the function * Each entry is resolved recursively and passed to the constructor, or as call * arguments for function factories. */ /** * Engine metadata shared between the EvaEngine runtime, service providers and mocks. */ export interface EngineMeta { projectRoot?: string; configPath?: string; sourceRoot?: string; config?: Record; logger?: unknown; namespace?: unknown; port?: number | string | boolean; mode?: string; } /** * Minimal structural view of an engine (the real EvaEngine or a test mock). */ export interface EngineLike { getMeta(): EngineMeta; } type ServiceProviderConstructor = new (engine: EngineLike) => ServiceProvider; type ClassOrFunction = (abstract new (...args: never[]) => unknown) | ((...args: never[]) => unknown); /** * Declares the injectable dependencies of a function factory (classes declare * `static dependencies` directly). The container resolves each entry * recursively and passes the results as call arguments. */ export declare function Dependencies(...dependencies: unknown[]): (target: T) => T; interface ClassBinding { kind: 'class'; target: ClassOrFunction; args?: unknown[]; } interface ValueBinding { kind: 'value'; target: unknown; } interface MethodBinding { kind: 'method'; target: ClassOrFunction; args?: unknown[]; } type Binding = ClassBinding | ValueBinding | MethodBinding; /** * Minimal native DI container: * - recursive resolution with per-container singleton cache * - class bindings are cached per class, so several binding names pointing at * the same class share one instance; this is what keeps the providers' * "get prebuilt instance, mutate it, bindClass(key, Class, [instance])" * pattern visible to later `get`s * - value/method bindings are cached per binding, so rebinding builds fresh * - method (function factory) bindings are invoked with the container as * `this` and their return value — the fully-injected inner function — is * cached as the singleton * - falsy instances are rebuilt on every get */ export declare class Container { bindings: Map; instances: Map; stack: Set; bindClass(key: unknown, target: ClassOrFunction, args?: unknown[]): this; bindValue(key: unknown, value: unknown): this; bindMethod(key: unknown, target: ClassOrFunction, args?: unknown[]): this; resolve(key: unknown): unknown; private resolveBinding; private instantiate; private resolveDeps; private construct; private invoke; } export default class DI { static getContainer(): Container; static getBound(): Record; static get(name: 'env'): Env; static get(name: 'config'): Config; static get(name: 'logger'): Logger; static get(name: 'redis'): Redis; static get(name: 'cache'): Cache; static get(name: 'http_client'): HttpClient; static get(name: 'rest_client'): RestClient; static get(name: 'namespace'): Namespace; static get(name: 'now'): Now; static get(name: 'validator_base'): ValidatorBase; static get(name: 'event_manager'): EventManager; static get(name: 'jwt'): JsonWebToken | KongJsonWebToken; static get(name: 'trace'): ReturnType; static get(name: 'session'): ReturnType; static get(name: 'auth'): ReturnType; static get(name: 'debug'): ReturnType; static get(name: 'validator'): ReturnType; static get(name: 'view_cache'): ReturnType; static get(service: abstract new (...args: never[]) => T): T; static get(name: string): T; static bindClass(target: unknown, ...args: unknown[]): Container; static bindValue(target: unknown, ...args: unknown[]): Container; static bindMethod(target: unknown, ...args: unknown[]): Container; static reset(): void; static registerServiceProviders(providers: ServiceProviderConstructor[] | undefined, engine: EngineLike): void; static registerService(ProviderClass: ServiceProviderConstructor, engine: EngineLike): void; static registerMockedProviders(providers: ServiceProviderConstructor[], configPath: string): void; } export {};