import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigatewayv2 from 'aws-cdk-lib/aws-apigatewayv2';
import type { MicroserviceDefinition, VpcConfig } from '../../../lib/runtime-web/types';
import { MicroserviceRegistrar } from '../../../core/runtime-web/registrar';
import type { RuntimeInfraStack } from '../../runtime-infra-stack';
import { MicroserviceLayerBundleResult, MicroserviceLayerOptions } from '../../utils';
/**
 * Properties for RuntimeWebStack
 */
export interface RuntimeWebStackProps extends cdk.StackProps {
    /**
     * Deployment stage (dev, staging, prod)
     */
    stage: 'dev' | 'staging' | 'prod';
    /**
     * Service name for resource naming
     */
    serviceName: string;
    /**
     * Reference to Infra stack for cross-stack references
     */
    infraStack: RuntimeInfraStack;
    /**
     * Path to user's application entry point
     * @example './src/index.tsx'
     */
    appEntryPoint?: string;
    /**
     * Microservice registry with service definitions
     */
    register: Record<string, MicroserviceDefinition>;
    /**
     * API exposure mode
     * @default 'apiGateway'
     */
    apiMode?: 'apiGateway' | 'lambdaUrl';
    /**
     * Default Lambda memory size in MB
     * @default 512
     */
    lambdaMemorySize?: number;
    /**
     * Default Lambda timeout in seconds
     * @default 30
     */
    lambdaTimeout?: number;
    /**
     * Enable Lambda warmup
     * @default false
     */
    enableWarmup?: boolean;
    /**
     * VPC configuration for Lambda functions
     */
    vpc?: VpcConfig;
    /**
     * Global environment variables for all Lambda functions
     */
    environment?: Record<string, string>;
}
/**
 * RuntimeWebStack - CDK stack for Runtime Web Core microservices.
 *
 * Creates Lambda functions and API Gateway from microservice definitions.
 * Extends the existing Runtime infrastructure with microservice support.
 *
 * **Features**:
 * - Automatic Lambda function creation from LambdaDefinition
 * - API Gateway with HTTP routes for Lambda endpoints
 * - Environment variable injection (LAMBDA_ID, SERVICE_NAME, STAGE)
 * - VPC support for private resources
 * - Lambda warmup for reduced cold starts
 *
 * **Requirements**: REQ-11, REQ-13, REQ-14
 *
 * @example
 * ```typescript
 * const runtimeWebStack = new RuntimeWebStack(app, 'my-app-runtime-dev', {
 *   stage: 'dev',
 *   serviceName: 'my-app',
 *   infraStack,
 *   register: {
 *     payments: {
 *       ties: [PaymentsTies],
 *       lambdas: [chargeHandler, refundHandler]
 *     }
 *   },
 *   apiMode: 'apiGateway',
 *   lambdaMemorySize: 512,
 *   lambdaTimeout: 30
 * });
 * ```
 */
