import type { HttpIntegration } from './http.types';
import type { APIGatewayProxyEvent, Context } from 'aws-lambda';
/**
 * Initialization function type that executes during Lambda cold start.
 *
 * Init functions run once per Lambda execution environment (cold start only),
 * before the first handler invocation. The returned snapshot is cached and
 * available to all subsequent warm invocations via `event.snapshot`.
 *
 * ## Use Cases
 *
 * - **Database connections**: Establish connections once during cold start
 * - **Configuration loading**: Load and parse configuration files
 * - **SDK client warming**: Pre-initialize AWS SDK clients
 * - **Cache priming**: Pre-load frequently accessed data
 *
 * ## Execution Timing
 *
 * ```
 * Cold Start:
 *   1. Lambda execution environment created
 *   2. Init function executes (receives ties instances)
 *   3. Snapshot cached for reuse
 *   4. Handler invoked with event.snapshot
 *
 * Warm Invocation:
 *   1. Cached snapshot retrieved
 *   2. Handler invoked with event.snapshot (no init execution)
 * ```
 *
 * ## Type Safety
 *
 * The snapshot type is inferred from the init function's return type:
 *
 * ```typescript
 * // Init returns { dbConnection: Connection; config: AppConfig }
 * // event.snapshot is typed as { dbConnection: Connection; config: AppConfig }
 * ```
 *
 * @template TTies - Type of the ties object containing DI instances
 * @template TSnapshot - Type of the snapshot object returned by init
 *
 * @example Basic Usage
 * ```typescript
 * type MyTies = { dbService: DatabaseService; configService: ConfigService };
 * type MySnapshot = { dbConnection: Connection; config: AppConfig };
 *
 * const init: InitFunction<MyTies, MySnapshot> = async (ties) => {
 *   const dbConnection = await ties.dbService.connect();
 *   const config = await ties.configService.loadConfig();
 *   return { dbConnection, config };
 * };
 * ```
 *
 * @example With LambdaDefinition
 * ```typescript
 * type MyTies = { dbService: DatabaseService };
 * type MySnapshot = { connection: Connection };
 *
 * const handler: LambdaDefinition<MyTies, MySnapshot> = {
 *   ties: { dbService: DatabaseService },
 *   init: async (ties) => {
 *     const connection = await ties.dbService.connect();
 *     return { connection };
 *   },
 *   handler: async (event, context) => {
 *     // event.snapshot.connection is fully typed as Connection
 *     const result = await event.snapshot.connection.query('SELECT * FROM users');
 *     return { statusCode: 200, body: JSON.stringify(result) };
 *   }
 * };
 * ```
 *
 * @example Async Operations
 * ```typescript
 * const init: InitFunction<MyTies, MySnapshot> = async (ties) => {
 *   // Supports full async/await
 *   const [config, secrets] = await Promise.all([
 *     ties.configService.loadConfig(),
 *     ties.secretsService.loadSecrets()
 *   ]);
 *
 *   // Can use setTimeout, setImmediate, etc.
 *   await new Promise(resolve => setTimeout(resolve, 100));
 *
 *   return { config, secrets };
 * };
 * ```
 *
 * @see {@link LambdaDefinition} - Uses InitFunction for the init property
 * @see {@link LambdaEvent} - Provides snapshot access via event.snapshot
 */
