import { type CronExecutionResult, type CronInvocationContext, type CronJobDefinition, type CronMode } from './cron/index.js'; /** * Dependency Injection Container * * Manages service registration, dependency resolution, and instance lifecycle. * Supports singleton pattern and automatic dependency injection via decorators. * Works with SWC and TypeScript's native decorator support. */ type Constructor = new (...args: any[]) => T; type ServiceFactory = () => T; type ContainerEventPayloads = { registered: { key: string | Constructor; singleton: boolean; kind: 'class' | 'factory' | 'value'; }; resolved: { key: string | Constructor; instance: any; singleton: boolean; fromCache: boolean; }; constructed: { key: Constructor; instance: any; overrides: Record; }; cleared: { count: number; }; telemetry: { className: string; methodName: string; args: any[]; startTime: number; endTime?: number; result?: any; error?: any; }; }; type Listener = (payload: T) => void; export declare const TELEMETRY_METADATA_KEY = "di:telemetry"; export declare const TELEMETRY_LISTENER_METADATA_KEY = "di:telemetry-listener"; export declare const PUBLISHER_METADATA_KEY = "di:publisher"; export declare const SUBSCRIBER_METADATA_KEY = "di:subscriber"; export declare const CRON_METADATA_KEY = "di:cron"; export declare const QUEUE_HANDLER_METADATA_KEY = "di:queue_handler"; declare function defineMetadata(key: string | symbol, value: any, target: any): void; declare function getMetadata(key: string | symbol, target: any): any; declare function hasMetadata(key: string | symbol, target: any): boolean; declare function getOwnMetadata(key: string | symbol, target: any): any; export declare class Container { private services; private resolutionStack; private listeners; private cronJobs; private cronMode; /** * Set cron execution mode ('in-process' or 'external'). * In 'external' mode, automatic in-component timers are suppressed. */ setCronMode(mode: CronMode): this; getCronMode(): CronMode; isExternalCron(): boolean; /** * Register a service class as injectable */ register(serviceClass: Constructor, options?: { singleton?: boolean; }): this; /** * Register a service using a factory function. * Accepts a string token or a class constructor (registers under both the * constructor key and {@code Class.name} so {@code resolve(MyClass)} works). */ registerFactory(nameOrClass: string | Constructor, factory: ServiceFactory, options?: { singleton?: boolean; }): this; /** Register an already-created value, including falsy and undefined values. */ registerValue(token: string | Constructor, value: T): this; /** * Get or create a service instance */ resolve(serviceClass: Constructor | string): T; /** * Construct a new instance without registering it in the container. * Supports constructor overrides for primitives/config (constructor pattern). * Always returns a fresh instance (no caching). */ construct(serviceClass: Constructor, overrides?: Record): T; /** * Check if a service is registered */ has(serviceClass: Constructor | string): boolean; /** * Clear all registered services */ clear(): void; /** * Stop all active cron jobs */ stopCronJobs(): void; /** * Manually invoke a scheduled job by its stable identifier or method name. * Resolves the owning service through DI, awaits the method, and reports completion or failure. */ invokeCronJob(jobId: string, context?: Partial & { throwOnError?: boolean; }): Promise>; /** * Get all discovered/registered cron job definitions. */ getCronJobs(): CronJobDefinition[]; /** * Get all registered service names */ getServiceNames(): string[]; /** * Fork the container (prototype pattern): clone registrations into a new container. * Optionally carry over existing singleton instances. */ fork(options?: { carrySingletons?: boolean; }): Container; /** * Subscribe to container lifecycle events (observer pattern). * Returns an unsubscribe function. */ on(event: K, listener: Listener): () => void; /** * Remove a previously registered listener */ off(event: K, listener: Listener): void; emit(event: K, payload: K extends keyof ContainerEventPayloads ? ContainerEventPayloads[K] : any): void; /** * Apply event publishers and subscribers defined via decorators */ private applyEvents; /** * Apply cron schedules defined via @Cron decorator */ private applyCron; /** * Private method to instantiate a service */ private instantiate; /** * Apply telemetry tracking and listeners to an instance */ private applyTelemetry; /** * Check if a function is a class constructor */ private isClass; /** * Extract parameter names from constructor */ private getConstructorParamNames; } /** * Global DI container instance */ export declare const container: Container; /** * Get the global DI container */ export declare function useContainer(): Container; export * from './cron/index.js'; export { Bean, Bootstrap, Builder, Component, Configuration, Publisher, Subscriber, Telemetry, TelemetryListener, } from './decorators/index.js'; /** * Export metadata functions for use in decorators * These provide a simple, reflect-metadata-free way to store and access metadata */ export { QueueHandler, type QueueHandlerMetadata, type QueueHandlerOptions, } from './decorators/QueueHandler.js'; export { ExportOperation, ExportService, ServiceBinding, serviceBindingToken, } from './service-bindings/index.js'; export { defineMetadata, getMetadata, getOwnMetadata, hasMetadata };