import { Construct } from 'constructs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as iam from 'aws-cdk-lib/aws-iam';
import type { LambdaDefinition, VpcConfig } from '../../../lib/runtime-web/types';
import { RuntimeInfraResourceOptions, RuntimeInfraResources } from '../../interfaces';
import { RuntimeWebStackProps } from '../../runtime-web';
/**
 * Properties for LambdaBuilder construct
 */
export interface LambdaBuilderProps {
    /**
     * Deployment stage
     */
    stage: 'dev' | 'staging' | 'prod';
    /**
     * Service name for resource naming
     */
    serviceName: string;
    /**
     * IAM role for Lambda execution
     */
    lambdaRole: iam.IRole;
    /**
     * Default memory size in MB
     * @default 512
     */
    defaultMemorySize?: number;
    /**
     * Default timeout in seconds
     * @default 30
     */
    defaultTimeout?: number;
    /**
     * Global environment variables
     */
    globalEnvironment?: Record<string, string>;
    /**
     * VPC configuration
     */
    vpc?: VpcConfig;
}
/**
 * LambdaBuilder - CDK construct for building Lambda functions from definitions.
 *
 * Creates Lambda functions with proper configuration, environment variables,
 * IAM permissions, and CloudWatch log groups. Supports VPC deployment and
 * X-Ray tracing.
 *
 * **Features**:
 * - Automatic Lambda function creation from LambdaDefinition
 * - Environment variable injection (LAMBDA_ID, SERVICE_NAME, STAGE)
 * - CloudWatch log group with retention policy
 * - X-Ray tracing support
 * - VPC deployment support
 * - AWS SDK v3 externalization for bundle size optimization
 *
 * **Requirements**: REQ-11, REQ-13
 *
 * @example
 * ```typescript
 * const builder = new LambdaBuilder(this, 'LambdaBuilder', {
 *   stage: 'dev',
 *   serviceName: 'my-app',
 *   lambdaRole,
 *   defaultMemorySize: 512,
 *   defaultTimeout: 30
 * });
 *
 * const lambdaFn = builder.buildLambda('payments.charge', 'payments', lambdaDef);
 * ```
 */
export declare class LambdaBuilder extends Construct implements RuntimeInfraResources {
    private readonly props;
    private readonly vpc?;
    private readonly securityGroups?;
    private readonly subnets?;
    constructor(scope: Construct, id: string, props: LambdaBuilderProps);
    /**
     * Build a Lambda function from a LambdaDefinition.
     *
     * Creates a Lambda function with proper configuration, environment variables,
     * and CloudWatch log group. The function is configured for Runtime Web Core
     * with DI support and attached to its microservice's Lambda Layer.
     *
     * **Hash-Based Resolution**: Computes hash key at build time using hash32Base64Url
     * and passes it to getLambdaCode() for handler resolution. Includes hash algorithm
     * in environment variables for debugging.
     *
     * **Requirements**: 6.6, 11.4
     *
     * @param props - Stack properties
     * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
     * @param microserviceName - Name of the parent microservice
     * @param definition - Lambda definition with handler and configuration
     * @param layer - Optional Lambda Layer for this microservice
     * @returns Lambda Function instance
     *
     * @example
     * ```typescript
     * const lambdaFn = builder.buildLambda(props, 'payments.charge', 'payments', {
     *   id: 'charge',
     *   ties: [PaymentsService],
     *   handler: (ties) => async (event) => { ... },
     *   http: { method: 'POST', path: '/api/payments/charge' },
     *   config: { memorySize: 1024, timeout: 60 }
     * }, paymentsLayer);
     * ```
     */
    buildLambda(props: RuntimeWebStackProps, lambdaId: string, microserviceName: string, definition: LambdaDefinition, layer?: lambda.LayerVersion): lambda.Function;
    /**
     * Build environment variables for Lambda function.
     *
     * Combines global environment variables with Lambda-specific variables
     * including LAMBDA_ID, SERVICE_NAME, STAGE, hash algorithm, and handler hash key for debugging.
     *
     * **Requirements**: 11.4, 6.6
     *
     * @param lambdaId - Full Lambda ID
     * @param serviceName - Name of the parent microservice
     * @param definition - Lambda definition
     * @param hashKey - Hash key computed for the handler
     * @returns Environment variables record
     * @private
     */
    private buildEnvironment;
    /**
     * Get Lambda code asset.
     *
     * Returns the Lambda code asset for the function. For Runtime Web Core,
     * this uses the new bundle import structure that imports the MicroserviceBundle
     * from the Lambda Layer and uses the getHandler() method with HASH-BASED keys.
     *
     * CRITICAL: Lambda uses HASH KEY computed at build time via hash32Base64Url(handlerCode.toString())
     * because the Lambda is already inside its microservice's Lambda Layer.
     *
     * **Requirements**: 6.1, 6.2, 6.3, 6.4, 6.5, 6.6
     *
     * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
     * @param definition - Lambda definition
     * @param hashKey - Hash key computed at build time
     * @returns Lambda Code asset
     * @private
     */
    private getLambdaCode;
    /**
     * Add IAM permissions to Lambda function.
     *
     * Adds additional IAM permissions to the Lambda function's execution role.
     *
     * @param lambdaFunction - Lambda function to add permissions to
     * @param permissions - Array of IAM policy statements
     */
    addPermissions(lambdaFunction: lambda.Function, permissions: iam.PolicyStatement[]): void;
    /**
     * Compute hash key for a Lambda handler.
     *
     * Computes a stable hash key using hash32Base64Url(handlerCode.toString()).
     * This hash key is used for handler resolution in the MicroserviceBundle.
     *
     * The hash key computation follows these steps:
     * 1. Convert handler function to string representation
     * 2. Compute SHA-256 hash of the string
     * 3. Encode as Base64 URL-safe string (32 characters)
     * 4. Store hash-to-name mapping for debugging
     *
     * **Requirements**: 2.2, 6.5, 6.6
     *
     * @param definition - Lambda definition with handler function
     * @returns Hash key computed via hash32Base64Url
     * @private
     */
    private computeHandlerHashKey;
    /**
     * Extract SHORT Lambda ID from full Lambda ID.
     *
     * Converts full Lambda ID (e.g., 'payments.charge') to short ID (e.g., 'charge').
     * If Lambda definition has explicit ID, uses that. Otherwise extracts from full ID.
     *
     * NOTE: This method is kept for backward compatibility but hash-based resolution
     * is now preferred over short Lambda IDs.
     *
     * @param fullLambdaId - Full Lambda ID (e.g., 'payments.charge')
     * @param definition - Lambda definition
     * @returns Short Lambda ID (e.g., 'charge')
     * @private
     */
    private extractShortLambdaId;
    /**
     * Generates a signature for the provided region by extracting the first character of each segment in the region string, delimited by hyphens.
     *
     * @param {string} region - The region string to generate the signature from. It is expected to be a hyphen-separated string.
     * @return {string} The generated region signature, formed by concatenating the first character of each valid segment. Returns an empty string if the input is invalid or empty.
     */
    private getRegionSignature;
    /**
     * Generates a resource name by concatenating service name, resource name,
     * simplified region, and stage with hyphens as separators.
     *
     * @param {Object} params - An object containing the required parameters.
     * @param {string} params.name - The name of the resource.
     * @param {string} params.serviceName - The name of the service associated with the resource.
     * @param {string} params.regionSimplified - The simplified region identifier.
     * @param {string} params.stage - The deployment stage of the resource.
     * @returns {string} The concatenated resource name.
     */
    resourceName({ name, serviceName, stage, region }: RuntimeInfraResourceOptions): string;
}