export type InitFunction<TTies, TSnapshot> = (ties: TTies) => Promise<TSnapshot>;
/**
 * Extracts the constructor type for a class.
 * Maps an instance type to its constructor type.
 *
 * This utility type is the foundation of the ties type transformation system.
 * It enables the framework to accept class constructors in the `ties` property
 * while providing instance types in the handler's `event.ties`.
 *
 * ## Type Transformation Explained
 *
 * In TypeScript, when you write `UsersService` as a type, it refers to the
 * **instance type** (an object with methods like `getUser()`). But when you
 * write `UsersService` as a value (e.g., in `ties: { userService: UsersService }`),
 * you're passing the **class constructor** itself.
 *
 * This type bridges that gap by converting instance types to constructor types,
 * allowing the type system to understand that:
 * - `ties` property accepts class constructors
 * - `event.ties` provides instantiated objects with methods
 *
 * ## How It Works
 *
 * ```
 * Instance Type:     UsersService (has methods like getUser())
 *                         ↓
 * Constructor<T>:    new (...args: any[]) => UsersService
 *                         ↓
 * Accepts:           The UsersService class itself as a value
 * ```
 *
 * @template T - The instance type to transform (e.g., `UsersService`)
 * @returns Constructor type that creates instances of T
 *
 * @example Basic Usage
 * ```typescript
 * class UsersService {
 *   getUser(id: string): User { ... }
 * }
 *
 * // Constructor<UsersService> = new (...args: any[]) => UsersService
 * type UserServiceConstructor = Constructor<UsersService>;
 *
 * // This allows passing the class itself as a value:
 * const ctor: UserServiceConstructor = UsersService; // ✓ Valid
 * const instance = new ctor(); // Creates UsersService instance
 * ```
 *
 * @example With Generic Services
 * ```typescript
 * class Repository<T> {
 *   find(id: string): T { ... }
 * }
 *
 * // Works with generic types too
 * type UserRepoConstructor = Constructor<Repository<User>>;
 * ```
 *
 * @see {@link TiesConstructors} - Uses Constructor to transform entire ties objects
 * @see {@link LambdaDefinition} - Uses these types for the ties property
 */
export type Constructor<T> = new (...args: any[]) => T;
/**
 * Transforms an object of instance types to an object of constructor types.
 *
 * This is the key utility type that enables the ties type safety pattern.
 * It allows developers to:
 * 1. Define a single type with instance types for handler access
 * 2. Pass class constructors in the `ties` property
 * 3. Get fully typed instance access in `event.ties`
 *
 * ## The Problem This Solves
 *
 * Without this type, there's a mismatch between what developers write and
 * what TypeScript expects:
 *
 * ```typescript
 * // Developer wants to write:
 * type MyTies = { userService: UsersService };  // Instance type for handler
 *
 * // But ties property receives class constructors:
 * ties: { userService: UsersService }  // UsersService here is the CLASS, not instance
 *
 * // TypeScript error! It expects an instance, not a constructor.
 * ```
 *
 * `TiesConstructors<T>` transforms the type so TypeScript understands that
 * the `ties` property should accept constructors, not instances.
 *
 * ## Type Transformation Flow
 *
 * ```
 * Developer defines:
 *   type MyTies = { userService: UsersService; configService: ConfigService }
 *
 * TiesConstructors<MyTies> produces:
 *   {
 *     userService: new (...args: any[]) => UsersService;
 *     configService: new (...args: any[]) => ConfigService;
 *   }
 *
 * This accepts:
 *   ties: { userService: UsersService, configService: ConfigService }
 *   // Where UsersService and ConfigService are class constructors ✓
 * ```
 *
 * @template T - Object type mapping property names to instance types
 * @returns Object type mapping same property names to constructor types
 *
 * @example Complete Usage Pattern
 * ```typescript
 * // Step 1: Define your service classes
 * class UsersService {
 *   getUser(id: string): Promise<User> { ... }
 *   createUser(data: UserData): Promise<User> { ... }
 * }
 *
 * class ConfigService {
 *   getValue(key: string): string { ... }
 * }
 *
 * // Step 2: Define instance types for handler access
 * type MyTies = {
 *   userService: UsersService;
 *   configService: ConfigService;
 * };
 *
 * // Step 3: Use in LambdaDefinition - ties accepts constructors
 * const handler: LambdaDefinition<MyTies> = {
 *   ties: {
 *     userService: UsersService,     // ✓ Class constructor accepted
 *     configService: ConfigService   // ✓ Class constructor accepted
 *   },
 *   handler: async (event) => {
 *     // event.ties has instance types with full IntelliSense
 *     const user = await event.ties.userService.getUser('123');
 *     const config = event.ties.configService.getValue('API_KEY');
 *     return { statusCode: 200, body: JSON.stringify(user) };
 *   }
 * };
 * ```
 *
 * @example Manual Type Transformation
 * ```typescript
 * type MyTies = {
 *   userService: UsersService;
 *   configService: ConfigService;
 * };
 *
 * // TiesConstructors<MyTies> is equivalent to:
 * type MyTiesConstructors = {
 *   userService: new (...args: any[]) => UsersService;
 *   configService: new (...args: any[]) => ConfigService;
 * };
 *
 * // You can use it directly if needed:
 * const tiesConfig: TiesConstructors<MyTies> = {
 *   userService: UsersService,
 *   configService: ConfigService
 * };
 * ```
 *
 * @see {@link Constructor} - The underlying type used for each property
 * @see {@link LambdaDefinition} - Uses TiesConstructors for the ties property
 * @see {@link LambdaEvent} - Provides instance types in event.ties
 */
