import yaml from 'js-yaml';
import { Options } from 'tsup';

/**
 * Universal logger for Serverless Framework plugins
 * Extracted from composer, module-registry, artifact-manager, and arn-prefixer
 * Provides consistent logging across all DevSquad serverless tooling
 */
interface LoggerOptions {
    verbose?: boolean;
    prefix?: string;
}
interface ServerlessInterface {
    cli?: {
        log?: (message: string) => void;
    };
}
declare class ServerlessLogger {
    private serverless;
    private options;
    private hasLogged;
    protected readonly prefix: string;
    protected readonly verbose: boolean;
    constructor(serverless: ServerlessInterface, options?: LoggerOptions);
    /**
     * Log an info message with optional color formatting
     */
    info(message: string, color?: string): void;
    /**
     * Log a success message in green
     */
    success(message: string): void;
    /**
     * Log a warning message in yellow
     */
    warning(message: string): void;
    /**
     * Log an error message in red
     */
    error(message: string): void;
    /**
     * Log a step or process message in blue
     */
    step(message: string): void;
    /**
     * Print a section header with separator
     */
    section(title: string): void;
    /**
     * Print section content with proper indentation
     */
    sectionItem(key: string, value: string, color?: string): void;
    /**
     * End a section
     */
    sectionEnd(): void;
    /**
     * Print composition/processing progress
     */
    progress(category: string, fileCount: number): void;
    /**
     * Print variable resolution progress
     */
    variableResolution(category: string, variableCount: number): void;
    /**
     * Log only once per instance (prevents spam)
     */
    logOnce(message: string, level?: 'info' | 'success' | 'warning' | 'error'): void;
    /**
     * Reset the logged flag (useful for testing or command handlers)
     */
    resetLoggedFlag(): void;
    /**
     * Legacy method to maintain compatibility with existing code
     */
    log(message: string, level?: 'info' | 'warning' | 'error'): void;
    /**
     * Output text to console via Serverless CLI or fallback to console.log
     */
    protected output(text: string): void;
    /**
     * Determine if verbose logging should be enabled
     */
    private shouldUseVerboseLogging;
}
/**
 * Helper function to determine if verbose logging should be enabled
 * Used by plugins to decide on logger verbosity without creating logger instance
 */
declare function shouldUseVerboseLogging(options?: any): boolean;
/**
 * Create a logger instance with the specified prefix and options
 */
declare function createLogger(serverless: ServerlessInterface, prefix: string, options?: Omit<LoggerOptions, 'prefix'>): ServerlessLogger;

/**
 * Cross-version variable resolution utilities for Serverless Framework
 * Extracted from composer and module-registry plugins
 * Supports Serverless Framework v2, v3, and v4
 */

interface ServerlessVariables {
    populateObject?: (payload: any) => Promise<any>;
    loadVariableSyntax?: () => void;
    variableResolvers?: Record<string, any>;
}
interface ServerlessConfigurationVariables {
    resolve?: (payload: any) => Promise<any>;
}
interface ServerlessPluginManager {
    plugins?: Array<{
        configurationVariablesSources?: Record<string, any>;
    }>;
}
interface ServerlessWithVariables extends ServerlessInterface {
    variables?: ServerlessVariables;
    configurationVariables?: ServerlessConfigurationVariables;
    pluginManager?: ServerlessPluginManager;
    service?: {
        service?: string;
        provider?: {
            stage?: string;
        };
        custom?: Record<string, any>;
    };
}
/**
 * Utility function to check if an object is a plain object
 */
declare function isPlainObject(obj: any): boolean;
/**
 * Detects Serverless Framework version based on available APIs
 */
declare function detectServerlessVersion(serverless: ServerlessWithVariables): 'v2' | 'v3+';
/**
 * Recursively resolve ${arn:prefix}, ${arn:stage}, and basic ${self:*} variables in an object
 */
declare function resolveArnAndSelfVariables(obj: any, serverless: ServerlessWithVariables, arnPrefix?: string): any;
/**
 * Iteratively resolve variables until no more changes occur
 * Handles complex nested patterns like ${self:custom.deletionPolicy.${arn:stage}, 'Delete'}
 */
