import { d as ExportFormat, E as ExportConfig$1, l as ExportStatus, e as ExportField, U as UniversalExportServiceConfig$1, a as ExportRequest, b as ExportResult$1, c as ExportProgress$1, u as ExportEventListener$1, j as FieldType } from '../../types-DszP7SAQ.js';
import * as drizzle_orm from 'drizzle-orm';
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';

/**
 * UniversalExport Server 端类型定义
 */

/** 导出服务配置 */
interface UniversalExportServiceConfig {
    /** 数据库连接（可选） */
    db?: any;
    /** 导出文件存储目录 */
    exportDir?: string;
    /** 临时文件目录 */
    tempDir?: string;
    /** 最大导出行数 */
    maxRows?: number;
    /** 是否启用流式导出 */
    enableStreaming?: boolean;
    /** 导出超时时间（毫秒） */
    timeout?: number;
}
/** 导出引擎接口 */
interface IExportEngine {
    /** 引擎格式 */
    readonly format: ExportFormat;
    /** 导出数据 */
    export(data: any[], config: ExportConfig$1): Promise<ExportResult>;
    /** 流式导出 */
    exportStream?(data: AsyncIterable<any>, config: ExportConfig$1): Promise<ExportResult>;
    /** 验证配置 */
    validateConfig(config: ExportConfig$1): boolean;
    /** 获取引擎信息 */
    getInfo(): EngineInfo;
}
/** 引擎信息 */
interface EngineInfo {
    /** 引擎名称 */
    name: string;
    /** 支持的格式 */
    format: ExportFormat;
    /** 支持流式导出 */
    supportsStreaming: boolean;
    /** 最大行数限制 */
    maxRows?: number;
}
/** 导出结果 */
interface ExportResult {
    /** 是否成功 */
    success: boolean;
    /** 文件路径 */
    filePath?: string;
    /** 文件大小（字节） */
    fileSize?: number;
    /** 导出行数 */
    rowCount: number;
    /** 导出时长（毫秒） */
    duration: number;
    /** 错误信息 */
    error?: string;
    /** 元数据 */
    metadata?: Record<string, any>;
}
/** 导出进度 */
interface ExportProgress {
    /** 任务 ID */
    taskId: string;
    /** 当前状态 */
    status: ExportStatus;
    /** 已处理行数 */
    processedRows: number;
    /** 总行数 */
    totalRows: number;
    /** 进度百分比 */
    percentage: number;
    /** 剩余时间（秒） */
    estimatedTime?: number;
    /** 错误信息 */
    error?: string;
}
/** 数据转换器 */
interface DataTransformer {
    /** 转换数据行 */
    transform(row: any, config: ExportConfig$1): any;
    /** 批量转换 */
    transformBatch?(rows: any[], config: ExportConfig$1): any[];
}
/** 字段映射器 */
interface FieldMapper {
    /** 映射字段 */
    map(value: any, field: ExportField): any;
}
/** 数据验证器 */
interface Validator {
    /** 验证数据 */
    validate(data: any[], config: ExportConfig$1): ValidationResult;
}
/** 验证结果 */
interface ValidationResult {
    /** 是否有效 */
    valid: boolean;
    /** 错误列表 */
    errors: ValidationError[];
}
/** 验证错误 */
interface ValidationError {
    /** 行号 */
    row: number;
    /** 字段 */
    field: string;
    /** 错误消息 */
    message: string;
}
/** 数据源接口 */
interface IDataSource {
    /** 获取数据 */
    getData(query: any, options?: DataQueryOptions): Promise<any[]>;
    /** 获取数据流 */
    getDataStream?(query: any, options?: DataQueryOptions): AsyncIterable<any>;
    /** 获取总数 */
    getCount(query: any): Promise<number>;
}
/** 数据查询选项 */
interface DataQueryOptions {
    /** 分页 */
    page?: number;
    pageSize?: number;
    /** 排序 */
    orderBy?: string;
    orderDirection?: 'asc' | 'desc';
    /** 过滤 */
    filters?: Record<string, any>;
}
/** 任务创建选项 */
interface TaskCreateOptions {
    /** 配置 ID */
    configId: string;
    /** 导出格式 */
    format: ExportFormat;
    /** 查询条件 */
    query?: any;
    /** 创建者 ID */
    creatorId?: string;
    /** 任务名称 */
    name?: string;
    /** 任务描述 */
    description?: string;
}
/** 任务更新选项 */
interface TaskUpdateOptions {
    /** 任务状态 */
    status?: ExportStatus;
    /** 进度 */
    progress?: number;
    /** 文件路径 */
    filePath?: string;
    /** 文件大小 */
    fileSize?: number;
    /** 导出行数 */
    rowCount?: number;
    /** 错误信息 */
    error?: string;
}
/** 导出配置记录 */
interface ExportConfigRecord {
    /** 配置 ID */
    id: string;
    /** 配置名称 */
    name: string;
    /** 配置描述 */
    description?: string;
    /** 导出格式 */
    format: ExportFormat;
    /** 字段定义 */
    fields: ExportField[];
    /** 创建时间 */
    createdAt: Date | string;
    /** 更新时间 */
    updatedAt: Date | string;
    /** 创建者 ID */
    creatorId?: string;
}
/** 导出任务记录 */
interface ExportTaskRecord {
    /** 任务 ID */
    id: string;
    /** 配置 ID */
    configId: string;
    /** 任务状态 */
    status: ExportStatus;
    /** 文件路径 */
    filePath?: string;
    /** 导出进度 */
    progress?: number;
    /** 创建时间 */
    createdAt: Date | string;
    /** 更新时间 */
    updatedAt: Date | string;
    /** 完成时间 */
    completedAt?: Date | string;
}
/** 导出历史记录 */
interface ExportHistoryRecord {
    /** 历史 ID */
    id: string;
    /** 任务 ID */
    taskId: string;
    /** 配置 ID */
    configId: string;
    /** 导出格式 */
    format: ExportFormat;
    /** 导出状态 */
    status: ExportStatus;
    /** 文件路径 */
    filePath?: string;
    /** 文件大小 */
    fileSize?: number;
    /** 导出行数 */
    rowCount: number;
    /** 导出时长 */
    duration: number;
    /** 创建者 ID */
    creatorId?: string;
    /** 创建时间 */
    createdAt: Date | string;
    /** 错误信息 */
    error?: string;
}
/** 导出事件类型 */
type ExportEventType = 'task:created' | 'task:started' | 'task:progress' | 'task:completed' | 'task:failed' | 'task:cancelled' | 'config:created' | 'config:updated' | 'config:deleted';
/** 导出事件 */
interface ExportEvent {
    /** 事件类型 */
    type: ExportEventType;
    /** 任务 ID */
    taskId?: string;
    /** 配置 ID */
    configId?: string;
    /** 事件数据 */
    data?: any;
    /** 时间戳 */
    timestamp: Date;
}
/** 事件监听器 */
type ExportEventListener = (event: ExportEvent) => void | Promise<void>;
/** 格式化器函数 */
type FormatterFunction = (value: any) => string;
/** 聚合函数 */
type AggregateFunction = (values: any[]) => any;
/** 自定义处理函数 */
type CustomProcessor = (values: any[]) => any;

