import type { AuthMethod } from '../auth/types.js';
/**
 * Configuration structure for dw.json after key normalization.
 *
 * All keys are normalized to camelCase by `normalizeConfigKeys()` when loading.
 * Both camelCase and kebab-case are accepted in the raw file; the interface
 * documents the canonical (post-normalization) field names.
 *
 * Legacy aliases (e.g., `server`, `secureHostname`, `passphrase`, `selfsigned`,
 * `cloudOrigin`, `scapi-shortcode`) are also accepted and mapped to their
 * canonical names during normalization.
 */
export interface DwJsonConfig {
    /** Instance name (for multi-config files) */
    name?: string;
    /** Whether this config is active (for multi-config files) */
    active?: boolean;
    /** B2C instance hostname */
    hostname?: string;
    /** Code version for deployments */
    codeVersion?: string;
    /** Username for Basic auth (WebDAV) */
    username?: string;
    /** Password/access-key for Basic auth (WebDAV) */
    password?: string;
    /** OAuth client ID */
    clientId?: string;
    /** OAuth client secret */
    clientSecret?: string;
    /** OAuth scopes */
    oauthScopes?: string[];
    /** SLAS client ID for shopper authentication */
    slasClientId?: string;
    /** SLAS client secret for private shopper clients */
    slasClientSecret?: string;
    /** B2C Commerce site/channel ID */
    siteId?: string;
    /** SCAPI short code */
    shortCode?: string;
    /** Alternate hostname for WebDAV (if different from main hostname) */
    webdavHostname?: string;
    /** Allowed authentication methods in priority order */
    authMethods?: AuthMethod[];
    /** Account Manager hostname for OAuth */
    accountManagerHost?: string;
    /** MRT project slug */
    mrtProject?: string;
    /** MRT environment name (e.g., staging, production) */
    mrtEnvironment?: string;
    /** MRT API key */
    mrtApiKey?: string;
    /** MRT cloud origin URL */
    mrtOrigin?: string;
    /** Tenant/Organization ID for SCAPI */
    tenantId?: string;
    /** ODS API hostname */
    sandboxApiHost?: string;
    /** Default ODS realm for sandbox operations */
    realm?: string;
    /** Cartridge names to include in deploy/watch (string with colon/comma separators, or array) */
    cartridges?: string | string[];
    /** Default content library ID for content export/list commands */
    contentLibrary?: string;
    /** Catalog IDs for WebDAV browsing */
    catalogs?: string[];
    /** Library IDs for WebDAV browsing */
    libraries?: string[];
    /** Optional CIP analytics host override */
    cipHost?: string;
    /** Path to PKCS12 certificate file for mTLS (two-factor auth) */
    certificate?: string;
    /** Passphrase for the certificate */
    certificatePassphrase?: string;
    /** Whether to skip SSL/TLS certificate verification (self-signed certs) */
    selfSigned?: boolean;
    /**
     * Safety configuration for this instance.
     *
     * @example
     * ```json
     * {
     *   "safety": {
     *     "level": "NO_UPDATE",
     *     "confirm": true,
     *     "rules": [
     *       { "job": "sfcc-site-archive-export", "action": "allow" },
     *       { "command": "sandbox:*", "action": "confirm" }
     *     ]
     *   }
     * }
     * ```
     */
    safety?: {
        level?: string;
        confirm?: boolean;
        rules?: Array<{
            method?: string;
            path?: string;
            job?: string;
            command?: string;
            action: string;
        }>;
    };
}
/**
 * dw.json with multi-config support (configs array).
 */
export interface DwJsonMultiConfig extends DwJsonConfig {
    /** Array of named instance configurations */
    configs?: DwJsonConfig[];
}
/**
 * Options for loading dw.json.
 */
export interface LoadDwJsonOptions {
    /** Named instance to select from configs array */
    instance?: string;
    /** Explicit path to dw.json (skips searching if provided) */
    path?: string;
    /** Starting directory for search (defaults to cwd) */
    projectDirectory?: string;
    /** @deprecated Use projectDirectory instead */
    workingDirectory?: string;
}
/**
 * Result of loading dw.json configuration.
 */
