import { type Result, type SiteId } from '../../../../core/src/index';
import { type DryRunReport, type SiteCommandBatch, type SiteCommandExecutionSuccess, type SiteCommandOf, type SiteCommandPlanFor, type SiteCommandRef, type SiteCommandType, type SiteCommandValidationError } from '../../../../site-commands/src/index';
import type { EnvTarget } from '../helpers';
export type CliCommandBatchRefInput<TSource extends string = string> = Readonly<{
    source: TSource;
    siteId: SiteId;
    targetEnv: EnvTarget;
}>;
export type CliCommandExecutionError<TCommandType extends SiteCommandType> = Readonly<{
    code: 'management_api_failed';
    commandRef: SiteCommandRef;
    commandType: TCommandType;
    message: string;
}>;
export type CliCommandExecutionResult<TCommandType extends SiteCommandType> = Readonly<{
    status: 'applied';
    applied: readonly SiteCommandExecutionSuccess[];
}> | Readonly<{
    status: 'failed';
    applied: readonly SiteCommandExecutionSuccess[];
    failed: CliCommandExecutionError<TCommandType>;
}>;
export type PlannedCliCommand<TCommand extends Readonly<{
    ref: SiteCommandRef;
    type: SiteCommandType;
}>> = Readonly<{
    command: TCommand;
}>;
export type CliCommandReportBinding<TCommand extends Readonly<{
    ref: SiteCommandRef;
    type: SiteCommandType;
}>, TSubject> = Readonly<{
    command: TCommand;
    reportSubject: TSubject;
}>;
export type CliCommandReportedPlannedCommand<TCommand extends Readonly<{
    ref: SiteCommandRef;
    type: SiteCommandType;
}>, TSubject> = Readonly<{
    plannedCommand: PlannedCliCommand<TCommand>;
    reportSubject: TSubject;
}>;
export type CliCommandExecutionReportFailure<TSubject> = Readonly<{
    identifier: string;
    message: string;
    subject?: TSubject;
}>;
export type CliCommandOutcome<TSubject> = Readonly<{
    status: 'applied';
    commandRef: SiteCommandRef;
    commandType: SiteCommandType;
    subject: TSubject;
}> | Readonly<{
    status: 'failed';
    commandRef: SiteCommandRef;
    commandType: SiteCommandType;
    identifier: string;
    message: string;
    subject?: TSubject;
}> | Readonly<{
    status: 'skipped_by_stop_policy';
    commandRef: SiteCommandRef;
    commandType: SiteCommandType;
    identifier: string;
    subject: TSubject;
}> | Readonly<{
    status: 'compile_failed';
    identifier: string;
    message: string;
    subject?: TSubject;
}>;
export type CliCommandExecutionReport<TSubject> = Readonly<{
    outcomes: readonly CliCommandOutcome<TSubject>[];
    appliedSubjects: readonly TSubject[];
    failure: CliCommandExecutionReportFailure<TSubject> | null;
    warnings: readonly string[];
}>;
export type CliCommandValidationCompileError = Readonly<{
    code: 'command_validation_failed';
    errors: readonly SiteCommandValidationError[];
    message: string;
}>;
export type CliCommandCompileBatchSuccess<TCommandType extends SiteCommandType> = Readonly<{
    batch: SiteCommandBatch;
    plan: SiteCommandPlanFor<TCommandType>;
    dryRunReport: DryRunReport;
}>;
export type CliCommandCompileBatchSuccessWithReports<TCommandType extends SiteCommandType, TSubject> = Readonly<{
    reportedCommands: readonly CliCommandReportedPlannedCommand<SiteCommandOf<TCommandType>, TSubject>[];
}> & CliCommandCompileBatchSuccess<TCommandType>;
export declare function createCliCommandBatchRef(input: CliCommandBatchRefInput): string;
export declare function formatSiteCommandValidationErrors(errors: readonly {
    message: string;
}[]): string;
export declare function formatManagementError(error: unknown): string;
export declare function planCliCommandBatchForTypes<TCommandType extends SiteCommandType>(input: CliCommandBatchRefInput & Readonly<{
    commands: readonly SiteCommandOf<TCommandType>[];
    commandTypes: readonly TCommandType[];
}>): Result<CliCommandCompileBatchSuccess<TCommandType>, CliCommandValidationCompileError>;
export declare function planCliCommandBatchForBindings<TCommandType extends SiteCommandType, TSubject>(input: CliCommandBatchRefInput & Readonly<{
    commandBindings: readonly CliCommandReportBinding<SiteCommandOf<TCommandType>, TSubject>[];
    commandTypes: readonly TCommandType[];
}>): Result<CliCommandCompileBatchSuccessWithReports<TCommandType, TSubject>, CliCommandValidationCompileError>;
export declare function executeCliCommandPlan<TCommand extends Readonly<{
    ref: SiteCommandRef;
    type: TCommandType;
}>, TCommandType extends SiteCommandType>(input: Readonly<{
    commands: readonly PlannedCliCommand<TCommand>[];
    applyCommand: (command: TCommand) => Promise<void>;
}>): Promise<CliCommandExecutionResult<TCommandType>>;
export declare function commandExecutionToReport<TCommand extends Readonly<{
    ref: SiteCommandRef;
    type: TCommandType;
}>, TCommandType extends SiteCommandType, TSubject>(input: Readonly<{
    execution: CliCommandExecutionResult<TCommandType>;
    reportedCommands: readonly CliCommandReportedPlannedCommand<TCommand, TSubject>[];
    resourceLabel: string;
    commandDisplayIdentifier: (command: TCommand) => string;
    includeFailureSubject?: boolean;
}>): CliCommandExecutionReport<TSubject>;
export declare function commandCompileFailureToReport<TSubject>(input: Readonly<{
    identifier: string;
    message: string;
    subject?: TSubject;
    warnings?: readonly string[];
}>): CliCommandExecutionReport<TSubject>;
export declare function executeCompiledCliCommandPlanAsReport<TCompiledPlan extends Readonly<{
    plan: Readonly<{
        commands: readonly unknown[];
    }>;
}>, TExecutionResult, TSubject>(input: Readonly<{
    compiledPlan: TCompiledPlan;
    onBeforeExecute?: (commandCount: number) => void;
    executePlan: (plan: TCompiledPlan['plan']) => Promise<TExecutionResult>;
    executionToReport: (input: Readonly<{
        execution: TExecutionResult;
        compiledPlan: TCompiledPlan;
    }>) => CliCommandExecutionReport<TSubject>;
}>): Promise<CliCommandExecutionReport<TSubject>>;
export declare function reportFromOutcomes<TSubject>(input: Readonly<{
    outcomes: readonly CliCommandOutcome<TSubject>[];
    warnings?: readonly string[];
}>): CliCommandExecutionReport<TSubject>;
export declare function commandReportHasFailures(report: CliCommandExecutionReport<unknown>): boolean;