/**
 * 通用导出服务
 *
 * 提供统一的导出功能，支持配置化字段选择、格式化和分组
 */

/**
 * 导出客户端接口（用于依赖注入）
 */
interface IExportClient {
    createConfig(config: Omit<ExportConfig$1, 'id' | 'createdAt' | 'updatedAt'>): Promise<ExportConfig$1>;
    getConfigsByModule(moduleId: string, businessId?: string): Promise<ExportConfig$1[]>;
}
declare class UniversalExportService {
    private config;
    private eventListeners;
    private activeExports;
    private configCache;
    private resultCache;
    private client?;
    constructor(config?: Partial<UniversalExportServiceConfig$1>, client?: IExportClient);
    /**
     * 创建导出配置
     */
    createConfig(config: Omit<ExportConfig$1, 'id' | 'createdAt' | 'updatedAt'>): Promise<ExportConfig$1>;
    /**
     * 获取导出配置
     */
    getConfig(configId: string): Promise<ExportConfig$1 | null>;
    /**
     * 更新导出配置
     */
    updateConfig(configId: string, updates: Partial<ExportConfig$1>): Promise<ExportConfig$1>;
    /**
     * 删除导出配置
     */
    deleteConfig(configId: string): Promise<void>;
    /**
     * 获取模块的配置列表
     */
    getConfigsByModule(moduleId: string, businessId?: string): Promise<ExportConfig$1[]>;
    /**
     * 执行导出
     */
    export(request: ExportRequest): Promise<ExportResult$1>;
    /**
     * 获取导出进度
     */
    getExportProgress(exportId: string): ExportProgress$1 | null;
    /**
     * 取消导出
     */
    cancelExport(exportId: string): boolean;
    /**
     * 添加事件监听器
     */
    addEventListener(type: string, listener: ExportEventListener$1): void;
    /**
     * 移除事件监听器
     */
    removeEventListener(type: string, listener: ExportEventListener$1): void;
    /**
     * 生成唯一ID
     */
    private generateId;
    /**
     * 验证配置
     */
    private validateConfig;
    /**
     * 获取数据
     */
    private getData;
    /**
     * 处理数据
     */
    private processData;
    /**
     * 应用过滤器
     */
    private applyFilters;
    /**
     * 应用排序
     */
    private applySorting;
    /**
     * 获取嵌套值
     */
    private getNestedValue;
    /**
     * 过滤掉所有行都为空值的字段
     */
    private filterEmptyFields;
    /**
     * 生成文件
     */
    private generateFile;
    /**
     * 生成CSV内容
     */
    private generateCSV;
    /**
     * 生成JSON内容
     */
    private generateJSON;
    /**
     * 转义CSV字段
     */
    private escapeCSVField;
    /**
     * 生成文件名
     */
    private generateFileName;
    /**
     * 获取MIME类型
     */
    private getMimeType;
    /**
     * 触发事件
     */
    private emitEvent;
    /**
     * 应用分组
     */
    private applyGrouping;
    /**
     * 按字段分组数据
     */
    private groupDataByFields;
    /**
     * 生成分组键
     */
    private generateGroupKey;
    /**
     * 处理分组后的数据
     */
    private processGroupedData;
    /**
     * 处理单个分组
     */
    private processGroup;
    /**
     * 创建分组头行
     */
    private createGroupHeader;
    /**
     * 处理合并模式
     */
    private processMergeMode;
    /**
     * 处理多字段合并模式
     */
    private processMultiFieldMergeMode;
    /**
     * 处理嵌套模式
     */
    private processNestedMode;
    /**
     * 统计分组数量
     */
    private countGroups;
    /**
     * 生成Excel文件
     */
    private generateExcel;
    /**
     * 准备Excel数据
     */
    private prepareExcelData;
    /**
     * 应用Excel分组和合并单元格
     */
    private applyExcelGrouping;
    /**
     * 设置Excel列宽和样式
     */
    private setExcelColumnWidths;
    /**
     * 为Excel数据单元格应用样式
     */
    private applyExcelDataStyles;
}