export declare class RuntimeWebStack extends cdk.Stack {
    /**
     * Map of Lambda functions by Lambda ID
     */
    readonly lambdaFunctions: Map<string, lambda.Function>;
    /**
     * Map of Lambda Layers by microservice name.
     * Each microservice gets its own Lambda Layer with its own MicroserviceBundle.
     */
    readonly microserviceLayers: Map<string, lambda.LayerVersion>;
    /**
     * API Gateway HttpApi (if apiMode is 'apiGateway')
     */
    readonly apiGateway?: apigatewayv2.HttpApi;
    /**
     * API Gateway stage
     */
    readonly apiGatewayStage?: apigatewayv2.HttpStage;
    /**
     * Microservice registrar for DI container management
     */
    private readonly registrar;
    /**
     * Lambda builder construct
     */
    private readonly lambdaBuilder;
    /**
     * API Gateway builder construct
     */
    private readonly apiGatewayBuilder;
    /**
     * IAM role for Lambda execution
     */
    private readonly lambdaRole;
    constructor(scope: Construct, id: string, props: RuntimeWebStackProps);
    /**
     * Register microservices and build DI containers.
     *
     * Processes each microservice definition to create PureContainer instances
     * and establish Lambda-to-service mappings.
     *
     * @param register - Microservice registry
     * @private
     */
    private registerMicroservices;
    /**
     * Create Lambda Layers for each microservice.
     *
     * Each microservice gets its own Lambda Layer containing:
     * - MicroserviceBundle with DI container
     * - All dependencies (Ties classes)
     * - Pre-created Lambda instances with bound handlers
     *
     * This follows the architectural principle: One Microservice = One Lambda Layer = One DI Container
     *
     * @param props - Stack properties
     * @private
     */
    private createMicroserviceLayers;
    /**
     * Constructs and returns a sanitized build directory string for the given microservice layer.
     *
     * @param props - The properties of the runtime web stack, including service name and stage.
     * @param microserviceName - The name of the microservice for which the layer directory is being constructed.
     * @return The sanitized name of the layer build directory.
     */
    private layerBuildDirectory;
    /**
     * Create a Lambda Layer for a specific microservice.
     *
     * The Layer contains the MicroserviceBundle with:
     * - DI container created at bundle load time
     * - All Lambda handlers as pre-bound methods
     * - No DI resolution on invoke
     *
     * @param props - Stack properties
     * @param microserviceName - Name of the microservice
     * @param definition - Microservice definition
     * @returns Lambda LayerVersion
     * @private
     */
    private createMicroserviceLayer;
    /**
     * Create Lambda functions for all registered microservices.
     *
     * Iterates through all microservice definitions and creates Lambda
     * functions for each LambdaDefinition with proper environment variables.
     * Each Lambda function is attached to its microservice's Lambda Layer.
     *
     * @param props - Stack properties
     * @private
     */
    private createLambdaFunctions;
    /**
     * Build global environment variables for Lambda functions.
     *
     * Creates environment variables that are shared across all Lambda functions
     * including infrastructure references from the Infra stack.
     *
     * @param props - Stack properties
     * @returns Environment variables record
     * @private
     */
    private buildGlobalEnvironment;
    /**
     * Create CloudFormation outputs for stack resources.
     *
     * @param props - Stack properties
     * @private
     */
    private createOutputs;
    /**
     * Get Lambda function by ID.
     *
     * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
     * @returns Lambda function or undefined
     */
    getLambdaFunction(lambdaId: string): lambda.Function | undefined;
    /**
     * Get all Lambda IDs.
     *
     * @returns Array of Lambda IDs
     */
    getLambdaIds(): string[];
    /**
     * Get the microservice registrar.
     *
     * @returns MicroserviceRegistrar instance
     */
    getRegistrar(): MicroserviceRegistrar;
    /**
     * Get Lambda Layer for a microservice.
     *
     * @param serviceName - Name of the microservice
     * @returns Lambda LayerVersion or undefined
     */
    getMicroserviceLayer(serviceName: string): lambda.LayerVersion | undefined;
    /**
     * Get all microservice names that have Lambda Layers.
     *
     * @returns Array of microservice names
     */
    getMicroserviceNames(): string[];
    /**
     * Build Lambda Layer bundles for multiple microservices.
     *
     * Creates separate Lambda Layer bundles for each microservice in the register.
     * Each bundle contains its own MicroserviceBundle with isolated DI container.
     *
     * @param register - Map of microservice names to their definitions
     * @param appEntryPoint - Path to the user's application entry point
     * @param stage
     * @param options - Additional build options
     * @returns Map of microservice names to their build results
     *
     * @important: this functions is bint to RuntimeWebStack instance during its call
     */
    buildAllMicroserviceLayerBundles(register: Record<string, MicroserviceDefinition>, stage: string, appEntryPoint?: string, options?: {
        minify?: boolean;
        sourcemap?: boolean;
    }): Map<string, MicroserviceLayerBundleResult>;
    /**
     * Build a Lambda Layer bundle for a specific microservice.
     *
     * Each microservice gets its own Lambda Layer containing:
     * - MicroserviceBundle with DI container (created at bundle load time)
     * - All dependencies (Ties classes)
     * - Pre-created Lambda instances with bound handlers
     * - node_modules/ with React, ReactDOM, React Router (peer ties)
     *
     * This follows the architectural principle:
     * - One Microservice = One Lambda Layer = One DI Container
     * - DI at bundle load time, NOT on invoke
     * - Handler = pre-bound method, invoke = just method call
     *
     * **Validates: Requirements 7.2, 7.4**
     *
     * @param options - Microservice layer options
     * @param definition
     * @returns Build result with bundle path and size
     */
    buildMicroserviceLayerBundle(options: MicroserviceLayerOptions, definition?: MicroserviceDefinition): MicroserviceLayerBundleResult;
}
