/**
 * Configuration mapping utilities.
 *
 * This module provides the single source of truth for mapping between
 * different configuration formats (dw.json, normalized config, etc.).
 *
 * @module config/mapping
 */
import type { AuthConfig } from '../auth/types.js';
import { B2CInstance } from '../instance/index.js';
import type { DwJsonConfig } from './dw-json.js';
import type { NormalizedConfig, ConfigWarning } from './types.js';
/**
 * Maps dw.json fields to normalized config format.
 *
 * This is the SINGLE place where dw.json field mapping happens.
 * Handles multiple field name variants for backward compatibility:
 * - WebDAV hostname: `webdav-hostname`, `secureHostname`, `secure-server`
 * - Short code: `shortCode`, `short-code`, `scapi-shortcode`
 *
 * @param json - The raw dw.json config
 * @returns Normalized configuration
 *
 * @example
 * ```typescript
 * import { mapDwJsonToNormalizedConfig } from '@salesforce/b2c-tooling-sdk/config';
 *
 * const dwJson = { hostname: 'example.com', 'code-version': 'v1' };
 * const config = mapDwJsonToNormalizedConfig(dwJson);
 * // { hostname: 'example.com', codeVersion: 'v1' }
 * ```
 */
export declare function mapDwJsonToNormalizedConfig(json: DwJsonConfig): NormalizedConfig;
/**
 * Options for merging configurations.
 */
export interface MergeConfigOptions {
    /**
     * Whether to apply hostname mismatch protection.
     * When true, if overrides.hostname differs from base.hostname,
     * the entire base config is ignored.
     * @default true
     */
    hostnameProtection?: boolean;
}
/**
 * Result of merging configurations.
 */
export interface MergeConfigResult {
    /** The merged configuration */
    config: NormalizedConfig;
    /** Warnings generated during merge (e.g., hostname mismatch) */
    warnings: ConfigWarning[];
    /** Whether a hostname mismatch was detected and base was ignored */
    hostnameMismatch: boolean;
}
/**
 * Merges configurations with hostname mismatch protection.
 *
 * Applies the precedence rule: overrides > base.
 * If hostname protection is enabled and the override hostname differs from
 * the base hostname, the entire base config is ignored to prevent
 * credential leakage between different instances.
 *
 * @param overrides - Higher-priority config values (e.g., from CLI flags/env)
 * @param base - Lower-priority config values (e.g., from dw.json)
 * @param options - Merge options
 * @returns Merged config with warnings
 *
 * @example
 * ```typescript
 * import { mergeConfigsWithProtection } from '@salesforce/b2c-tooling-sdk/config';
 *
 * const { config, warnings } = mergeConfigsWithProtection(
 *   { hostname: 'staging.example.com' },
 *   { hostname: 'prod.example.com', clientId: 'abc' },
 *   { hostnameProtection: true }
 * );
 * // config = { hostname: 'staging.example.com' }
 * // warnings = [{ code: 'HOSTNAME_MISMATCH', ... }]
 * ```
 */
export declare function mergeConfigsWithProtection(overrides: Partial<NormalizedConfig>, base: NormalizedConfig, options?: MergeConfigOptions): MergeConfigResult;
/**
 * Gets the list of fields that have values in a config.
 *
 * Used for tracking which sources contributed which fields during
 * configuration resolution.
 *
 * @param config - The configuration to inspect
 * @returns Array of field names that have non-empty values
 *
 * @example
 * ```typescript
 * const config = { hostname: 'example.com', clientId: 'abc' };
 * const fields = getPopulatedFields(config);
 * // ['hostname', 'clientId']
 * ```
 */
export declare function getPopulatedFields(config: NormalizedConfig): (keyof NormalizedConfig)[];
/**
 * Builds an AuthConfig from a NormalizedConfig.
 *
 * This is the single source of truth for converting normalized config
 * to the AuthConfig format expected by B2CInstance.
 *
 * @param config - The normalized configuration
 * @returns AuthConfig for B2CInstance
 *
 * @example
 * ```typescript
 * const config = {
 *   clientId: 'my-client-id',
 *   clientSecret: 'my-secret',
 *   username: 'admin',
 *   password: 'pass',
 * };
 * const authConfig = buildAuthConfigFromNormalized(config);
 * // { oauth: { clientId: '...', clientSecret: '...' }, basic: { username: '...', password: '...' } }
 * ```
 */
export declare function buildAuthConfigFromNormalized(config: NormalizedConfig): AuthConfig;
/**
 * Creates a B2CInstance from a NormalizedConfig.
 *
 * This utility provides a single source of truth for instance creation
 * from resolved configuration. It is used by both ConfigResolver.createInstance()
 * and CLI commands (e.g., InstanceCommand).
 *
 * @param config - The normalized configuration (must include hostname)
 * @returns Configured B2CInstance
 * @throws Error if hostname is not available in config
 *
 * @example
 * ```typescript
 * import { createInstanceFromConfig } from '@salesforce/b2c-tooling-sdk/config';
 *
 * const config = { hostname: 'example.demandware.net', clientId: 'abc' };
 * const instance = createInstanceFromConfig(config);
 * await instance.webdav.mkcol('Cartridges/v1');
 * ```
 */
export declare function createInstanceFromConfig(config: NormalizedConfig): B2CInstance;