export type TiesConstructors<T> = {
    [K in keyof T]: Constructor<T[K]>;
};
/**
 * Lambda handler factory function type.
 *
 * Receives injected dependencies and returns a Lambda handler function.
 * Dependencies are automatically resolved from the microservice's PureContainer
 * based on the class references in the ties array.
 *
 * @param ties - Object containing injected dependencies (camelCase keys)
 * @returns Lambda handler function
 *
 * @example
 * ```typescript
 * const chargeHandler: LambdaHandlerFactory = (ties) => {
 *   return async (event, context) => {
 *     // ties.paymentsService is automatically injected
 *     return await ties.paymentsService.processCharge(event.body);
 *   };
 * };
 * ```
 */
export type LambdaHandlerFactory = (ties: Record<string, unknown>) => (event: unknown, context: unknown) => Promise<unknown>;
/**
 * Lambda-specific configuration overrides.
 *
 * Allows overriding global Lambda settings for specific functions.
 * All properties are optional and will fall back to global defaults.
 */
export interface LambdaConfig {
    /**
     * Memory allocation for this Lambda function (MB).
     *
     * **Range**: 128 - 10240 MB
     * **Default**: Uses global lambdaMemorySize from InfraOptions
     *
     * @example
     * ```typescript
     * memorySize: 1024  // 1GB memory
     * ```
     */
    memorySize?: number;
    /**
     * Timeout for this Lambda function (seconds).
     *
     * **Range**: 1 - 900 seconds (15 minutes)
     * **Default**: Uses global lambdaTimeout from InfraOptions
     *
     * @example
     * ```typescript
     * timeout: 30  // 30 second timeout
     * ```
     */
    timeout?: number;
    /**
     * Additional environment variables for this Lambda function.
     *
     * Merged with global environment variables from InfraOptions.
     * Lambda-specific variables take precedence over global ones.
     *
     * @example
     * ```typescript
     * environment: {
     *   PAYMENT_PROVIDER: 'stripe',
     *   MAX_RETRY_ATTEMPTS: '3'
     * }
     * ```
     */
    environment?: Record<string, string>;
}
/**
 * Lambda endpoint definition with dependency injection.
 *
 * Declaratively defines a Lambda function with its dependencies, business logic,
 * and optional HTTP integration. The framework automatically creates the Lambda
 * function, injects dependencies, and sets up API Gateway routes.
 *
 * @deprecated Use LambdaDefinition for new implementations with object-based ties
 */
export interface LambdaDefinition_old {
    /**
     * Lambda identifier within the microservice.
     *
     * **Optional**: If omitted, automatically generated from handler function name.
     * **Final ID**: Combined with service name as `{serviceName}.{id}`
     *
     * @example
     * ```typescript
     * id: 'charge'  // Results in 'payments.charge' if service is 'payments'
     * ```
     */
    id?: string;
    /**
     * Service name (auto-set by framework).
     *
     * **Internal**: Automatically populated by the framework during registration.
     * **Do not set manually**.
     */
    service?: string;
    /**
     * Array of class constructors for dependency injection.
     *
     * Classes are automatically resolved from the microservice's PureContainer
     * using their class names as keys. Dependencies are injected into the handler
     * with camelCase property names.
     *
     * **Key Generation**: Automatic via Class.name (no magic strings)
     * **Property Names**: ClassName → camelCase (PaymentsService → paymentsService)
     *
     * @example
     * ```typescript
     * ties: [PaymentsService, BillingService, ConfigService]
     * // Results in: { paymentsService, billingService, configService }
     * ```
     */
    ties: Array<new (...args: unknown[]) => unknown>;
    /**
     * Lambda handler factory function.
     *
     * Receives injected dependencies and returns the actual Lambda handler.
     * The framework calls this function with resolved dependencies from the
     * microservice's PureContainer.
     *
     * @see {@link LambdaHandlerFactory}
     *
     * @example
     * ```typescript
     * handler: (ties) => async (event, context) => {
     *   const result = await ties.paymentsService.processPayment(event.body);
     *   return {
     *     statusCode: 200,
     *     body: JSON.stringify(result)
     *   };
     * }
     * ```
     */
    handler: LambdaHandlerFactory;
    /**
     * HTTP integration configuration.
     *
     * **Optional**: If provided, creates an API Gateway route for this Lambda.
     * If omitted, Lambda can only be invoked directly or via other AWS services.
     *
     * @see {@link HttpIntegration}
     *
     * @example
     * ```typescript
     * http: {
     *   method: 'POST',
     *   path: '/api/payments/charge',
     *   auth: 'jwt',
     *   cors: true
     * }
     * ```
     */
    http?: HttpIntegration;
    /**
     * Lambda-specific configuration overrides.
     *
     * **Optional**: Overrides global Lambda settings for this specific function.
     * Useful for functions with special requirements (more memory, longer timeout, etc.).
     *
     * @see {@link LambdaConfig}
     *
     * @example
     * ```typescript
     * config: {
     *   memorySize: 2048,  // 2GB for heavy processing
     *   timeout: 300,      // 5 minutes for long operations
     *   environment: {
     *     SPECIAL_CONFIG: 'value'
     *   }
     * }
     * ```
     */
    config?: LambdaConfig;
}
/**
 * Enhanced Lambda event with typed dependencies and snapshot.
 *
 * @template TTies - Ties object type containing dependency definitions
 * @template TSnapshot - Snapshot type from init functions (defaults to empty object)
 * @template TBaseEvent - Base AWS Lambda event type (defaults to APIGatewayProxyEvent)
 */
