import { PureContainer } from '@worktif/utils';
import { LambdaApi } from '@worktif/purews';
import type { LambdaInterface } from '@aws-lambda-powertools/commons/types';
import type { LambdaDefinition, MicroserviceDefinition } from '../../../lib/runtime-web/types';
import type { LambdaHandlerFactory } from './lambda-handler-factory';
import type { InitManager } from '../init';
/**
 * Runtime Web Lambda handler that extends LambdaApi with dependency injection.
 *
 * This class bridges the gap between the existing Runtime Core LambdaApi
 * infrastructure and the new Runtime Web Core dependency injection system.
 * It extends LambdaApi to maintain compatibility while adding automatic
 * DI resolution and user handler invocation.
 *
 * Supports both object-based ties (new pattern) and array-based ties (legacy):
 * - Object-based: Direct handler functions with enhanced event.ties
 * - Array-based: Factory functions with injected dependencies parameter
 *
 * ## Cold Start Initialization
 *
 * When an InitManager is provided, the handler supports cold start initialization:
 * - Init functions execute once per execution environment (cold start)
 * - Snapshot is cached and reused for warm invocations
 * - Event is enhanced with both `ties` and `snapshot` properties
 *
 * @example
 * ```typescript
 * // Object-based ties (new pattern)
 * const handler = new RuntimeWebLambdaHandler(definition, registrar, factory);
 * // Handler receives: async (event, context) => { event.ties.userService... }
 *
 * // Array-based ties (legacy pattern)
 * const handler = new RuntimeWebLambdaHandler(definition, registrar, factory);
 * // Handler receives: (ties) => async (event, context) => { ties.userService... }
 *
 * // With init function
 * const handler = new RuntimeWebLambdaHandler(definition, container, factory, initManager, microserviceDef);
 * // Handler receives: async (event, context) => { event.ties.userService, event.snapshot.dbConnection... }
 * ```
 */
export declare class RuntimeWebLambdaHandler extends LambdaApi implements LambdaInterface {
    private readonly definition;
    private readonly container;
    private readonly factory;
    private readonly logger;
    private readonly userHandler;
    /**
     * InitManager instance for cold start initialization.
     * Optional - when not provided, init functions are not executed.
     */
    private readonly initManager?;
    /**
     * Microservice definition for microservice-level init.
     * Optional - when not provided, only lambda-level init is executed.
     */
    private readonly microserviceDefinition?;
    /**
     * Cached snapshot from init function execution.
     * Populated on first invocation (cold start) and reused for warm invocations.
     */
    private snapshot;
    /**
     * Flag indicating whether init has been executed.
     * Used to determine cold start vs warm invocation.
     */
    private initExecuted;
    /**
     * Create a Runtime Web Lambda handler.
     *
     * @param definition - Lambda definition with handler and dependencies (supports both formats)
     * @param container - DI container for dependency resolution
     * @param factory - Factory instance for dependency injection and wrapping
     * @param initManager - Optional InitManager for cold start initialization
     * @param microserviceDefinition - Optional microservice definition for microservice-level init
     */
    constructor(definition: LambdaDefinition, container: PureContainer<string>, factory: LambdaHandlerFactory, initManager?: InitManager, microserviceDefinition?: MicroserviceDefinition);
    /**
     * Get the full Lambda ID for caching purposes.
     *
     * @returns Full Lambda ID in format `{service}.{id}` or just `{id}` if no service
     */
    private getLambdaId;
    /**
     * Main Lambda handler method called by AWS Lambda runtime.
     *
     * This method is called by the AWS Lambda runtime for each invocation.
     * It injects dependencies, enhances the event object with typed ties,
     * calls the user's handler function, and returns the result.
     *
     * For object-based ties: Enhances event with ties and snapshot properties before calling handler
     * For array-based ties: Uses legacy factory pattern with ties parameter
     *
     * ## Cold Start Initialization
     *
     * On first invocation (cold start), if an InitManager is provided:
     * 1. Executes microservice-level init (if defined)
     * 2. Executes lambda-level init (if defined)
     * 3. Merges snapshots (lambda overrides microservice)
     * 4. Caches snapshot for warm invocations
     *
     * @param event - Lambda event object (will be enhanced with ties and snapshot for object-based ties)
     * @param context - Lambda context object
     * @returns Promise resolving to the handler result
     *
     * @example
     * ```typescript
     * // Object-based ties - event is enhanced with ties and snapshot
     * const result = await handler.handler(apiGatewayEvent, lambdaContext);
     * // Handler receives: { ...apiGatewayEvent, ties: { userService: UsersService }, snapshot: { dbConnection: Connection } }
     *
     * // Array-based ties - legacy factory pattern
     * const result = await handler.handler(apiGatewayEvent, lambdaContext);
     * // Handler receives: (ties) => async (event, context) => {}
     * ```
     */
    handler(event: unknown, context: unknown): Promise<unknown>;
    /**
     * Create the user handler with dependency injection and wrapping.
     *
     * This method is called once during construction to resolve dependencies
     * and create the wrapped user handler. The result is cached for reuse
     * across Lambda invocations to avoid repeated DI resolution.
     *
     * For object-based ties: Returns a no-op handler since event enhancement happens at runtime
     * For array-based ties: Creates wrapped handler with injected dependencies (legacy pattern)
     *
     * @returns Wrapped user handler with dependencies injected (or no-op for object-based)
     * @private
     */
    private createUserHandler;
    /**
     * Get the Lambda definition used by this handler.
     *
     * Provides access to the original Lambda definition for debugging
     * or introspection purposes.
     *
     * @returns The Lambda definition (supports both formats)
     */
    getDefinition(): LambdaDefinition;
    /**
     * Get the PureContainer used by this handler.
     *
     * Provides access to the DI container for debugging or advanced
     * use cases. Generally not needed in normal operation.
     *
     * @returns The PureContainer instance
     */
    getContainer(): PureContainer<string>;
    /**
     * Get the InitManager used by this handler.
     *
     * Provides access to the InitManager for debugging or advanced
     * use cases. Returns undefined if no InitManager was provided.
     *
     * @returns The InitManager instance or undefined
     */
    getInitManager(): InitManager | undefined;
    /**
     * Get the microservice definition used by this handler.
     *
     * Provides access to the microservice definition for debugging
     * or introspection purposes. Returns undefined if not provided.
     *
     * @returns The MicroserviceDefinition or undefined
     */
    getMicroserviceDefinition(): MicroserviceDefinition | undefined;
    /**
     * Check if init has been executed for this handler.
     *
     * Returns true if the init functions have been executed (cold start
     * has occurred), false otherwise.
     *
     * @returns True if init has been executed, false otherwise
     */
    hasInitExecuted(): boolean;
    /**
     * Get the cached snapshot from init function execution.
     *
     * Returns the snapshot that was returned by the init functions.
     * Returns an empty object if no init functions were defined or
     * if init has not yet been executed.
     *
     * @returns The cached snapshot
     */
    getSnapshot(): unknown;
    /**
     * Check if the handler has been properly initialized.
     *
     * Verifies that the user handler has been created successfully
     * and is ready for invocation. For object-based ties, always returns
     * true since event enhancement happens at runtime.
     *
     * @returns True if handler is ready, false otherwise
     */
    isReady(): boolean;
}