declare function resolveVariablesIteratively(payload: Record<string, any>, serverless: ServerlessWithVariables, maxIterations?: number): Promise<Record<string, any>>;
/**
 * Cross‑version helper – resolves Serverless variables in an arbitrary
 * payload regardless of whether the framework is v2, v3 or v4.
 * Enhanced to support custom variable sources registered by plugins.
 */
declare function resolveVarsSafely(serverless: ServerlessWithVariables, payload: Record<string, any>): Promise<Record<string, any>>;
/**
 * Manually resolve variables in a payload using custom variable sources
 * This is used as a fallback for v3+ when configurationVariables.resolve is not available
 */
declare function resolveVariablesManually(payload: any, customSources: Record<string, any>, serverless: ServerlessWithVariables): Promise<any>;

/**
 * Object manipulation and merging utilities
 * Extracted from composer plugin for reuse across serverless tools
 */

/**
 * Recursively merges plain objects (mutates target)
 * Handles null/undefined values gracefully and preserves object structure
 */
declare function deepMerge(target: Record<string, any>, source: Record<string, any>): Record<string, any>;
/**
 * Chunk array into smaller arrays of specified size
 * Useful for batch operations like DynamoDB batch writes
 */
declare function chunkArray<T>(array: T[], size: number): T[][];
/**
 * Sanitize CloudFormation resource names to be alphanumeric only
 * Required for CloudFormation logical IDs
 */
declare function sanitizeResourceName(name: string): string;
/**
 * Deep clone an object to avoid mutations
 */
declare function deepClone<T>(obj: T): T;
/**
 * Check if an object has any properties
 */
declare function isEmpty(obj: any): boolean;

/**
 * CloudFormation utilities for Serverless Framework plugins
 * Handles CloudFormation intrinsic functions and YAML schema
 */

/**
 * CloudFormation-aware YAML schema that handles intrinsic functions
 * Used across multiple serverless plugins for consistent YAML parsing
 */
declare const cloudFormationSchema: yaml.Schema;
/**
 * Load YAML file with CloudFormation intrinsic function support
 */
declare function loadCloudFormationYaml(filePath: string): any;
/**
 * Parse YAML content with CloudFormation intrinsic function support
 */
declare function parseCloudFormationYaml(content: string): any;
/**
 * Dump object to CloudFormation-compatible YAML
 */
declare function dumpCloudFormationYaml(data: any, options?: yaml.DumpOptions): string;

/**
 * Base TSUp configuration for serverless plugins
 * Provides consistent build setup across all DevSquad serverless packages
 */

interface TSUpBaseOptions extends Options {
    binEntries?: Record<string, string>;
    nodeTarget?: 'node14' | 'node16' | 'node18' | 'node20';
    externalDeps?: string[];
}
/**
 * Create a standardized TSUp configuration for serverless plugins
 */
declare function createTSUpConfig(options?: TSUpBaseOptions): Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);

/**
 * Build and development configuration utilities
 * Provides standardized configurations for DevSquad serverless packages
 */

/**
 * Get the path to the base TypeScript configuration
 */
declare function getTSConfigBasePath(): string;
/**
 * Get the path to the base ESLint configuration
 */
declare function getESLintBasePath(): string;
/**
 * Get the path to the base Jest configuration
 */
declare function getJestBasePath(): string;
/**
 * Create a standard package.json template for serverless plugins
 */
declare function createPackageJsonTemplate(options: {
    name: string;
    description: string;
    version?: string;
    additionalDependencies?: Record<string, string>;
    additionalDevDependencies?: Record<string, string>;
    additionalScripts?: Record<string, string>;
}): any;

export { type LoggerOptions, type ServerlessConfigurationVariables, type ServerlessInterface, ServerlessLogger, type ServerlessPluginManager, type ServerlessVariables, type ServerlessWithVariables, type TSUpBaseOptions, chunkArray, cloudFormationSchema, createLogger, createPackageJsonTemplate, createTSUpConfig, deepClone, deepMerge, detectServerlessVersion, dumpCloudFormationYaml, getESLintBasePath, getJestBasePath, getTSConfigBasePath, isEmpty, isPlainObject, loadCloudFormationYaml, parseCloudFormationYaml, resolveArnAndSelfVariables, resolveVariablesIteratively, resolveVariablesManually, resolveVarsSafely, sanitizeResourceName, shouldUseVerboseLogging };