export type LambdaEvent<TTies, TSnapshot = {}, TBaseEvent = APIGatewayProxyEvent> = TBaseEvent & {
    /**
     * Injected dependencies with exact property names from ties object.
     * Fully typed for IntelliSense and compile-time validation.
     *
     * @example
     * ```typescript
     * // With ties: { userService: UsersService, configService: ConfigService }
     * event.ties.userService // Fully typed as UsersService instance
     * event.ties.configService // Fully typed as ConfigService instance
     * ```
     */
    ties: TTies;
    /**
     * Snapshot from init functions (microservice + lambda merged).
     *
     * Contains the result of initialization functions executed during cold start.
     * When both microservice-level and lambda-level init exist, the snapshot
     * contains merged results with lambda-level properties taking precedence.
     *
     * When no init function is defined, this is an empty object `{}`.
     *
     * @example
     * ```typescript
     * // With init returning { dbConnection: Connection; config: AppConfig }
     * event.snapshot.dbConnection // Fully typed as Connection
     * event.snapshot.config // Fully typed as AppConfig
     * ```
     */
    snapshot: TSnapshot;
};
/**
 * Generic Lambda handler type with typed dependencies, snapshot, and event.
 *
 * @template TTies - Ties object type (e.g., { userService: UsersService })
 * @template TSnapshot - Snapshot type from init functions (defaults to empty object)
 * @template TEvent - Base event type (defaults to APIGatewayProxyEvent)
 *
 * @example
 * ```typescript
 * type MyTies = { userService: UsersService; configService: ConfigService };
 * type MySnapshot = { dbConnection: Connection };
 *
 * const handler: LambdaHandler<MyTies, MySnapshot> = async (event, context) => {
 *   // event.ties.userService is fully typed as UsersService
 *   // event.snapshot.dbConnection is fully typed as Connection
 *   const user = await event.ties.userService.getUser(event.pathParameters.id);
 *   return { statusCode: 200, body: JSON.stringify(user) };
 * };
 * ```
 */
