/**
 * Resource Command Pattern Types
 *
 * This module defines the types for the Command pattern implementation.
 * Commands enable deferred resource creation with undo support and
 * dependency-based execution ordering.
 *
 * @module declarative-api/command.types
 */
import type { IResourceEntity } from './resource.types';
/**
 * Command execution status.
 *
 * Tracks the current state of a command in its lifecycle.
 */
export type CommandStatus = 'pending' | 'executed' | 'undone' | 'failed';
/**
 * Valid command status values as a const array for validation.
 */
export declare const COMMAND_STATUSES: readonly ["pending", "executed", "undone", "failed"];
/**
 * Type guard to check if a value is a valid CommandStatus.
 *
 * @param value - The value to check
 * @returns True if the value is a valid CommandStatus
 */
export declare function isValidCommandStatus(value: unknown): value is CommandStatus;
/**
 * Command audit entry for tracking command execution history.
 *
 * Each command maintains an audit entry that records its execution
 * status, timestamps, and any errors that occurred.
 *
 * Validates: Requirements 15.6
 */
export interface CommandAuditEntry {
    /** Unique identifier of the command */
    readonly commandId: string;
    /** Type of command (e.g., 'create-table', 'create-queue') */
    readonly commandType: string;
    /** Timestamp when the command was executed (undefined if not executed) */
    readonly executedAt?: Date;
    /** Timestamp when the command was undone (undefined if not undone) */
    readonly undoneAt?: Date;
    /** ID of the resource created by this command (undefined if not executed) */
    readonly resourceId?: string;
    /** Current status of the command */
    readonly status: CommandStatus;
    /** Error message if the command failed */
    readonly error?: string;
}
/**
 * Resource Command interface for deferred resource creation.
 *
 * Commands encapsulate resource creation operations that can be:
 * - Validated before execution (canExecute)
 * - Executed to create resources
 * - Undone to rollback changes
 * - Audited for tracking
 *
 * Implements: Command Pattern
 * Validates: Requirements 15.1, 15.3
 */
export interface IResourceCommand {
    /** Unique identifier for this command */
    readonly commandId: string;
    /** IDs of commands that must execute before this one */
    readonly dependencies: readonly string[];
    /**
     * Check if the command can be executed.
     *
     * This validates preconditions before execution.
     *
     * @returns True if the command can be executed
     */
    canExecute(): boolean;
    /**
     * Execute the command to create the resource.
     *
     * @returns The created resource entity
     * @throws Error if execution fails
     */
    execute(): IResourceEntity;
    /**
     * Undo the command to rollback the resource creation.
     *
     * This should reverse the effects of execute().
     *
     * @throws Error if undo fails
     */
    undo(): void;
    /**
     * Get the audit entry for this command.
     *
     * @returns The current audit entry
     */
    getAuditEntry(): CommandAuditEntry;
}
/**
 * Macro Command interface for batch operations.
 *
 * A macro command contains multiple sub-commands that are
 * executed as a single unit. If any sub-command fails,
 * all previously executed sub-commands are undone.
 *
 * Implements: Composite Command Pattern
 * Validates: Requirements 15.4
 */
export interface IMacroCommand extends IResourceCommand {
    /** The sub-commands contained in this macro */
    readonly commands: readonly IResourceCommand[];
    /**
     * Add a command to this macro.
     *
     * @param command - The command to add
     * @returns This macro for chaining
     */
    addCommand(command: IResourceCommand): this;
    /**
     * Remove a command from this macro.
     *
     * @param commandId - The ID of the command to remove
     * @returns True if the command was removed
     */
    removeCommand(commandId: string): boolean;
    /**
     * Get the count of sub-commands.
     *
     * @returns The number of sub-commands
     */
    getCommandCount(): number;
}
/**
 * Command Executor interface for managing command execution.
 *
 * The executor collects commands, resolves their dependencies,
 * and executes them in the correct order. It also supports
 * rollback of all executed commands.
 *
 * Implements: Command Executor Pattern
 * Validates: Requirements 15.2, 15.5
 */
export interface ICommandExecutor {
    /**
     * Add a command to the execution queue.
     *
     * @param command - The command to enqueue
     */
    enqueue(command: IResourceCommand): void;
    /**
     * Execute all queued commands in dependency order.
     *
     * Commands are executed using topological sort based on
     * their dependencies. If a command fails, execution stops
     * and previously executed commands can be rolled back.
     *
     * @returns Array of created resource entities
     * @throws Error if execution fails
     */
    executeAll(): IResourceEntity[];
    /**
     * Rollback all executed commands in reverse order.
     *
     * This undoes all commands that were successfully executed,
     * in reverse order of execution.
     */
    rollbackAll(): void;
    /**
     * Get the execution plan without executing.
     *
     * This performs a dry-run to show the order in which
     * commands would be executed based on dependencies.
     *
     * @returns Array of commands in execution order
     */
    getExecutionPlan(): IResourceCommand[];
    /**
     * Get all audit entries for executed commands.
     *
     * @returns Array of audit entries
     */
    getAuditLog(): CommandAuditEntry[];
    /**
     * Clear all queued commands.
     */
    clear(): void;
    /**
     * Get the count of queued commands.
     *
     * @returns The number of queued commands
     */
    getQueueSize(): number;
}
/**
 * Options for creating a command.
 */
export interface CommandOptions {
    /** Custom command ID (auto-generated if not provided) */
    readonly commandId?: string;
    /** IDs of commands that must execute before this one */
    readonly dependencies?: readonly string[];
}
/**
 * Result of command execution.
 */
export interface CommandExecutionResult {
    /** Whether execution was successful */
    readonly success: boolean;
    /** The created resource (if successful) */
    readonly resource?: IResourceEntity;
    /** Error message (if failed) */
    readonly error?: string;
    /** The audit entry for this execution */
    readonly auditEntry: CommandAuditEntry;
}
/**
 * Result of batch command execution.
 */
export interface BatchExecutionResult {
    /** Whether all commands executed successfully */
    readonly success: boolean;
    /** Array of created resources */
    readonly resources: IResourceEntity[];
    /** Array of execution results for each command */
    readonly results: CommandExecutionResult[];
    /** Number of commands that succeeded */
    readonly successCount: number;
    /** Number of commands that failed */
    readonly failureCount: number;
}
