/**
 * Approval Chain Database Operations
 *
 * Provides operations for creating reusable approval chains and tracking
 * per-document approval progress through multi-step review processes.
 *
 * An approval chain defines a sequence of steps (roles) that must approve
 * a document. When applied to a document, individual approval_steps rows
 * are created. Steps are processed in order - the next step becomes active
 * only when the previous step is approved.
 *
 * CRITICAL: NEVER use console.log() - stdout is reserved for JSON-RPC protocol.
 *
 * @module database/approval-operations
 */
import type Database from 'better-sqlite3';
export interface ApprovalChainRow {
    id: string;
    name: string;
    description: string | null;
    steps_json: string;
    created_at: string;
    created_by: string | null;
}
export interface ApprovalStepRow {
    id: string;
    document_id: string;
    chain_id: string;
    step_order: number;
    required_role: string;
    status: string;
    decided_by: string | null;
    decided_at: string | null;
    reason: string | null;
}
export interface ApprovalChainStep {
    role: string;
    required_approvals?: number;
    auto_advance?: boolean;
}
export interface CreateApprovalChainParams {
    name: string;
    description?: string | null;
    steps: ApprovalChainStep[];
    created_by?: string | null;
}
export interface ApprovalProgress {
    chain_id: string;
    chain_name: string;
    document_id: string;
    steps: ApprovalStepRow[];
    total_steps: number;
    completed_steps: number;
    current_step: ApprovalStepRow | null;
    is_complete: boolean;
    is_rejected: boolean;
}
/**
 * Create a reusable approval chain with ordered steps.
 *
 * @param conn - Database connection
 * @param params - Chain creation parameters
 * @returns The created approval chain row
 * @throws Error if name is empty or no steps provided
 */
export declare function createApprovalChain(conn: Database.Database, params: CreateApprovalChainParams): ApprovalChainRow;
/**
 * Get an approval chain by ID.
 *
 * @param conn - Database connection
 * @param chainId - Approval chain ID
 * @returns The approval chain row or null
 */
export declare function getApprovalChain(conn: Database.Database, chainId: string): ApprovalChainRow | null;
/**
 * Apply an approval chain to a document, creating approval_steps rows.
 *
 * Creates one approval_steps row per step in the chain, all starting
 * with 'pending' status. Steps are ordered by step_order.
 *
 * @param conn - Database connection
 * @param documentId - Document ID to apply the chain to
 * @param chainId - Approval chain ID to apply
 * @returns Array of created approval step rows
 * @throws Error if document or chain not found, or chain already applied
 */
export declare function applyApprovalChain(conn: Database.Database, documentId: string, chainId: string): ApprovalStepRow[];
/**
 * Get the current (first pending) approval step for a document+chain.
 *
 * @param conn - Database connection
 * @param documentId - Document ID
 * @param chainId - Approval chain ID
 * @returns The first pending step, or null if all steps are decided
 */
export declare function getCurrentApprovalStep(conn: Database.Database, documentId: string, chainId: string): ApprovalStepRow | null;
/**
 * Decide on an approval step (approve or reject).
 *
 * On approval: marks the step as 'approved' and returns it.
 * On rejection: marks the step as 'rejected' and skips all subsequent
 * pending steps (sets them to 'skipped').
 *
 * @param conn - Database connection
 * @param stepId - Approval step ID to decide on
 * @param decision - 'approved' or 'rejected'
 * @param userId - User ID making the decision
 * @param reason - Optional reason (required for rejection)
 * @returns The updated approval step row
 * @throws Error if step not found, not pending, or not the current step
 */
export declare function decideApprovalStep(conn: Database.Database, stepId: string, decision: 'approved' | 'rejected', userId: string, reason?: string | null): ApprovalStepRow;
/**
 * Get approval progress for a document and chain.
 *
 * Returns all steps with summary counts and the current pending step.
 *
 * @param conn - Database connection
 * @param documentId - Document ID
 * @param chainId - Approval chain ID
 * @returns Approval progress with steps and summary
 * @throws Error if chain not found or not applied to document
 */
export declare function getApprovalProgress(conn: Database.Database, documentId: string, chainId: string): ApprovalProgress;
//# sourceMappingURL=approval-operations.d.ts.map