export type LambdaHandler<TTies, TSnapshot = {}, TEvent = APIGatewayProxyEvent> = (event: LambdaEvent<TTies, TSnapshot, TEvent>, context: Context) => Promise<unknown>;
/**
 * Enhanced Lambda definition supporting both array and object-based ties.
 *
 * This interface defines a Lambda function with its dependencies, business logic,
 * and optional HTTP integration. The framework automatically creates the Lambda
 * function, injects dependencies, and sets up API Gateway routes.
 *
 * ## Object-Based Ties (Recommended)
 *
 * The object-based ties pattern provides full type safety:
 * - **`ties` property**: Accepts class constructors (the class itself)
 * - **`event.ties`**: Provides instance types (objects with methods)
 *
 * This separation is handled automatically by the type system through
 * {@link TiesConstructors} transformation.
 *
 * ## Understanding ties vs event.ties Typing
 *
 * There's an important distinction between what you pass to `ties` and what
 * you receive in `event.ties`:
 *
 * ```typescript
 * type MyTies = { userService: UsersService };
 *
 * const handler: LambdaDefinition<MyTies> = {
 *   // ties property: Accepts CLASS CONSTRUCTORS
 *   // Type: TiesConstructors<MyTies> = { userService: Constructor<UsersService> }
 *   ties: { userService: UsersService },  // UsersService is the CLASS
 *
 *   // handler's event.ties: Provides INSTANCE TYPES
 *   // Type: MyTies = { userService: UsersService }
 *   handler: async (event) => {
 *     // event.ties.userService is an INSTANCE with methods
 *     await event.ties.userService.getUser('123');  // ✓ Methods available
 *   }
 * };
 * ```
 *
 * ## Complete Usage Example
 *
 * ```typescript
 * // 1. Define your service classes
 * class UsersService {
 *   async getUser(id: string): Promise<User> { ... }
 *   async createUser(data: UserData): Promise<User> { ... }
 * }
 *
 * class AuthService {
 *   validateToken(token: string): boolean { ... }
 * }
 *
 * // 2. Define the ties type (instance types for handler access)
 * type GetUserTies = {
 *   userService: UsersService;
 *   authService: AuthService;
 * };
 *
 * // 3. Create the Lambda definition
 * export const getUserHandler: LambdaDefinition<GetUserTies> = {
 *   id: 'get-user',
 *
 *   // Pass class constructors - TypeScript accepts this because
 *   // ties type is TiesConstructors<GetUserTies>
 *   ties: {
 *     userService: UsersService,   // Class constructor ✓
 *     authService: AuthService     // Class constructor ✓
 *   },
 *
 *   // Handler receives instances - TypeScript types event.ties
 *   // as GetUserTies (instance types)
 *   handler: async (event, context) => {
 *     // Full IntelliSense for service methods
 *     const token = event.headers.Authorization;
 *     if (!event.ties.authService.validateToken(token)) {
 *       return { statusCode: 401, body: 'Unauthorized' };
 *     }
 *
 *     const userId = event.pathParameters?.id;
 *     const user = await event.ties.userService.getUser(userId);
 *
 *     return {
 *       statusCode: 200,
 *       body: JSON.stringify(user)
 *     };
 *   },
 *
 *   http: {
 *     method: 'GET',
 *     path: '/users/{id}'
 *   }
 * };
 * ```
 *
 * ## Legacy Array-Based Ties
 *
 * For backward compatibility, array-based ties are still supported:
 *
 * ```typescript
 * const legacyHandler: LambdaDefinition = {
 *   ties: [UsersService, AuthService],  // Array of constructors
 *   handler: (ties) => async (event, context) => {
 *     // ties is Record<string, unknown> - less type safety
 *     const user = await (ties.usersService as UsersService).getUser(id);
 *     return { statusCode: 200, body: JSON.stringify(user) };
 *   }
 * };
 * ```
 *
 * @template TTies - Ties type defining dependencies
 *   - For object-based ties: `{ serviceName: ServiceClass }` (instance types)
 *   - For array-based ties: `any` (legacy, less type-safe)
 * @template TSnapshot - Snapshot type from init function (defaults to empty object)
 *
 * @see {@link TiesConstructors} - Type transformation for ties property
 * @see {@link LambdaEvent} - Event type with typed ties and snapshot in handler
 * @see {@link LambdaHandler} - Handler function type
 * @see {@link InitFunction} - Init function type for cold start initialization
 * @see {@link Constructor} - Underlying constructor type
 */
