import { Command, type Interfaces } from '@oclif/core';
import type { LoadConfigOptions } from './config.js';
import type { ResolvedB2CConfig } from '../config/index.js';
import { type Logger } from '../logging/index.js';
import { type ExtraParamsConfig } from '../clients/middleware.js';
import { Telemetry, type TelemetryAttributes } from '../telemetry/index.js';
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
/**
 * Base command class for B2C CLI tools.
 *
 * Environment variables for logging:
 * - SFCC_JSON_LOGS: Output log messages as JSON lines (for log aggregation)
 * - SFCC_LOG_TO_STDOUT: Send logs to stdout instead of stderr
 * - SFCC_LOG_COLORIZE: Force colors on/off (default: auto-detect TTY)
 * - SFCC_REDACT_SECRETS: Set to 'false' to disable secret redaction
 * - NO_COLOR: Industry standard to disable colors
 *
 * Environment variables for telemetry:
 * - SF_DISABLE_TELEMETRY: Set to 'true' to disable telemetry (sf CLI standard)
 * - SFCC_DISABLE_TELEMETRY: Set to 'true' to disable telemetry
 * - SFCC_APP_INSIGHTS_KEY: Override connection string from package.json
 */
export declare abstract class BaseCommand<T extends typeof Command> extends Command {
    static baseFlags: {
        'log-level': Interfaces.OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, Interfaces.CustomOptions>;
        debug: Interfaces.BooleanFlag<boolean>;
        json: Interfaces.BooleanFlag<boolean>;
        jsonl: Interfaces.BooleanFlag<boolean>;
        lang: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
        config: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
        instance: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
        'project-directory': Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
        'extra-query': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
        'extra-body': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
        'extra-headers': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
    };
    protected flags: Flags<T>;
    protected args: Args<T>;
    protected resolvedConfig: ResolvedB2CConfig;
    protected logger: Logger;
    /** Telemetry instance for tracking command events */
    protected telemetry?: Telemetry;
    /** Start time for command duration tracking */
    private commandStartTime?;
    init(): Promise<void>;
    /**
     * Auto-initialize telemetry from package.json oclif.telemetry config.
     * Called during init() to enable automatic telemetry for all commands.
     */
    private initTelemetryFromConfig;
    /**
     * Manual telemetry initialization for non-pjson usage (e.g., MCP server with additional attributes).
     * Use this when you need to pass custom initial attributes or use a different connection string.
     *
     * @param options - Telemetry options
     * @returns The telemetry instance, or undefined if telemetry is disabled
     */
    protected initTelemetry(options: {
        appInsightsKey?: string;
        initialAttributes?: TelemetryAttributes;
    }): Promise<Telemetry | undefined>;
    /**
     * Determine colorize setting based on env vars and TTY.
     * Priority: NO_COLOR > SFCC_LOG_COLORIZE > TTY detection
     */
    private shouldColorize;
    protected configureLogging(): void;
    /**
     * Override oclif's log() to use pino.
     */
    log(message?: string, ...args: unknown[]): void;
    /**
     * Override oclif's warn() to use pino.
     */
    warn(input: string | Error): string | Error;
    /**
     * Gets base configuration options from common flags.
     *
     * Subclasses should spread these options when overriding loadConfiguration()
     * to ensure common options like projectDirectory are always included.
     *
     * @example
     * ```typescript
     * protected override loadConfiguration(): ResolvedB2CConfig {
     *   const options: LoadConfigOptions = {
     *     ...this.getBaseConfigOptions(),
     *     // Add subclass-specific options here
     *   };
     *   return loadConfig(extractMyFlags(this.flags), options);
     * }
     * ```
     */
    protected getBaseConfigOptions(): LoadConfigOptions;
    protected loadConfiguration(): ResolvedB2CConfig;
    /**
     * Enrich telemetry with realm/tenant context from the resolved configuration.
     * Called after loadConfiguration() in init() so that COMMAND_SUCCESS and
     * COMMAND_EXCEPTION events include organizational context.
     */
    protected addTelemetryContext(): void;
    /**
     * Collects config sources from plugins via the `b2c:config-sources` hook.
     *
     * This method is called during command initialization, after flags are parsed
     * but before configuration is resolved. It allows CLI plugins to provide
     * custom ConfigSource implementations.
     *
     * Plugin sources are registered with the global config source registry
     * and automatically included in all subsequent `resolveConfig()` calls.
     *
     * Priority mapping:
     * - 'before' → -1 (higher priority than defaults)
     * - 'after' → 10 (lower priority than defaults)
     * - number → used directly
     */
    protected collectPluginConfigSources(): Promise<void>;
    /**
     * Collects HTTP middleware from plugins via the `b2c:http-middleware` hook.
     *
     * This method is called during command initialization, after flags are parsed
     * but before any API clients are created. It allows CLI plugins to provide
     * custom middleware that will be applied to all HTTP clients.
     *
     * Plugin middleware is registered with the global middleware registry.
     */
    protected collectPluginHttpMiddleware(): Promise<void>;
    /**
     * Collects auth middleware from plugins via the `b2c:auth-middleware` hook.
     *
     * This method is called during command initialization, after flags are parsed
     * but before any authentication is performed. It allows CLI plugins to provide
     * custom middleware that will be applied to OAuth token requests.
     *
     * Plugin middleware is registered with the global auth middleware registry.
     */
    protected collectPluginAuthMiddleware(): Promise<void>;
    /**
     * Handle errors thrown during command execution.
     *
     * Logs the error using the structured logger (including cause if available).
     * In JSON mode, outputs a JSON error object to stdout instead of oclif's default format.
     * Sends exception to telemetry if initialized.
     */
    protected catch(err: Error & {
        exitCode?: number;
    }): Promise<never>;
    /**
     * Called after run() completes (whether successfully or via catch()).
     * Tracks COMMAND_SUCCESS and stops telemetry.
     */
    protected finally(err: Error | undefined): Promise<void>;
    baseCommandTest(): void;
    /**
     * Parse extra params from --extra-query, --extra-body, and --extra-headers flags.
     * Returns undefined if no extra params are specified.
     *
     * @returns ExtraParamsConfig or undefined
     */
    protected getExtraParams(): ExtraParamsConfig | undefined;
    /**
     * Register extra params (query, body, headers) as global middleware.
     * This applies to ALL HTTP clients created during command execution.
     */
    private registerExtraParamsMiddleware;
}