/**
 * UniversalExport Service 工厂函数
 * 提供简化的服务初始化方式
 */

/**
 * 创建导出服务配置（带智能默认值）
 */
declare function createExportServiceConfig(options?: Partial<UniversalExportServiceConfig>): UniversalExportServiceConfig;
/**
 * 创建导出服务实例（简化版）
 *
 * @example
 * ```typescript
 * // 最简配置
 * const service = createUniversalExportService();
 *
 * // 标准配置
 * const service = createUniversalExportService({
 *   db: drizzleDb,
 *   exportDir: './exports',
 *   maxRows: 50000,
 * });
 * ```
 */
declare function createUniversalExportService(options?: Partial<UniversalExportServiceConfig>): {
    config: UniversalExportServiceConfig;
    export(): Promise<never>;
    createTask(): Promise<never>;
};
/**
 * 从环境变量创建配置（便利函数）
 *
 * @example
 * ```typescript
 * // .env
 * // EXPORT_DIR=./exports
 * // EXPORT_MAX_ROWS=50000
 *
 * const service = createExportServiceFromEnv();
 * ```
 */
declare function createExportServiceFromEnv(db?: any): {
    config: UniversalExportServiceConfig;
    export(): Promise<never>;
    createTask(): Promise<never>;
};

/**
 * UniversalExport 预设配置
 * 提供常见场景的开箱即用配置
 */

/**
 * 小型应用预设（数据量小）
 */
declare function createSmallAppPreset(): Partial<UniversalExportServiceConfig>;
/**
 * 中型应用预设（默认配置）
 */
declare function createMediumAppPreset(): Partial<UniversalExportServiceConfig>;
/**
 * 大型应用预设（数据量大）
 */