export interface LambdaDefinition<TTies = any, TSnapshot = {}> {
    /**
     * Lambda identifier within the microservice.
     *
     * **Optional**: If omitted, automatically generated from handler function name.
     * **Final ID**: Combined with service name as `{serviceName}.{id}`
     */
    id?: string;
    /**
     * Service name (auto-set by framework).
     *
     * **Internal**: Automatically populated by the framework during registration.
     * **Do not set manually**.
     */
    service?: string;
    /**
     * Dependencies definition using class constructors.
     *
     * This property defines which services the Lambda function needs. The framework
     * resolves these dependencies from the microservice's DI container and injects
     * them into the handler.
     *
     * ## Type Transformation (Object-Based Ties)
     *
     * When using object-based ties with `LambdaDefinition<MyTies>`:
     * - **Generic parameter `MyTies`**: Defines instance types (e.g., `{ userService: UsersService }`)
     * - **`ties` property type**: Automatically transformed to accept constructors via {@link TiesConstructors}
     *
     * This means you write `ties: { userService: UsersService }` and TypeScript
     * understands you're passing the class constructor, not an instance.
     *
     * ## Property Name Requirements
     *
     * Property names in `ties` must match the keys registered in your Ties classes:
     *
     * ```typescript
     * // In your Ties class
     * class UsersTies {
     *   static register = {
     *     userService: { instance: UsersService, dependencies: [] }
     *   };
     * }
     *
     * // In your Lambda definition - key must match
     * ties: { userService: UsersService }  // ✓ 'userService' matches
     * ```
     *
     * @example Object Format (Recommended)
     * ```typescript
     * type MyTies = { userService: UsersService; configService: ConfigService };
     *
     * const handler: LambdaDefinition<MyTies> = {
     *   ties: {
     *     userService: UsersService,      // Class constructor
     *     configService: ConfigService    // Class constructor
     *   },
     *   handler: async (event) => {
     *     // event.ties.userService is typed as UsersService instance
     *     const user = await event.ties.userService.getUser(id);
     *     return { statusCode: 200, body: JSON.stringify(user) };
     *   }
     * };
     * ```
     *
     * @example Legacy Array Format
     * ```typescript
     * // Less type-safe, but still supported
     * ties: [UsersService, PaymentsService]
     * // Results in: { usersService, paymentsService } (camelCase from class name)
     * ```
     */
    ties: TTies extends Record<string, any> ? TiesConstructors<TTies> : Array<new (...args: unknown[]) => unknown>;
    /**
     * Optional initialization function executed during cold start.
     *
     * Init functions run once per Lambda execution environment (cold start only),
     * before the first handler invocation. The returned snapshot is cached and
     * available to all subsequent warm invocations via `event.snapshot`.
     *
     * ## Execution Timing
     *
     * - Executes exactly once per execution environment (cold start)
     * - Executes before the first handler invocation
     * - Result is cached for all warm invocations
     * - If both microservice-level and lambda-level init exist, microservice runs first
     *
     * ## Use Cases
     *
     * - Database connection establishment
     * - Configuration loading and parsing
     * - SDK client warming
     * - Cache priming
     *
     * @example Basic Usage
     * ```typescript
     * type MyTies = { dbService: DatabaseService };
     * type MySnapshot = { connection: Connection };
     *
     * const handler: LambdaDefinition<MyTies, MySnapshot> = {
     *   ties: { dbService: DatabaseService },
     *   init: async (ties) => {
     *     const connection = await ties.dbService.connect();
     *     return { connection };
     *   },
     *   handler: async (event, context) => {
     *     // event.snapshot.connection is fully typed as Connection
     *     const result = await event.snapshot.connection.query('SELECT * FROM users');
     *     return { statusCode: 200, body: JSON.stringify(result) };
     *   }
     * };
     * ```
     *
     * @see {@link InitFunction} - The init function type definition
     */
    init?: InitFunction<TTies, TSnapshot>;
    /**
     * Handler function with typed dependencies and snapshot.
     *
     * The handler signature depends on the ties format:
     * - **Object ties**: Direct async function receiving `(event, context)`
     * - **Array ties**: Factory function receiving `(ties)` that returns the handler
     *
     * ## Object-Based Ties Handler (Recommended)
     *
     * With object-based ties, the handler is a direct async function where
     * `event.ties` provides fully typed access to service instances and
     * `event.snapshot` provides access to init function results:
     *
     * ```typescript
     * type MyTies = { userService: UsersService };
     * type MySnapshot = { config: AppConfig };
     *
     * handler: async (event, context) => {
     *   // event.ties.userService is typed as UsersService instance
     *   // event.snapshot.config is typed as AppConfig
     *   const user = await event.ties.userService.getUser(id);
     *   return { statusCode: 200, body: JSON.stringify(user) };
     * }
     * ```
     *
     * ## Type Safety Benefits
     *
     * - **IntelliSense**: Autocomplete for all service methods and snapshot properties
     * - **Compile-time validation**: TypeScript catches typos and wrong parameters
     * - **Refactoring support**: Rename methods and TypeScript updates all usages
     *
     * ## Handler Type Details
     *
     * For object-based ties with `LambdaDefinition<MyTies, MySnapshot>`:
     * - Handler type: `LambdaHandler<MyTies, MySnapshot>`
     * - Event type: `LambdaEvent<MyTies, MySnapshot>` (APIGatewayProxyEvent + { ties: MyTies; snapshot: MySnapshot })
     * - `event.ties`: Typed as `MyTies` (instance types, not constructors)
     * - `event.snapshot`: Typed as `MySnapshot` (init function return type)
     *
     * @example Object-Based Ties with Init (Recommended)
     * ```typescript
     * type GetUserTies = {
     *   userService: UsersService;
     *   authService: AuthService;
     * };
     * type GetUserSnapshot = { config: AppConfig };
     *
     * const getUserHandler: LambdaDefinition<GetUserTies, GetUserSnapshot> = {
     *   ties: { userService: UsersService, authService: AuthService },
     *   init: async (ties) => {
     *     const config = await ties.configService.loadConfig();
     *     return { config };
     *   },
     *   handler: async (event, context) => {
     *     // Fully typed access to services and snapshot
     *     const isValid = event.ties.authService.validateToken(event.headers.Authorization);
     *     if (!isValid) {
     *       return { statusCode: 401, body: 'Unauthorized' };
     *     }
     *
     *     const user = await event.ties.userService.getUser(event.pathParameters.id);
     *     return { statusCode: 200, body: JSON.stringify(user) };
     *   }
     * };
     * ```
     *
     * @example Array-Based Ties (Legacy)
     * ```typescript
     * // Factory pattern - less type-safe
     * handler: (ties) => async (event, context) => {
     *   // ties is Record<string, unknown> - requires casting
     *   const userService = ties.userService as UsersService;
     *   const user = await userService.getUser(event.pathParameters.id);
     *   return { statusCode: 200, body: JSON.stringify(user) };
     * }
     * ```
     */
    handler: TTies extends Record<string, any> ? LambdaHandler<TTies, TSnapshot, any> : LambdaHandlerFactory;
    /**
     * HTTP integration configuration.
     *
     * **Optional**: If provided, creates an API Gateway route for this Lambda.
     */
    http?: HttpIntegration;
    /**
     * Lambda-specific configuration overrides.
     *
     * **Optional**: Overrides global Lambda settings for this specific function.
     */
    config?: LambdaConfig;
}
/**
 * Type helper to extract ties type from LambdaDefinition.
 *
 * @example
 * ```typescript
 * type MyLambdaDef = LambdaDefinition<{ userService: UsersService }>;
 * type MyTies = ExtractTiesType<MyLambdaDef>; // { userService: UsersService }
 * ```
 */