export interface LoadDwJsonResult {
    /** The parsed configuration */
    config: DwJsonConfig;
    /** The path to the dw.json file that was loaded */
    path: string;
}
/**
 * Finds dw.json by searching upward from the starting directory.
 *
 * @param projectDirectory - Directory to start searching from (defaults to cwd)
 * @returns Path to dw.json if found, undefined otherwise
 *
 * @example
 * const dwPath = findDwJson();
 * if (dwPath) {
 *   console.log(`Found dw.json at ${dwPath}`);
 * }
 */
export declare function findDwJson(projectDirectory?: string): Promise<string | undefined>;
/**
 * Load the raw dw.json file without selecting a specific instance.
 *
 * This is useful for instance management operations that need to work
 * with the full configs array.
 *
 * @param options - Loading options
 * @returns The raw multi-config structure and path, or undefined if not found
 */
export declare function loadFullDwJson(options?: LoadDwJsonOptions): Promise<{
    config: DwJsonMultiConfig;
    path: string;
} | undefined>;
/**
 * Save a dw.json configuration to disk.
 *
 * @param config - The configuration to save
 * @param filePath - Path to save to
 */
export declare function saveDwJson(config: DwJsonMultiConfig, filePath: string): Promise<void>;
/**
 * Options for adding an instance.
 */
export interface AddInstanceOptions {
    /** Path to dw.json (defaults to ./dw.json) */
    path?: string;
    /** Starting directory for search */
    projectDirectory?: string;
    /** @deprecated Use projectDirectory instead */
    workingDirectory?: string;
    /** Whether to set as active instance */
    setActive?: boolean;
}
/**
 * Add a new instance to dw.json.
 *
 * If dw.json doesn't exist, creates a new one. If an instance with the same
 * name already exists, throws an error.
 *
 * @param instance - The instance configuration to add
 * @param options - Options for adding
 * @throws Error if instance with same name already exists
 */
export declare function addInstance(instance: DwJsonConfig, options?: AddInstanceOptions): Promise<void>;
/**
 * Options for removing an instance.
 */
export interface RemoveInstanceOptions {
    /** Path to dw.json */
    path?: string;
    /** Starting directory for search */
    projectDirectory?: string;
    /** @deprecated Use projectDirectory instead */
    workingDirectory?: string;
}
/**
 * Remove an instance from dw.json.
 *
 * @param name - Name of the instance to remove
 * @param options - Options for removal
 * @throws Error if instance not found or dw.json doesn't exist
 */
export declare function removeInstance(name: string, options?: RemoveInstanceOptions): Promise<void>;
/**
 * Options for setting active instance.
 */
export interface SetActiveInstanceOptions {
    /** Path to dw.json */
    path?: string;
    /** Starting directory for search */
    projectDirectory?: string;
    /** @deprecated Use projectDirectory instead */
    workingDirectory?: string;
}
/**
 * Set an instance as the active default.
 *
 * @param name - Name of the instance to set as active
 * @param options - Options
 * @throws Error if instance not found or dw.json doesn't exist
 */
export declare function setActiveInstance(name: string, options?: SetActiveInstanceOptions): Promise<void>;
/**
 * Loads configuration from a dw.json file.
 *
 * If an explicit path is provided, uses that file. Otherwise, looks for dw.json
 * in the projectDirectory (or cwd). Does NOT search parent directories.
 *
 * Use `findDwJson()` if you need to search upward through parent directories.
 *
 * @param options - Loading options
 * @returns The parsed config with its path, or undefined if no dw.json found
 *
 * @example
 * // Load from ./dw.json (current directory)
 * const result = loadDwJson();
 * if (result) {
 *   console.log(`Loaded from ${result.path}`);
 *   console.log(result.config.hostname);
 * }
 *
 * // Load from specific directory
 * const result = loadDwJson({ projectDirectory: '/path/to/project' });
 *
 * // Use named instance
 * const result = loadDwJson({ instance: 'staging' });
 *
 * // Explicit path
 * const result = loadDwJson({ path: './config/dw.json' });
 */
export declare function loadDwJson(options?: LoadDwJsonOptions): Promise<LoadDwJsonResult | undefined>;
