import * as drizzle_orm from 'drizzle-orm';
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';

/**
 * 配置系统类型定义
 * ConfigEngine V2 - 数据驱动的配置管理
 */
type ConfigType = 'string' | 'number' | 'boolean' | 'json' | 'enum' | 'url' | 'email';
type UiComponentType = 'input' | 'textarea' | 'select' | 'switch' | 'slider' | 'color-picker';
type ConfigStatus = 'active' | 'deprecated' | 'disabled';
type ChangeType = 'create' | 'update' | 'delete';
/**
 * 验证规则
 */
interface ValidationRules {
    /** 最小值（数字） */
    min?: number;
    /** 最大值（数字） */
    max?: number;
    /** 最小长度（字符串） */
    minLength?: number;
    /** 最大长度（字符串） */
    maxLength?: number;
    /** 正则表达式 */
    pattern?: string;
    /** 是否为邮箱 */
    email?: boolean;
    /** 是否为 URL */
    url?: boolean;
    /** 自定义验证函数名 */
    custom?: string;
}
/**
 * UI 组件属性
 */
interface UiProps {
    /** 占位符 */
    placeholder?: string;
    /** 帮助文本 */
    helpText?: string;
    /** 前缀 */
    prefix?: string;
    /** 后缀 */
    suffix?: string;
    /** 步长（数字输入） */
    step?: number;
    /** 行数（文本域） */
    rows?: number;
    /** 是否禁用 */
    disabled?: boolean;
    /** 最大值（滑块） */
    max?: number;
    /** 最小值（滑块） */
    min?: number;
}
/**
 * 枚举选项
 */
interface EnumOption {
    /** 显示标签 */
    label: string;
    /** 实际值 */
    value: any;
    /** 描述 */
    description?: string;
    /** 图标 */
    icon?: string;
}
/**
 * 配置定义（完整）
 */
interface ConfigDefinition {
    id?: number;
    key: string;
    category: string;
    name: string;
    description?: string;
    type: ConfigType;
    validationRules?: ValidationRules;
    uiComponent?: UiComponentType;
    uiProps?: UiProps;
    isSensitive?: boolean;
    isRequired?: boolean;
    isReadonly?: boolean;
    requiredPermission?: string;
    defaultValue?: any;
    enumOptions?: EnumOption[];
    dependsOn?: string[];
    showIf?: Record<string, any>;
    groupName?: string;
    sortOrder?: number;
    version?: number;
    status?: ConfigStatus;
    tags?: string[];
    createdAt?: Date | string;
    updatedAt?: Date | string;
    createdBy?: number;
}
/**
 * 配置定义（用于创建）
 */
type ConfigDefinitionCreate = Omit<ConfigDefinition, 'id' | 'createdAt' | 'updatedAt'>;
/**
 * 配置定义（用于更新）
 */
type ConfigDefinitionUpdate = Partial<ConfigDefinitionCreate>;
/**
 * 配置定义（带值）
 */
interface ConfigDefinitionWithValue extends ConfigDefinition {
    value: any;
    displayValue?: any;
}
/**
 * 配置值
 */
interface ConfigValue {
    key: string;
    value: any;
}
/**
 * 配置变更历史
 */
interface ConfigHistoryRecord {
    id?: number;
    configKey: string;
    oldValue?: string;
    newValue?: string;
    changeType: ChangeType;
    changedBy?: number;
    changedAt?: Date | string;
    reason?: string;
    ipAddress?: string;
    userAgent?: string;
}
/**
 * 配置历史（用于创建）
 */
type ConfigHistoryCreate = Omit<ConfigHistoryRecord, 'id' | 'changedAt'>;
/**
 * 验证结果
 */
interface ValidationResult {
    valid: boolean;
    errors: string[];
}
/**
 * API 成功响应
 */
interface ApiSuccessResponse<T = any> {
    success: true;
    data: T;
    message?: string;
}
/**
 * API 错误响应
 */
interface ApiErrorResponse {
    success: false;
    error: string;
    details?: any;
}
/**
 * API 响应（联合类型）
 */
type ApiResponse<T = any> = ApiSuccessResponse<T> | ApiErrorResponse;
/**
 * 配置分组（UI 展示用）
 */
