import type { MicroserviceDefinition } from '../../lib/runtime-web/types/microservice.types';
import { MicroserviceLayerBundleResult, MicroserviceLayerOptions } from '../../infra/utils/lambda-bundler';
import type { BuildCache } from './microservice-bundle-builder.types';
/**
 * Options for building all microservice bundles.
 */
export interface BuildAllMicroservicesOptions {
    /** Whether to minify the bundles */
    minify?: boolean;
    /** Whether to generate sourcemaps */
    sourcemap?: boolean;
    /** Force rebuild even if bundles exist and are up-to-date */
    force?: boolean;
    /** Enable verbose logging with detailed build output */
    verbose?: boolean;
}
/**
 * Service responsible for building microservice Lambda Layer bundles.
 *
 * Extracts build logic from RuntimeWebStack to enable pre-synthesis builds.
 * Uses the same esbuild configuration and output structure.
 *
 * **Validates: Requirements 1.4, 6.1, 6.4**
 */
export declare class MicroserviceBundleBuilderService {
    private readonly cwd;
    constructor(cwd?: string);
    /**
     * Result of building all microservice bundles, including partial failures.
     *
     * **Validates: Requirements 1.7, 7.1**
     */
    buildAllMicroserviceBundlesResult: {
        results: Map<string, MicroserviceLayerBundleResult>;
        errors: Array<{
            microserviceName: string;
            error: string;
        }>;
    } | null;
    /**
     * Build all microservice bundles from the register.
     *
     * Implements partial failure handling: if one microservice fails to build,
     * the remaining microservices will still be built. All errors are collected
     * and returned at the end.
     *
     * @param register - Map of microservice names to definitions
     * @param stage - Deployment stage
     * @param appEntryPoint - Path to user's application entry point
     * @param options - Build options (minify, sourcemap, force, verbose)
     * @returns Map of microservice names to build results
     *
     * **Validates: Requirements 1.4, 1.7, 6.1, 7.1, 7.3**
     */
    buildAllMicroserviceBundles(register: Record<string, MicroserviceDefinition>, stage: string, appEntryPoint: string, options?: BuildAllMicroservicesOptions): Promise<Map<string, MicroserviceLayerBundleResult>>;
    /**
     * Get the errors from the last build operation.
     *
     * Returns an empty array if no build has been performed or if
     * the last build had no errors.
     *
     * **Validates: Requirements 1.7, 7.1**
     */
    getLastBuildErrors(): Array<{
        microserviceName: string;
        error: string;
    }>;
    /**
     * Build a single microservice bundle.
     *
     * 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
     *
     * @param options - Microservice layer options
     * @returns Build result with bundle path and size
     *
     * **Validates: Requirements 1.4, 7.3**
     */
    buildMicroserviceBundle(options: MicroserviceLayerOptions): MicroserviceLayerBundleResult;
    /**
     * Check if a microservice bundle needs rebuilding.
     *
     * Uses a multi-level cache invalidation strategy:
     * 1. If bundle file doesn't exist → rebuild needed
     * 2. If cache entry doesn't exist → rebuild needed
     * 3. If source files hash changed → rebuild needed
     * 4. If bundle file hash changed (external modification) → rebuild needed
     *
     * @param microserviceName - Name of the microservice
     * @param stage - Deployment stage
     * @param appEntryPoint - Path to user's application entry point
     * @returns true if rebuild is needed, false otherwise
     *
     * **Validates: Requirements 6.1, 6.4**
     */
    needsRebuild(microserviceName: string, stage: string, appEntryPoint: string): boolean;
    /**
     * Log the reason why a rebuild is needed (verbose mode only).
     *
     * Performs the same checks as needsRebuild but logs the specific reason.
     *
     * @param microserviceName - Name of the microservice
     * @param stage - Deployment stage
     * @param appEntryPoint - Path to user's application entry point
     *
     * **Validates: Requirements 7.3**
     */
    private logRebuildReason;
    /**
     * Get the output directory for a microservice bundle.
     *
     * Returns the path following the pattern:
     * `cdk.out/microservice-bundles/{microserviceName}-layer-{stage}/nodejs/bundle.js`
     *
     * @param microserviceName - Name of the microservice
     * @param stage - Deployment stage
     * @returns Full path to the bundle file
     *
     * **Validates: Requirements 1.4, 3.1**
     */
    getBundleOutputPath(microserviceName: string, stage: string): string;
    /**
     * Get the path to the build cache file.
     *
     * The cache file is stored at `cdk.out/.build-cache.json`.
     *
     * @returns Full path to the cache file
     *
     * **Validates: Requirements 6.1, 6.4**
     */
    getCachePath(): string;
    /**
     * Read the build cache from disk.
     *
     * Returns an empty cache if:
     * - Cache file doesn't exist
     * - Cache file is corrupted/invalid JSON
     * - Cache version doesn't match current version
     *
     * @returns The build cache object
     *
     * **Validates: Requirements 6.1, 6.4**
     */
    readCache(): BuildCache;
    /**
     * Write the build cache to disk.
     *
     * Creates the cdk.out/ directory if it doesn't exist.
     * Writes the cache atomically to prevent corruption.
     *
     * @param cache - The build cache to write
     *
     * **Validates: Requirements 6.1, 6.4**
     */
    writeCache(cache: BuildCache): void;
    /**
     * Update a single cache entry after a successful build.
     *
     * @param microserviceName - Name of the microservice
     * @param stage - Deployment stage
     * @param bundlePath - Path to the built bundle
     * @param appEntryPoint - Path to the application entry point
     *
     * **Validates: Requirements 6.1, 6.4**
     */
    updateCacheEntry(microserviceName: string, stage: string, bundlePath: string, appEntryPoint: string): void;
    /**
     * Generate a cache key for a microservice.
     *
     * Format: `{microserviceName}-{stage}`
     *
     * @param microserviceName - Name of the microservice
     * @param stage - Deployment stage
     * @returns Cache key string
     *
     * **Validates: Requirements 6.1, 6.4**
     */
    getCacheKey(microserviceName: string, stage: string): string;
    /**
     * Compute a hash of the source files that contribute to a bundle.
     *
     * Currently hashes the entry point file content and its modification time.
     * This provides a balance between accuracy and performance.
     *
     * @param absoluteEntryPoint - Absolute path to the entry point file
     * @returns SHA-256 hash of source files (first 16 chars)
     *
     * **Validates: Requirements 6.1, 6.4**
     */
    computeSourceFilesHash(absoluteEntryPoint: string): string;
    /**
     * Compute a hash of a file's contents.
     *
     * @param filePath - Path to the file
     * @returns SHA-256 hash of file contents (first 16 chars), or empty string if file doesn't exist
     *
     * **Validates: Requirements 6.1, 6.4**
     */
    computeFileHash(filePath: string): string;
    /**
     * Create an empty build cache with the current version.
     *
     * @returns Empty build cache object
     */
    private createEmptyCache;
    /**
     * Resolve the entry point path to an absolute path.
     *
     * Tries multiple resolution strategies:
     * 1. If already absolute, use as-is
     * 2. Resolve relative to cwd
     * 3. Resolve relative to parent of cwd (for cdk/ subdirectory)
     *
     * @param appEntryPoint - Path to the entry point (may be relative)
     * @returns Absolute path to entry point, or null if not found
     */
    private resolveEntryPoint;
    /**
     * Generate the Lambda Layer entry code for a microservice.
     *
     * This code is bundled into the Lambda Layer and:
     * 1. Imports the user's application (executes runtime())
     * 2. Gets the microservice definition from runtimeThreads.register
     * 3. Creates an isolated MicroserviceBundle with DI container
     * 4. Exports the bundle for Lambda handlers to use
     *
     * @param microserviceName - Name of the microservice
     * @param absoluteEntryPoint - Absolute path to user's app entry point
     * @param libPath - Path to runtime lib bundle
     * @param pipelinesBundlePath - Path to pipelines bundle
     * @returns Generated entry code string
     */
    private generateLayerEntryCode;
}