declare function createLargeAppPreset(): Partial<UniversalExportServiceConfig>;
/**
 * 实时导出预设（快速响应）
 */
declare function createRealtimeExportPreset(): Partial<UniversalExportServiceConfig>;
/**
 * 批量导出预设（大批量、离线处理）
 */
declare function createBatchExportPreset(): Partial<UniversalExportServiceConfig>;
/**
 * 智能预设：根据环境自动选择
 */
declare function createSmartExportPreset(): Partial<UniversalExportServiceConfig>;

/**
 * UniversalExport 配置验证
 */

declare class ConfigValidationError extends Error {
    field: string;
    constructor(message: string, field: string);
}
/**
 * 验证导出服务配置
 */
declare function validateExportConfig(config: UniversalExportServiceConfig): void;
/**
 * 验证环境变量
 */
declare function validateEnvironment(requiredVars: string[]): void;

/**
 * UniversalExport Server 工具函数
 */

/**
 * 格式化字段值
 *
 * @param value 原始值
 * @param field 字段定义
 * @returns 格式化后的值
 */
declare function formatFieldValue(value: any, field: ExportField): string;
/**
 * 验证字段值
 *
 * @param value 字段值
 * @param field 字段定义
 * @returns 是否有效
 */
declare function validateFieldValue(value: any, field: ExportField): boolean;
/**
 * 转换字段类型
 *
 * @param value 原始值
 * @param targetType 目标类型
 * @returns 转换后的值
 */
declare function convertFieldType(value: any, targetType: FieldType): any;
/**
 * 安全获取嵌套属性值
 *
 * @param obj 对象
 * @param path 属性路径（支持点号分隔）
 * @returns 属性值
 *
 * @example
 * ```typescript
 * const obj = { user: { name: 'John', age: 30 } };
 * getNestedValue(obj, 'user.name')  // 'John'
 * getNestedValue(obj, 'user.email') // undefined
 * ```
 */
declare function getNestedValue(obj: any, path: string): any;
/**
 * 转义 CSV 字段值
 *
 * @param value 字段值
 * @returns 转义后的值
 */
declare function escapeCsvValue(value: string): string;
/**
 * 生成唯一的文件名
 *
 * @param prefix 前缀
 * @param extension 扩展名
 * @returns 唯一文件名
 *
 * @example
 * ```typescript
 * generateUniqueFilename('export', 'xlsx')
 * // 'export_20231111_123456_abc123.xlsx'
 * ```
 */
declare function generateUniqueFilename(prefix: string, extension: string): string;
/**
 * 计算导出进度百分比
 *
 * @param processed 已处理行数
 * @param total 总行数
 * @returns 百分比（0-100）
 */
declare function calculateProgress(processed: number, total: number): number;
/**
 * 估算剩余时间（秒）
 *
 * @param processed 已处理行数
 * @param total 总行数
 * @param elapsedMs 已用时间（毫秒）
 * @returns 剩余时间（秒）
 */
declare function estimateRemainingTime(processed: number, total: number, elapsedMs: number): number;

/**
 * 通用导出服务 - PostgreSQL 数据库表结构定义
 *
 * 提供导出配置和历史记录的数据库表结构。
 *
 * 表结构概览：
 * - export_configs: 导出配置表
 * - export_history: 导出历史记录表
 *
 * 设计特点：
 * - 支持多种导出格式（CSV, Excel, JSON）
 * - 灵活的字段配置和分组
 * - 完整的历史记录追踪
 *
 * @fileoverview 数据库表结构 - 通用导出服务 (PostgreSQL)
 * @package sa2kit/universalExport/server
 */
/**
 * 导出配置表 (ExportConfig)
 *
 * 存储导出任务的配置信息，包括字段选择、格式化、分组等。
 */