interface ConfigGroup {
    groupName: string;
    definitions: ConfigDefinitionWithValue[];
}
/**
 * 分类配置（UI 展示用）
 */
interface CategoryConfigs {
    category: string;
    groups: ConfigGroup[];
}
/**
 * 批量注册配置定义
 */
interface BatchRegisterRequest {
    definitions: ConfigDefinitionCreate[];
}
/**
 * 批量更新配置值
 */
interface BatchUpdateValuesRequest {
    values: Array<{
        key: string;
        value: any;
    }>;
}
/**
 * 配置元数据缓存
 */
interface ConfigMetadataCache {
    category: string;
    type: ConfigType;
    isSensitive: boolean;
    isRequired: boolean;
    defaultDescription?: string;
}
/**
 * 配置分类枚举
 */
declare enum ConfigCategory {
    DATABASE = "database",
    STORAGE = "storage",
    AI_SERVICE = "ai_service",
    EMAIL = "email",
    SECURITY = "security",
    SYSTEM = "system",
    MOBILE = "mobile",
    WECHAT = "wechat"
}
/**
 * 配置项（用于模板）
 */
interface ConfigItem {
    key: string;
    value: any;
    category: ConfigCategory;
    type: ConfigType;
    isRequired: boolean;
    isSensitive: boolean;
    description?: string;
    defaultValue?: any;
    group?: string;
    isGroupTemplate?: boolean;
    groupFields?: string[];
}

/**
 * 配置管理模块 - Drizzle ORM Schema
 *
 * 包含4个核心表：
 * 1. system_configs - 系统配置值表
 * 2. config_metadata - 配置元数据表
 * 3. config_definitions - 配置定义表（ConfigEngine核心）
 * 4. config_history - 配置变更历史表
 */
/**
 * 系统配置值表
 * 存储实际的配置键值对
 */