export type ExtractTiesType<T> = T extends LambdaDefinition<infer TTies, any> ? TTies : never;
/**
 * Type helper to extract snapshot type from LambdaDefinition.
 *
 * @example
 * ```typescript
 * type MyLambdaDef = LambdaDefinition<{ userService: UsersService }, { config: AppConfig }>;
 * type MySnapshot = ExtractSnapshotType<MyLambdaDef>; // { config: AppConfig }
 * ```
 */
export type ExtractSnapshotType<T> = T extends LambdaDefinition<any, infer TSnapshot> ? TSnapshot : never;
/**
 * Type helper to create handler type from ties object.
 *
 * @example
 * ```typescript
 * type MyTies = { userService: UsersService };
 * type MyHandler = CreateHandlerType<MyTies>; // LambdaHandler<MyTies>
 * ```
 */
export type CreateHandlerType<TTies, TSnapshot = {}, TEvent = APIGatewayProxyEvent> = LambdaHandler<TTies, TSnapshot, TEvent>;
/**
 * Type guard to check if ties is object-based format.
 *
 * @param ties - Ties definition to check
 * @returns True if ties is object-based, false if array-based or invalid
 */
export declare function isObjectBasedTies(ties: any): ties is Record<string, new (...args: any[]) => any>;
/**
 * Type guard to check if handler is direct function (object-based ties).
 *
 * @param handler - Handler to check
 * @returns True if handler is direct function, false if factory function
 */
export declare function isDirectHandler<TTies>(handler: any): handler is LambdaHandler<TTies>;
/**
 * Type guard to check if handler is factory function (array-based ties).
 *
 * @param handler - Handler to check
 * @returns True if handler is factory function, false if direct function
 */
export declare function isFactoryHandler(handler: any): handler is LambdaHandlerFactory;