declare const exportConfigs: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "ExportConfig";
    schema: undefined;
    columns: {
        id: drizzle_orm_pg_core.PgColumn<{
            name: "id";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: true;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        name: drizzle_orm_pg_core.PgColumn<{
            name: "name";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        description: drizzle_orm_pg_core.PgColumn<{
            name: "description";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        format: drizzle_orm_pg_core.PgColumn<{
            name: "format";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        fields: drizzle_orm_pg_core.PgColumn<{
            name: "fields";
            tableName: "ExportConfig";
            dataType: "json";
            columnType: "PgJsonb";
            data: unknown;
            driverParam: unknown;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        grouping: drizzle_orm_pg_core.PgColumn<{
            name: "grouping";
            tableName: "ExportConfig";
            dataType: "json";
            columnType: "PgJsonb";
            data: unknown;
            driverParam: unknown;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        fileNameTemplate: drizzle_orm_pg_core.PgColumn<{
            name: "fileNameTemplate";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        includeHeader: drizzle_orm_pg_core.PgColumn<{
            name: "includeHeader";
            tableName: "ExportConfig";
            dataType: "boolean";
            columnType: "PgBoolean";
            data: boolean;
            driverParam: boolean;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        delimiter: drizzle_orm_pg_core.PgColumn<{
            name: "delimiter";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        encoding: drizzle_orm_pg_core.PgColumn<{
            name: "encoding";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        addBOM: drizzle_orm_pg_core.PgColumn<{
            name: "addBOM";
            tableName: "ExportConfig";
            dataType: "boolean";
            columnType: "PgBoolean";
            data: boolean;
            driverParam: boolean;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        maxRows: drizzle_orm_pg_core.PgColumn<{
            name: "maxRows";
            tableName: "ExportConfig";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        moduleId: drizzle_orm_pg_core.PgColumn<{
            name: "moduleId";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        businessId: drizzle_orm_pg_core.PgColumn<{
            name: "businessId";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        createdBy: drizzle_orm_pg_core.PgColumn<{
            name: "createdBy";
            tableName: "ExportConfig";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        createdAt: drizzle_orm_pg_core.PgColumn<{
            name: "createdAt";
            tableName: "ExportConfig";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        updatedAt: drizzle_orm_pg_core.PgColumn<{
            name: "updatedAt";
            tableName: "ExportConfig";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    };
    dialect: "pg";
}>;
/**
 * 导出历史记录表 (ExportHistory)
 *
 * 记录每次导出任务的执行情况，包括状态、耗时、文件信息等。
 */
declare const exportHistory: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "ExportHistory";
    schema: undefined;
    columns: {
        id: drizzle_orm_pg_core.PgColumn<{
            name: "id";
            tableName: "ExportHistory";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: true;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        configId: drizzle_orm_pg_core.PgColumn<{
            name: "configId";
            tableName: "ExportHistory";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        fileName: drizzle_orm_pg_core.PgColumn<{
            name: "fileName";
            tableName: "ExportHistory";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        fileSize: drizzle_orm_pg_core.PgColumn<{
            name: "fileSize";
            tableName: "ExportHistory";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        exportedRows: drizzle_orm_pg_core.PgColumn<{
            name: "exportedRows";
            tableName: "ExportHistory";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        status: drizzle_orm_pg_core.PgColumn<{
            name: "status";
            tableName: "ExportHistory";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        error: drizzle_orm_pg_core.PgColumn<{
            name: "error";
            tableName: "ExportHistory";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        duration: drizzle_orm_pg_core.PgColumn<{
            name: "duration";
            tableName: "ExportHistory";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        startTime: drizzle_orm_pg_core.PgColumn<{
            name: "startTime";
            tableName: "ExportHistory";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        endTime: drizzle_orm_pg_core.PgColumn<{
            name: "endTime";
            tableName: "ExportHistory";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        createdBy: drizzle_orm_pg_core.PgColumn<{
            name: "createdBy";
            tableName: "ExportHistory";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        createdAt: drizzle_orm_pg_core.PgColumn<{
            name: "createdAt";
            tableName: "ExportHistory";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    };
    dialect: "pg";
}>;
/**
 * 导出配置表关系
 * 一个配置可以有多个导出历史记录
 */
declare const exportConfigsRelations: drizzle_orm.Relations<"ExportConfig", {
    history: drizzle_orm.Many<"ExportHistory">;
}>;
/**
 * 导出历史表关系
 * 每个历史记录关联一个配置
 */
declare const exportHistoryRelations: drizzle_orm.Relations<"ExportHistory", {
    config: drizzle_orm.One<"ExportConfig", true>;
}>;
type ExportConfig = typeof exportConfigs.$inferSelect;
type NewExportConfig = typeof exportConfigs.$inferInsert;
type ExportHistory = typeof exportHistory.$inferSelect;
type NewExportHistory = typeof exportHistory.$inferInsert;

/**
 * 通用导出服务 - Drizzle 数据库操作层
 *
 * 提供导出配置和历史记录的数据库操作接口。
 * 支持任何 Drizzle 数据库实例。
 *
 * @package sa2kit/universalExport/server
 */

/**
 * Drizzle 数据库实例类型
 */
type DrizzleDb = any;
/**
 * 导出配置数据库服务工厂选项
 */
interface ExportDatabaseServiceOptions {
    /**
     * Drizzle 数据库实例
     */
    db: DrizzleDb;
}
/**
 * 导出配置数据库服务
 *
 * 提供导出配置的 CRUD 操作
 */
declare class ExportConfigDatabaseService {
    private readonly db;
    constructor(db: DrizzleDb);
    /**
     * 创建导出配置
     */
    createConfig(config: Omit<NewExportConfig, 'id' | 'createdAt' | 'updatedAt'>): Promise<ExportConfig>;
    /**
     * 根据ID获取配置
     */
    getConfigById(id: string): Promise<ExportConfig | null>;
    /**
     * 根据模块和业务ID获取配置列表
     */
    getConfigsByModule(moduleId: string, businessId?: string): Promise<ExportConfig[]>;
    /**
     * 更新配置
     */
    updateConfig(id: string, updates: Partial<Omit<ExportConfig, 'id' | 'createdAt'>>): Promise<ExportConfig | null>;
    /**
     * 删除配置
     */
    deleteConfig(id: string): Promise<boolean>;
    /**
     * 根据用户ID获取配置列表
     */
    getConfigsByUser(userId: string): Promise<ExportConfig[]>;
}
/**
 * 导出历史记录数据库服务
 *
 * 提供导出历史记录的 CRUD 操作
 */
declare class ExportHistoryDatabaseService {
    private readonly db;
    constructor(db: DrizzleDb);
    /**
     * 创建导出历史记录
     */
    createHistory(history: Omit<NewExportHistory, 'id' | 'createdAt'>): Promise<ExportHistory>;
    /**
     * 根据配置ID获取历史记录
     */
    getHistoryByConfigId(configId: string): Promise<ExportHistory[]>;
    /**
     * 根据用户ID获取历史记录
     */
    getHistoryByUser(userId: string): Promise<ExportHistory[]>;
    /**
     * 获取最近的导出历史记录
     */
    getRecentHistory(limit?: number): Promise<ExportHistory[]>;
}
/**
 * 创建导出数据库服务实例
 *
 * @param options - 数据库服务选项
 * @returns 导出配置和历史记录服务实例
 *
 * @example
 * ```typescript
 * import { createExportDatabaseServices } from 'sa2kit/universalExport/server';
 * import { db } from './db';
 *
 * const { configDB, historyDB } = createExportDatabaseServices({ db });
 *
 * // 使用服务
 * const config = await configDB.createConfig({ ... });
 * const history = await historyDB.createHistory({ ... });
 * ```
 */
declare function createExportDatabaseServices(options: ExportDatabaseServiceOptions): {
    configDB: ExportConfigDatabaseService;
    historyDB: ExportHistoryDatabaseService;
};

export { type AggregateFunction, type CustomProcessor, type DataQueryOptions, type DataTransformer, type DrizzleDb, type EngineInfo, type ExportConfig, ExportConfigDatabaseService, type ExportConfigRecord, ConfigValidationError as ExportConfigValidationError, type ExportDatabaseServiceOptions, type ExportEvent, type ExportEventListener, type ExportEventType, type ExportHistory, ExportHistoryDatabaseService, type ExportHistoryRecord, type ExportProgress, type ExportResult, type ExportTaskRecord, type FieldMapper, type FormatterFunction, type IDataSource, type IExportClient, type IExportEngine, type NewExportConfig, type NewExportHistory, type TaskCreateOptions, type TaskUpdateOptions, UniversalExportService, type UniversalExportServiceConfig, type ValidationError, type ValidationResult, type Validator, calculateProgress, convertFieldType, createBatchExportPreset, createExportDatabaseServices, createExportServiceConfig, createExportServiceFromEnv, createLargeAppPreset, createMediumAppPreset, createRealtimeExportPreset, createSmallAppPreset, createSmartExportPreset, createUniversalExportService, escapeCsvValue, estimateRemainingTime, exportConfigs, exportConfigsRelations, exportHistory, exportHistoryRelations, formatFieldValue, generateUniqueFilename, getNestedValue, validateExportConfig, validateEnvironment as validateExportEnvironment, validateFieldValue };