declare const systemConfigs: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "system_configs";
    schema: undefined;
    columns: {
        id: drizzle_orm_pg_core.PgColumn<{
            name: "id";
            tableName: "system_configs";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        key: drizzle_orm_pg_core.PgColumn<{
            name: "key";
            tableName: "system_configs";
            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;
        }, {}, {}>;
        value: drizzle_orm_pg_core.PgColumn<{
            name: "value";
            tableName: "system_configs";
            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;
        }, {}, {}>;
        description: drizzle_orm_pg_core.PgColumn<{
            name: "description";
            tableName: "system_configs";
            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: "system_configs";
            dataType: "string";
            columnType: "PgTimestampString";
            data: string;
            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: "system_configs";
            dataType: "string";
            columnType: "PgTimestampString";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    };
    dialect: "pg";
}>;
/**
 * 配置元数据表
 * 存储配置的类型、类别和验证规则等元数据
 */
declare const configMetadata: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "config_metadata";
    schema: undefined;
    columns: {
        key: drizzle_orm_pg_core.PgColumn<{
            name: "key";
            tableName: "config_metadata";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        category: drizzle_orm_pg_core.PgColumn<{
            name: "category";
            tableName: "config_metadata";
            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;
        }, {}, {}>;
        type: drizzle_orm_pg_core.PgColumn<{
            name: "type";
            tableName: "config_metadata";
            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;
        }, {}, {}>;
        isSensitive: drizzle_orm_pg_core.PgColumn<{
            name: "isSensitive";
            tableName: "config_metadata";
            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;
        }, {}, {}>;
        isRequired: drizzle_orm_pg_core.PgColumn<{
            name: "isRequired";
            tableName: "config_metadata";
            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;
        }, {}, {}>;
        defaultDescription: drizzle_orm_pg_core.PgColumn<{
            name: "defaultDescription";
            tableName: "config_metadata";
            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: "config_metadata";
            dataType: "string";
            columnType: "PgTimestampString";
            data: string;
            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: "config_metadata";
            dataType: "string";
            columnType: "PgTimestampString";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    };
    dialect: "pg";
}>;
/**
 * 配置定义表（ConfigEngine 核心）
 * 数据驱动的配置管理系统核心表
 */
declare const configDefinitions: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "config_definitions";
    schema: undefined;
    columns: {
        id: drizzle_orm_pg_core.PgColumn<{
            name: "id";
            tableName: "config_definitions";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: "always";
            generated: undefined;
        }, {}, {}>;
        key: drizzle_orm_pg_core.PgColumn<{
            name: "key";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        category: drizzle_orm_pg_core.PgColumn<{
            name: "category";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        name: drizzle_orm_pg_core.PgColumn<{
            name: "name";
            tableName: "config_definitions";
            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: "config_definitions";
            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;
        }, {}, {}>;
        type: drizzle_orm_pg_core.PgColumn<{
            name: "type";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        validationRules: drizzle_orm_pg_core.PgColumn<{
            name: "validationRules";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        uiComponent: drizzle_orm_pg_core.PgColumn<{
            name: "uiComponent";
            tableName: "config_definitions";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        uiProps: drizzle_orm_pg_core.PgColumn<{
            name: "uiProps";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        isSensitive: drizzle_orm_pg_core.PgColumn<{
            name: "isSensitive";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        isRequired: drizzle_orm_pg_core.PgColumn<{
            name: "isRequired";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        isReadonly: drizzle_orm_pg_core.PgColumn<{
            name: "isReadonly";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        requiredPermission: drizzle_orm_pg_core.PgColumn<{
            name: "requiredPermission";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        defaultValue: drizzle_orm_pg_core.PgColumn<{
            name: "defaultValue";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        enumOptions: drizzle_orm_pg_core.PgColumn<{
            name: "enumOptions";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        dependsOn: drizzle_orm_pg_core.PgColumn<{
            name: "dependsOn";
            tableName: "config_definitions";
            dataType: "array";
            columnType: "PgArray";
            data: string[];
            driverParam: string | string[];
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: drizzle_orm.Column<{
                name: "";
                tableName: "config_definitions";
                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;
            }, {}, {}>;
            identity: undefined;
            generated: undefined;
        }, {}, {
            baseBuilder: drizzle_orm_pg_core.PgColumnBuilder<{
                name: "";
                dataType: "string";
                columnType: "PgText";
                data: string;
                enumValues: [string, ...string[]];
                driverParam: string;
            }, {}, {}, drizzle_orm.ColumnBuilderExtraConfig>;
            size: undefined;
        }>;
        showIf: drizzle_orm_pg_core.PgColumn<{
            name: "showIf";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        groupName: drizzle_orm_pg_core.PgColumn<{
            name: "groupName";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        sortOrder: drizzle_orm_pg_core.PgColumn<{
            name: "sortOrder";
            tableName: "config_definitions";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        version: drizzle_orm_pg_core.PgColumn<{
            name: "version";
            tableName: "config_definitions";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        status: drizzle_orm_pg_core.PgColumn<{
            name: "status";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
        tags: drizzle_orm_pg_core.PgColumn<{
            name: "tags";
            tableName: "config_definitions";
            dataType: "array";
            columnType: "PgArray";
            data: string[];
            driverParam: string | string[];
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: drizzle_orm.Column<{
                name: "";
                tableName: "config_definitions";
                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;
            }, {}, {}>;
            identity: undefined;
            generated: undefined;
        }, {}, {
            baseBuilder: drizzle_orm_pg_core.PgColumnBuilder<{
                name: "";
                dataType: "string";
                columnType: "PgText";
                data: string;
                enumValues: [string, ...string[]];
                driverParam: string;
            }, {}, {}, drizzle_orm.ColumnBuilderExtraConfig>;
            size: undefined;
        }>;
        createdAt: drizzle_orm_pg_core.PgColumn<{
            name: "createdAt";
            tableName: "config_definitions";
            dataType: "string";
            columnType: "PgTimestampString";
            data: string;
            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: "config_definitions";
            dataType: "string";
            columnType: "PgTimestampString";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        createdBy: drizzle_orm_pg_core.PgColumn<{
            name: "createdBy";
            tableName: "config_definitions";
            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;
        }, {}, {}>;
    };
    dialect: "pg";
}>;
/**
 * 配置变更历史表
 * 记录所有配置的变更历史，用于审计和回滚
 */
declare const configHistory: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "config_history";
    schema: undefined;
    columns: {
        id: drizzle_orm_pg_core.PgColumn<{
            name: "id";
            tableName: "config_history";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: "always";
            generated: undefined;
        }, {}, {}>;
        configKey: drizzle_orm_pg_core.PgColumn<{
            name: "configKey";
            tableName: "config_history";
            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;
        }, {}, {}>;
        oldValue: drizzle_orm_pg_core.PgColumn<{
            name: "oldValue";
            tableName: "config_history";
            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;
        }, {}, {}>;
        newValue: drizzle_orm_pg_core.PgColumn<{
            name: "newValue";
            tableName: "config_history";
            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;
        }, {}, {}>;
        changeType: drizzle_orm_pg_core.PgColumn<{
            name: "changeType";
            tableName: "config_history";
            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;
        }, {}, {}>;
        changedBy: drizzle_orm_pg_core.PgColumn<{
            name: "changedBy";
            tableName: "config_history";
            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;
        }, {}, {}>;
        changedAt: drizzle_orm_pg_core.PgColumn<{
            name: "changedAt";
            tableName: "config_history";
            dataType: "string";
            columnType: "PgTimestampString";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        reason: drizzle_orm_pg_core.PgColumn<{
            name: "reason";
            tableName: "config_history";
            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;
        }, {}, {}>;
        ipAddress: drizzle_orm_pg_core.PgColumn<{
            name: "ipAddress";
            tableName: "config_history";
            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;
        }, {}, {}>;
        userAgent: drizzle_orm_pg_core.PgColumn<{
            name: "userAgent";
            tableName: "config_history";
            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;
        }, {}, {}>;
    };
    dialect: "pg";
}>;

/**
 * ConfigEngine V2 - 数据驱动的配置管理引擎
 *
 * 核心功能：
 * 1. 从数据库加载配置定义
 * 2. 配置值的验证和管理
 * 3. 配置变更历史记录
 * 4. 敏感信息加密/解密
 *
 * 使用方法:
 * ```typescript
 * import { ConfigEngine } from 'sa2kit/config/server';
 *
 * const engine = new ConfigEngine(db);
 * await engine.initialize();
 *
 * // 获取配置值
 * const value = await engine.getValue('config_key');
 *
 * // 设置配置值
 * await engine.setValue('config_key', 'new_value', userId);
 * ```
 */

/**
 * 数据库接口（使用Drizzle ORM）
 * 使用 any 类型以避免复杂的类型推导
 */
type DatabaseClient = any;
/**
 * 数据库表定义
 */
interface DatabaseTables {
    systemConfigs: any;
    configDefinitions?: any;
    configMetadata?: any;
    configHistory: any;
}
/**
 * 日志接口
 */
interface Logger {
    info: (message: string, ...args: any[]) => void;
    warn: (message: string, ...args: any[]) => void;
    error: (message: string, ...args: any[]) => void;
}
/**
 * ConfigEngine 配置选项
 */
interface ConfigEngineOptions {
    /** 数据库客户端 */
    db: DatabaseClient;
    /** 数据库表定义 */
    tables: DatabaseTables;
    /** 加密密钥 */
    encryptionKey?: string;
    /** 日志记录器 */
    logger?: Logger;
}
/**
 * 配置引擎类
 */
declare class ConfigEngine {
    private definitionsCache;
    private encryptionKey;
    private initialized;
    private db;
    private tables;
    private logger;
    constructor(options: ConfigEngineOptions);
    /**
     * 初始化配置引擎
     */
    initialize(): Promise<void>;
    /**
     * 从数据库加载所有配置定义到缓存
     */
    loadDefinitions(): Promise<void>;
    /**
     * 获取单个配置定义
     */
    getDefinition(key: string): ConfigDefinition | undefined;
    /**
     * 获取所有配置定义
     */
    getAllDefinitions(): ConfigDefinition[];
    /**
     * 获取指定分类的配置定义
     */
    getDefinitionsByCategory(category: string): ConfigDefinition[];
    /**
     * 验证配置值
     */
    validate(key: string, value: any): Promise<ValidationResult>;
    /**
     * 获取配置的完整数据（定义 + 值）
     */
    getConfigsWithValues(category?: string): Promise<ConfigDefinitionWithValue[]>;
    /**
     * 获取单个配置值
     */
    getValue(key: string): Promise<any>;
    /**
     * 设置配置值
     */
    setValue(key: string, value: any, userId?: number, options?: {
        reason?: string;
        ipAddress?: string;
        userAgent?: string;
    }): Promise<void>;
    /**
     * 批量设置配置值
     */
    setValues(values: Array<{
        key: string;
        value: any;
    }>, userId?: number, options?: {
        reason?: string;
        ipAddress?: string;
        userAgent?: string;
    }): Promise<void>;
    /**
     * 注册新配置定义
     */
    registerDefinition(definition: ConfigDefinitionCreate, userId?: number): Promise<void>;
    /**
     * 批量注册配置定义
     */
    registerDefinitions(definitions: ConfigDefinitionCreate[], userId?: number): Promise<void>;
    /**
     * 记录配置变更历史
     */
    private recordHistory;
    /**
     * 获取配置变更历史
     */
    getHistory(key: string, limit?: number): Promise<any[]>;
    /**
     * 类型验证
     */
    private validateType;
    /**
     * 规则验证
     */
    private validateRules;
    /**
     * 加密
     */
    private encrypt;
    /**
     * 解密
     */
    private decrypt;
    /**
     * 掩码显示敏感值
     */
    private maskValue;
}

/**
 * ConfigService - 简化的配置管理服务
 *
 * 提供更简单的API来管理配置，封装ConfigEngine的复杂性
 *
 * 使用方法:
 * ```typescript
 * import { ConfigService } from 'sa2kit/config/server';
 * import { ConfigCategory, ConfigType } from 'sa2kit/config/server';
 *
 * const service = new ConfigService({ db, tables });
 *
 * // 获取配置
 * const apiKey = await service.getConfig('api_key', 'default-key');
 *
 * // 设置配置
 * await service.setConfig('api_key', 'new-key');
 *
 * // 获取分类下的所有配置
 * const storageConfigs = await service.getConfigsByCategory(ConfigCategory.STORAGE);
 * ```
 */

/**
 * 配置模板（用于初始化默认配置）
 */
type ConfigTemplates$1 = Record<string, ConfigItem[]>;
/**
 * ConfigService 配置选项
 */
interface ConfigServiceOptions {
    /** 数据库客户端 */
    db: DatabaseClient;
    /** 数据库表定义 */
    tables: DatabaseTables;
    /** 加密密钥 */
    encryptionKey?: string;
    /** 日志记录器 */
    logger?: Logger;
    /** 配置模板 */
    templates?: ConfigTemplates$1;
}
/**
 * 配置管理服务类
 */
declare class ConfigService {
    private configCache;
    private metadataCache;
    private encryptionKey;
    private db;
    private tables;
    private logger;
    private templates;
    constructor(options: ConfigServiceOptions);
    private loadMetadataFromDatabase;
    private loadConfigsFromDatabase;
    getConfig(key: string, defaultValue?: any): Promise<any>;
    setConfig(key: string, value: any, description?: string): Promise<void>;
    getConfigsByCategory(category: ConfigCategory): Promise<Record<string, any>>;
    setConfigs(configs: Record<string, any>): Promise<void>;
    deleteConfig(key: string): Promise<void>;
    getAllConfigs(): Promise<Record<string, any>>;
    refreshCache(): Promise<void>;
    validateConfig(key: string, value: any): boolean;
    private encrypt;
    private decrypt;
    private parseValue;
    private validateValue;
    private getConfigType;
    private getConfigCategory;
    private isSensitiveConfig;
    private isRequiredConfig;
    private getConfigDescription;
    setConfigMetadata(key: string, category: string, type?: ConfigType, options?: {
        isSensitive?: boolean;
        isRequired?: boolean;
        defaultDescription?: string;
    }): Promise<void>;
}
/**
 * 创建ConfigService实例的工厂函数
 */
declare function createConfigService(options: ConfigServiceOptions): ConfigService;

/**
 * 配置模板
 *
 * 提供常用的配置项模板，可用于初始化默认配置
 */

/**
 * 配置模板类型
 */
type ConfigTemplates = Record<string, ConfigItem[]>;
/**
 * 默认配置模板
 *
 * 包含常见的配置项，可作为参考或直接使用
 */
declare const DEFAULT_CONFIG_TEMPLATES: ConfigTemplates;
/**
 * 创建自定义配置模板
 *
 * @param templates 配置模板
 * @returns 合并后的配置模板
 */
declare function createConfigTemplates(templates: Partial<ConfigTemplates>): ConfigTemplates;

/**
 * 配置服务工厂函数
 *
 * 提供便捷的工厂函数来创建 ConfigService 和 ConfigEngine 实例
 */

/**
 * 创建 ConfigEngine 实例的工厂函数
 */
declare function createConfigEngine(options: ConfigEngineOptions): ConfigEngine;
/**
 * 创建全局单例的 ConfigService 工厂
 *
 * @example
 * ```typescript
 * const getConfigService = createGlobalConfigService({
 *   db,
 *   tables: { systemConfigs, configMetadata, configHistory }
 * });
 *
 * // 在任何地方使用
 * const service = getConfigService();
 * ```
 */
declare function createGlobalConfigService(options: ConfigServiceOptions): () => ConfigService;
/**
 * 创建全局单例的 ConfigEngine 工厂
 *
 * @example
 * ```typescript
 * const getConfigEngine = createGlobalConfigEngine({
 *   db,
 *   tables: { systemConfigs, configDefinitions, configHistory }
 * });
 *
 * // 在任何地方使用
 * const engine = getConfigEngine();
 * await engine.initialize();
 * ```
 */
declare function createGlobalConfigEngine(options: ConfigEngineOptions): () => ConfigEngine;

/**
 * 数据库连接配置管理
 *
 * 注意：这些配置应该从环境变量读取，不存储在数据库中
 * 因为它们是连接数据库本身所需的基础配置
 */
interface DatabaseConnectionConfig {
    host: string;
    port: number;
    database: string;
    username: string;
    password: string;
    ssl?: boolean;
    poolSize?: number;
    queryTimeout?: number;
}
interface RedisConnectionConfig {
    host: string;
    port: number;
    password?: string;
    database?: number;
    keyPrefix?: string;
}
/**
 * 从环境变量解析数据库连接配置
 */
declare function getDatabaseConfig(): DatabaseConnectionConfig;
/**
 * 从环境变量解析 Redis 连接配置
 */
declare function getRedisConfig(): RedisConnectionConfig;
/**
 * 生成数据库连接 URL
 */
declare function buildDatabaseUrl(config: DatabaseConnectionConfig): string;
/**
 * 生成 Redis 连接 URL
 */
declare function buildRedisUrl(config: RedisConnectionConfig): string;
/**
 * 验证数据库连接配置
 */
declare function validateDatabaseConfig(config: DatabaseConnectionConfig): string[];
/**
 * 显示数据库连接配置（用于管理界面只读显示）
 * 敏感信息会被掩码处理
 */
declare function getDatabaseConfigForDisplay(): Record<string, any>;

export { type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type BatchRegisterRequest, type BatchUpdateValuesRequest, type CategoryConfigs, type ChangeType, ConfigCategory, type ConfigDefinition, type ConfigDefinitionCreate, type ConfigDefinitionUpdate, type ConfigDefinitionWithValue, ConfigEngine, type ConfigEngineOptions, type ConfigGroup, type ConfigHistoryCreate, type ConfigHistoryRecord, type ConfigItem, type ConfigMetadataCache, ConfigService, type ConfigServiceOptions, type ConfigStatus, type ConfigTemplates$1 as ConfigTemplates, type ConfigType, type ConfigValue, DEFAULT_CONFIG_TEMPLATES, type DatabaseClient, type DatabaseConnectionConfig, type DatabaseTables, type EnumOption, type Logger, type RedisConnectionConfig, type UiComponentType, type UiProps, type ValidationResult, type ValidationRules, buildDatabaseUrl, buildRedisUrl, configDefinitions, configHistory, configMetadata, createConfigEngine, createConfigService, createConfigTemplates, createGlobalConfigEngine, createGlobalConfigService, getDatabaseConfig, getDatabaseConfigForDisplay, getRedisConfig, systemConfigs, validateDatabaseConfig };
