sa2kit 1.6.23 → 1.6.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,5 +27,5 @@ var ExportFileError = class extends ExportServiceError {
27
27
  };
28
28
 
29
29
  export { ExportConfigError, ExportDataError, ExportFileError, ExportServiceError };
30
- //# sourceMappingURL=chunk-7XLFSPDG.mjs.map
31
- //# sourceMappingURL=chunk-7XLFSPDG.mjs.map
30
+ //# sourceMappingURL=chunk-LFB5EIIM.mjs.map
31
+ //# sourceMappingURL=chunk-LFB5EIIM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/universalExport/types.ts"],"names":[],"mappings":";AAuRO,IAAM,kBAAA,GAAN,cAAiC,KAAA,CAAM;AAAA,EAC5C,WAAA,CACE,OAAA,EACgB,IAAA,EACA,OAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AAAA,EACd;AACF;AAGO,IAAM,iBAAA,GAAN,cAAgC,kBAAA,CAAmB;AAAA,EACxD,WAAA,CAAY,SAAiB,OAAA,EAA+B;AAC1D,IAAA,KAAA,CAAM,OAAA,EAAS,uBAAuB,OAAO,CAAA;AAC7C,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AAAA,EACd;AACF;AAGO,IAAM,eAAA,GAAN,cAA8B,kBAAA,CAAmB;AAAA,EACtD,WAAA,CAAY,SAAiB,OAAA,EAA+B;AAC1D,IAAA,KAAA,CAAM,OAAA,EAAS,qBAAqB,OAAO,CAAA;AAC3C,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EACd;AACF;AAGO,IAAM,eAAA,GAAN,cAA8B,kBAAA,CAAmB;AAAA,EACtD,WAAA,CAAY,SAAiB,OAAA,EAA+B;AAC1D,IAAA,KAAA,CAAM,OAAA,EAAS,qBAAqB,OAAO,CAAA;AAC3C,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EACd;AACF","file":"chunk-LFB5EIIM.mjs","sourcesContent":["/**\n * 通用导出服务类型定义\n *\n * 定义了导出功能的核心接口和类型\n */\n\n// ============= 基础类型定义 =============\n\n/** 导出格式类型 */\nexport type ExportFormat = 'csv' | 'excel' | 'json';\n\n/** 字段类型 */\nexport type FieldType = 'string' | 'number' | 'date' | 'boolean' | 'array' | 'object';\n\n/** 字段对齐方式 */\nexport type FieldAlignment = 'left' | 'center' | 'right';\n\n/** 导出状态 */\nexport type ExportStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';\n\n/** 分组模式 */\nexport type GroupingMode = 'merge' | 'separate' | 'nested';\n\n/** 分组处理类型 */\nexport type GroupValueProcessing = 'first' | 'last' | 'concat' | 'sum' | 'count' | 'custom';\n\n// ============= 字段定义接口 =============\n\n/** 导出字段定义 */\nexport interface ExportField {\n /** 字段键名 */\n key: string;\n /** 字段显示名称 */\n label: string;\n /** 字段类型 */\n type: FieldType;\n /** 是否启用 */\n enabled: boolean;\n /** 字段宽度 */\n width?: number;\n /** 对齐方式 */\n alignment?: FieldAlignment;\n /** 格式化函数 */\n formatter?: (value: any) => string;\n /** 排序权重 */\n sortOrder?: number;\n /** 是否必填 */\n required?: boolean;\n /** 字段描述 */\n description?: string;\n /** 自定义样式 */\n style?: Record<string, any>;\n}\n\n/** 分组字段配置 */\nexport interface GroupingField {\n /** 分组字段键名 */\n key: string;\n /** 分组字段显示名称 */\n label: string;\n /** 分组模式 */\n mode: GroupingMode;\n /** 其他字段的值处理方式 */\n valueProcessing: GroupValueProcessing;\n /** 自定义处理函数 */\n customProcessor?: (values: any[]) => any;\n /** 是否显示分组行 */\n showGroupHeader: boolean;\n /** 分组行模板 */\n groupHeaderTemplate?: string;\n /** 是否合并单元格(仅Excel格式支持) */\n mergeCells: boolean;\n}\n\n/** 分组配置 */\nexport interface GroupingConfig {\n /** 是否启用分组 */\n enabled: boolean;\n /** 分组字段列表(支持多级分组) */\n fields: GroupingField[];\n /** 分组后是否保持原始顺序 */\n preserveOrder: boolean;\n /** 空值处理方式 */\n nullValueHandling: 'skip' | 'group' | 'separate';\n /** 空值分组名称 */\n nullGroupName?: string;\n}\n\n/** 导出配置 */\nexport interface ExportConfig {\n /** 配置ID */\n id: string;\n /** 配置名称 */\n name: string;\n /** 配置描述 */\n description?: string;\n /** 导出格式 */\n format: ExportFormat;\n /** 字段定义 */\n fields: ExportField[];\n /** 分组配置 */\n grouping?: GroupingConfig;\n /** 文件名模板 */\n fileNameTemplate: string;\n /** 是否包含表头 */\n includeHeader: boolean;\n /** 分隔符 */\n delimiter: string;\n /** 编码格式 */\n encoding: string;\n /** 是否添加BOM */\n addBOM: boolean;\n /** 最大行数限制 */\n maxRows?: number;\n /** 创建时间 */\n createdAt: Date;\n /** 更新时间 */\n updatedAt: Date;\n /** 模块标识 */\n moduleId: string;\n /** 业务标识 */\n businessId?: string;\n /** 创建者ID */\n createdBy?: string;\n}\n\n/** 导出请求 */\nexport interface ExportRequest {\n /** 导出配置ID或配置对象 */\n configId: string | ExportConfig;\n /** 数据源 */\n dataSource: string | (() => Promise<any[]>) | any[];\n /** 查询参数 */\n queryParams?: Record<string, any>;\n /** 自定义字段映射 */\n fieldMapping?: Record<string, string>;\n /** 过滤条件 */\n filters?: ExportFilter[];\n /** 排序条件 */\n sortBy?: ExportSort[];\n /** 分页参数 */\n pagination?: {\n page: number;\n pageSize: number;\n };\n /** 自定义文件名 */\n customFileName?: string;\n /** 回调函数 */\n callbacks?: {\n onProgress?: (progress: ExportProgress) => void;\n onSuccess?: (result: ExportResult) => void;\n onError?: (error: ExportError) => void;\n };\n}\n\n/** 导出过滤器 */\nexport interface ExportFilter {\n /** 字段名 */\n field: string;\n /** 操作符 */\n operator:\n | 'eq'\n | 'ne'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'contains'\n | 'startsWith'\n | 'endsWith'\n | 'in'\n | 'notIn';\n /** 值 */\n value: any;\n}\n\n/** 导出排序 */\nexport interface ExportSort {\n /** 字段名 */\n field: string;\n /** 排序方向 */\n direction: 'asc' | 'desc';\n}\n\n/** 导出进度 */\nexport interface ExportProgress {\n /** 导出ID */\n exportId: string;\n /** 状态 */\n status: ExportStatus;\n /** 进度百分比 */\n progress: number;\n /** 已处理行数 */\n processedRows: number;\n /** 总行数 */\n totalRows: number;\n /** 开始时间 */\n startTime: Date;\n /** 预计完成时间 */\n estimatedEndTime?: Date;\n /** 当前处理的数据 */\n currentData?: any;\n /** 错误信息 */\n error?: string;\n}\n\n/** 导出结果 */\nexport interface ExportResult {\n /** 导出ID */\n exportId: string;\n /** 文件名 */\n fileName: string;\n /** 文件大小 */\n fileSize: number;\n /** 文件URL */\n fileUrl?: string;\n /** 文件Blob */\n fileBlob?: Blob;\n /** 导出行数 */\n exportedRows: number;\n /** 开始时间 */\n startTime: Date;\n /** 完成时间 */\n endTime: Date;\n /** 耗时(毫秒) */\n duration: number;\n /** 统计信息 */\n statistics?: {\n totalRows: number;\n filteredRows: number;\n exportedRows: number;\n skippedRows: number;\n };\n}\n\n/** 导出错误 */\nexport interface ExportError {\n /** 错误代码 */\n code: string;\n /** 错误消息 */\n message: string;\n /** 错误详情 */\n details?: Record<string, any>;\n /** 错误时间 */\n timestamp: Date;\n}\n\n// ============= 服务配置接口 =============\n\n/** 通用导出服务配置 */\nexport interface UniversalExportServiceConfig {\n /** 默认导出格式 */\n defaultFormat: ExportFormat;\n /** 默认分隔符 */\n defaultDelimiter: string;\n /** 默认编码 */\n defaultEncoding: string;\n /** 是否默认添加BOM */\n defaultAddBOM: boolean;\n /** 最大文件大小限制(字节) */\n maxFileSize: number;\n /** 最大行数限制 */\n maxRowsLimit: number;\n /** 并发导出数量限制 */\n maxConcurrentExports: number;\n /** 导出超时时间(毫秒) */\n exportTimeout: number;\n /** 缓存配置 */\n cache: {\n /** 配置缓存TTL(秒) */\n configTTL: number;\n /** 结果缓存TTL(秒) */\n resultTTL: number;\n };\n}\n\n// ============= 异常类定义 =============\n\n/** 导出服务基础异常 */\nexport class ExportServiceError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly details?: Record<string, any>\n ) {\n super(message);\n this.name = 'ExportServiceError';\n }\n}\n\n/** 导出配置错误 */\nexport class ExportConfigError extends ExportServiceError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'EXPORT_CONFIG_ERROR', details);\n this.name = 'ExportConfigError';\n }\n}\n\n/** 导出数据处理错误 */\nexport class ExportDataError extends ExportServiceError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'EXPORT_DATA_ERROR', details);\n this.name = 'ExportDataError';\n }\n}\n\n/** 导出文件生成错误 */\nexport class ExportFileError extends ExportServiceError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'EXPORT_FILE_ERROR', details);\n this.name = 'ExportFileError';\n }\n}\n\n// ============= 事件类型定义 =============\n\n/** 导出事件类型 */\nexport type ExportEventType =\n | 'export:start'\n | 'export:progress'\n | 'export:complete'\n | 'export:error'\n | 'export:cancel'\n | 'config:save'\n | 'config:delete';\n\n/** 导出事件 */\nexport interface ExportEvent {\n /** 事件类型 */\n type: ExportEventType;\n /** 导出ID */\n exportId: string;\n /** 事件时间 */\n timestamp: Date;\n /** 事件数据 */\n data?: Record<string, any>;\n /** 错误信息 */\n error?: string;\n}\n\n/** 导出事件监听器 */\nexport type ExportEventListener = (event: ExportEvent) => void | Promise<void>;\n\n// ============= 工具类型 =============\n\n/** 字段映射函数 */\nexport type FieldMapper<T = any> = (item: T, index: number) => Record<string, any>;\n\n/** 数据转换函数 */\nexport type DataTransformer<T = any, R = any> = (data: T[]) => R[];\n\n/** 验证函数 */\nexport type Validator<T = any> = (data: T) => boolean | string;\n\n/** 格式化函数 */\nexport type Formatter<T = any> = (value: T) => string;\n"]}
@@ -32,5 +32,5 @@ exports.ExportConfigError = ExportConfigError;
32
32
  exports.ExportDataError = ExportDataError;
33
33
  exports.ExportFileError = ExportFileError;
34
34
  exports.ExportServiceError = ExportServiceError;
35
- //# sourceMappingURL=chunk-GCVOKQZP.js.map
36
- //# sourceMappingURL=chunk-GCVOKQZP.js.map
35
+ //# sourceMappingURL=chunk-UIYKZ73N.js.map
36
+ //# sourceMappingURL=chunk-UIYKZ73N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/universalExport/types.ts"],"names":[],"mappings":";;;AAuRO,IAAM,kBAAA,GAAN,cAAiC,KAAA,CAAM;AAAA,EAC5C,WAAA,CACE,OAAA,EACgB,IAAA,EACA,OAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AAAA,EACd;AACF;AAGO,IAAM,iBAAA,GAAN,cAAgC,kBAAA,CAAmB;AAAA,EACxD,WAAA,CAAY,SAAiB,OAAA,EAA+B;AAC1D,IAAA,KAAA,CAAM,OAAA,EAAS,uBAAuB,OAAO,CAAA;AAC7C,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AAAA,EACd;AACF;AAGO,IAAM,eAAA,GAAN,cAA8B,kBAAA,CAAmB;AAAA,EACtD,WAAA,CAAY,SAAiB,OAAA,EAA+B;AAC1D,IAAA,KAAA,CAAM,OAAA,EAAS,qBAAqB,OAAO,CAAA;AAC3C,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EACd;AACF;AAGO,IAAM,eAAA,GAAN,cAA8B,kBAAA,CAAmB;AAAA,EACtD,WAAA,CAAY,SAAiB,OAAA,EAA+B;AAC1D,IAAA,KAAA,CAAM,OAAA,EAAS,qBAAqB,OAAO,CAAA;AAC3C,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EACd;AACF","file":"chunk-UIYKZ73N.js","sourcesContent":["/**\n * 通用导出服务类型定义\n *\n * 定义了导出功能的核心接口和类型\n */\n\n// ============= 基础类型定义 =============\n\n/** 导出格式类型 */\nexport type ExportFormat = 'csv' | 'excel' | 'json';\n\n/** 字段类型 */\nexport type FieldType = 'string' | 'number' | 'date' | 'boolean' | 'array' | 'object';\n\n/** 字段对齐方式 */\nexport type FieldAlignment = 'left' | 'center' | 'right';\n\n/** 导出状态 */\nexport type ExportStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';\n\n/** 分组模式 */\nexport type GroupingMode = 'merge' | 'separate' | 'nested';\n\n/** 分组处理类型 */\nexport type GroupValueProcessing = 'first' | 'last' | 'concat' | 'sum' | 'count' | 'custom';\n\n// ============= 字段定义接口 =============\n\n/** 导出字段定义 */\nexport interface ExportField {\n /** 字段键名 */\n key: string;\n /** 字段显示名称 */\n label: string;\n /** 字段类型 */\n type: FieldType;\n /** 是否启用 */\n enabled: boolean;\n /** 字段宽度 */\n width?: number;\n /** 对齐方式 */\n alignment?: FieldAlignment;\n /** 格式化函数 */\n formatter?: (value: any) => string;\n /** 排序权重 */\n sortOrder?: number;\n /** 是否必填 */\n required?: boolean;\n /** 字段描述 */\n description?: string;\n /** 自定义样式 */\n style?: Record<string, any>;\n}\n\n/** 分组字段配置 */\nexport interface GroupingField {\n /** 分组字段键名 */\n key: string;\n /** 分组字段显示名称 */\n label: string;\n /** 分组模式 */\n mode: GroupingMode;\n /** 其他字段的值处理方式 */\n valueProcessing: GroupValueProcessing;\n /** 自定义处理函数 */\n customProcessor?: (values: any[]) => any;\n /** 是否显示分组行 */\n showGroupHeader: boolean;\n /** 分组行模板 */\n groupHeaderTemplate?: string;\n /** 是否合并单元格(仅Excel格式支持) */\n mergeCells: boolean;\n}\n\n/** 分组配置 */\nexport interface GroupingConfig {\n /** 是否启用分组 */\n enabled: boolean;\n /** 分组字段列表(支持多级分组) */\n fields: GroupingField[];\n /** 分组后是否保持原始顺序 */\n preserveOrder: boolean;\n /** 空值处理方式 */\n nullValueHandling: 'skip' | 'group' | 'separate';\n /** 空值分组名称 */\n nullGroupName?: string;\n}\n\n/** 导出配置 */\nexport interface ExportConfig {\n /** 配置ID */\n id: string;\n /** 配置名称 */\n name: string;\n /** 配置描述 */\n description?: string;\n /** 导出格式 */\n format: ExportFormat;\n /** 字段定义 */\n fields: ExportField[];\n /** 分组配置 */\n grouping?: GroupingConfig;\n /** 文件名模板 */\n fileNameTemplate: string;\n /** 是否包含表头 */\n includeHeader: boolean;\n /** 分隔符 */\n delimiter: string;\n /** 编码格式 */\n encoding: string;\n /** 是否添加BOM */\n addBOM: boolean;\n /** 最大行数限制 */\n maxRows?: number;\n /** 创建时间 */\n createdAt: Date;\n /** 更新时间 */\n updatedAt: Date;\n /** 模块标识 */\n moduleId: string;\n /** 业务标识 */\n businessId?: string;\n /** 创建者ID */\n createdBy?: string;\n}\n\n/** 导出请求 */\nexport interface ExportRequest {\n /** 导出配置ID或配置对象 */\n configId: string | ExportConfig;\n /** 数据源 */\n dataSource: string | (() => Promise<any[]>) | any[];\n /** 查询参数 */\n queryParams?: Record<string, any>;\n /** 自定义字段映射 */\n fieldMapping?: Record<string, string>;\n /** 过滤条件 */\n filters?: ExportFilter[];\n /** 排序条件 */\n sortBy?: ExportSort[];\n /** 分页参数 */\n pagination?: {\n page: number;\n pageSize: number;\n };\n /** 自定义文件名 */\n customFileName?: string;\n /** 回调函数 */\n callbacks?: {\n onProgress?: (progress: ExportProgress) => void;\n onSuccess?: (result: ExportResult) => void;\n onError?: (error: ExportError) => void;\n };\n}\n\n/** 导出过滤器 */\nexport interface ExportFilter {\n /** 字段名 */\n field: string;\n /** 操作符 */\n operator:\n | 'eq'\n | 'ne'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'contains'\n | 'startsWith'\n | 'endsWith'\n | 'in'\n | 'notIn';\n /** 值 */\n value: any;\n}\n\n/** 导出排序 */\nexport interface ExportSort {\n /** 字段名 */\n field: string;\n /** 排序方向 */\n direction: 'asc' | 'desc';\n}\n\n/** 导出进度 */\nexport interface ExportProgress {\n /** 导出ID */\n exportId: string;\n /** 状态 */\n status: ExportStatus;\n /** 进度百分比 */\n progress: number;\n /** 已处理行数 */\n processedRows: number;\n /** 总行数 */\n totalRows: number;\n /** 开始时间 */\n startTime: Date;\n /** 预计完成时间 */\n estimatedEndTime?: Date;\n /** 当前处理的数据 */\n currentData?: any;\n /** 错误信息 */\n error?: string;\n}\n\n/** 导出结果 */\nexport interface ExportResult {\n /** 导出ID */\n exportId: string;\n /** 文件名 */\n fileName: string;\n /** 文件大小 */\n fileSize: number;\n /** 文件URL */\n fileUrl?: string;\n /** 文件Blob */\n fileBlob?: Blob;\n /** 导出行数 */\n exportedRows: number;\n /** 开始时间 */\n startTime: Date;\n /** 完成时间 */\n endTime: Date;\n /** 耗时(毫秒) */\n duration: number;\n /** 统计信息 */\n statistics?: {\n totalRows: number;\n filteredRows: number;\n exportedRows: number;\n skippedRows: number;\n };\n}\n\n/** 导出错误 */\nexport interface ExportError {\n /** 错误代码 */\n code: string;\n /** 错误消息 */\n message: string;\n /** 错误详情 */\n details?: Record<string, any>;\n /** 错误时间 */\n timestamp: Date;\n}\n\n// ============= 服务配置接口 =============\n\n/** 通用导出服务配置 */\nexport interface UniversalExportServiceConfig {\n /** 默认导出格式 */\n defaultFormat: ExportFormat;\n /** 默认分隔符 */\n defaultDelimiter: string;\n /** 默认编码 */\n defaultEncoding: string;\n /** 是否默认添加BOM */\n defaultAddBOM: boolean;\n /** 最大文件大小限制(字节) */\n maxFileSize: number;\n /** 最大行数限制 */\n maxRowsLimit: number;\n /** 并发导出数量限制 */\n maxConcurrentExports: number;\n /** 导出超时时间(毫秒) */\n exportTimeout: number;\n /** 缓存配置 */\n cache: {\n /** 配置缓存TTL(秒) */\n configTTL: number;\n /** 结果缓存TTL(秒) */\n resultTTL: number;\n };\n}\n\n// ============= 异常类定义 =============\n\n/** 导出服务基础异常 */\nexport class ExportServiceError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly details?: Record<string, any>\n ) {\n super(message);\n this.name = 'ExportServiceError';\n }\n}\n\n/** 导出配置错误 */\nexport class ExportConfigError extends ExportServiceError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'EXPORT_CONFIG_ERROR', details);\n this.name = 'ExportConfigError';\n }\n}\n\n/** 导出数据处理错误 */\nexport class ExportDataError extends ExportServiceError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'EXPORT_DATA_ERROR', details);\n this.name = 'ExportDataError';\n }\n}\n\n/** 导出文件生成错误 */\nexport class ExportFileError extends ExportServiceError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'EXPORT_FILE_ERROR', details);\n this.name = 'ExportFileError';\n }\n}\n\n// ============= 事件类型定义 =============\n\n/** 导出事件类型 */\nexport type ExportEventType =\n | 'export:start'\n | 'export:progress'\n | 'export:complete'\n | 'export:error'\n | 'export:cancel'\n | 'config:save'\n | 'config:delete';\n\n/** 导出事件 */\nexport interface ExportEvent {\n /** 事件类型 */\n type: ExportEventType;\n /** 导出ID */\n exportId: string;\n /** 事件时间 */\n timestamp: Date;\n /** 事件数据 */\n data?: Record<string, any>;\n /** 错误信息 */\n error?: string;\n}\n\n/** 导出事件监听器 */\nexport type ExportEventListener = (event: ExportEvent) => void | Promise<void>;\n\n// ============= 工具类型 =============\n\n/** 字段映射函数 */\nexport type FieldMapper<T = any> = (item: T, index: number) => Record<string, any>;\n\n/** 数据转换函数 */\nexport type DataTransformer<T = any, R = any> = (data: T[]) => R[];\n\n/** 验证函数 */\nexport type Validator<T = any> = (data: T) => boolean | string;\n\n/** 格式化函数 */\nexport type Formatter<T = any> = (value: T) => string;\n"]}
@@ -114,7 +114,7 @@ interface ExportRequest {
114
114
  /** 导出配置ID或配置对象 */
115
115
  configId: string | ExportConfig;
116
116
  /** 数据源 */
117
- dataSource: string | (() => Promise<any[]>);
117
+ dataSource: string | (() => Promise<any[]>) | any[];
118
118
  /** 查询参数 */
119
119
  queryParams?: Record<string, any>;
120
120
  /** 自定义字段映射 */
@@ -114,7 +114,7 @@ interface ExportRequest {
114
114
  /** 导出配置ID或配置对象 */
115
115
  configId: string | ExportConfig;
116
116
  /** 数据源 */
117
- dataSource: string | (() => Promise<any[]>);
117
+ dataSource: string | (() => Promise<any[]>) | any[];
118
118
  /** 查询参数 */
119
119
  queryParams?: Record<string, any>;
120
120
  /** 自定义字段映射 */
@@ -1,5 +1,5 @@
1
- import { E as ExportConfig, a as ExportRequest, b as ExportResult, c as ExportProgress, d as ExportFormat, F as Formatter, e as ExportField } from '../types-XTo80Oi_.mjs';
2
- export { D as DataTransformer, g as ExportConfigError, h as ExportDataError, r as ExportError, t as ExportEvent, u as ExportEventListener, s as ExportEventType, i as ExportFileError, p as ExportFilter, f as ExportServiceError, q as ExportSort, l as ExportStatus, k as FieldAlignment, v as FieldMapper, j as FieldType, m as GroupValueProcessing, o as GroupingConfig, n as GroupingField, G as GroupingMode, U as UniversalExportServiceConfig, V as Validator } from '../types-XTo80Oi_.mjs';
1
+ import { E as ExportConfig, a as ExportRequest, b as ExportResult, c as ExportProgress, d as ExportFormat, F as Formatter, e as ExportField } from '../types-DszP7SAQ.mjs';
2
+ export { D as DataTransformer, g as ExportConfigError, h as ExportDataError, r as ExportError, t as ExportEvent, u as ExportEventListener, s as ExportEventType, i as ExportFileError, p as ExportFilter, f as ExportServiceError, q as ExportSort, l as ExportStatus, k as FieldAlignment, v as FieldMapper, j as FieldType, m as GroupValueProcessing, o as GroupingConfig, n as GroupingField, G as GroupingMode, U as UniversalExportServiceConfig, V as Validator } from '../types-DszP7SAQ.mjs';
3
3
  import React__default from 'react';
4
4
 
5
5
  /**
@@ -41,7 +41,9 @@ declare class UniversalExportClient {
41
41
  /**
42
42
  * 触发数据导出
43
43
  */
44
- exportData(request: Omit<ExportRequest, 'callbacks'>): Promise<ExportResult>;
44
+ exportData(request: Omit<ExportRequest, 'callbacks' | 'dataSource'> & {
45
+ dataSource: any[] | string;
46
+ }): Promise<ExportResult>;
45
47
  /**
46
48
  * 查询导出进度
47
49
  */
@@ -1,5 +1,5 @@
1
- import { E as ExportConfig, a as ExportRequest, b as ExportResult, c as ExportProgress, d as ExportFormat, F as Formatter, e as ExportField } from '../types-XTo80Oi_.js';
2
- export { D as DataTransformer, g as ExportConfigError, h as ExportDataError, r as ExportError, t as ExportEvent, u as ExportEventListener, s as ExportEventType, i as ExportFileError, p as ExportFilter, f as ExportServiceError, q as ExportSort, l as ExportStatus, k as FieldAlignment, v as FieldMapper, j as FieldType, m as GroupValueProcessing, o as GroupingConfig, n as GroupingField, G as GroupingMode, U as UniversalExportServiceConfig, V as Validator } from '../types-XTo80Oi_.js';
1
+ import { E as ExportConfig, a as ExportRequest, b as ExportResult, c as ExportProgress, d as ExportFormat, F as Formatter, e as ExportField } from '../types-DszP7SAQ.js';
2
+ export { D as DataTransformer, g as ExportConfigError, h as ExportDataError, r as ExportError, t as ExportEvent, u as ExportEventListener, s as ExportEventType, i as ExportFileError, p as ExportFilter, f as ExportServiceError, q as ExportSort, l as ExportStatus, k as FieldAlignment, v as FieldMapper, j as FieldType, m as GroupValueProcessing, o as GroupingConfig, n as GroupingField, G as GroupingMode, U as UniversalExportServiceConfig, V as Validator } from '../types-DszP7SAQ.js';
3
3
  import React__default from 'react';
4
4
 
5
5
  /**
@@ -41,7 +41,9 @@ declare class UniversalExportClient {
41
41
  /**
42
42
  * 触发数据导出
43
43
  */
44
- exportData(request: Omit<ExportRequest, 'callbacks'>): Promise<ExportResult>;
44
+ exportData(request: Omit<ExportRequest, 'callbacks' | 'dataSource'> & {
45
+ dataSource: any[] | string;
46
+ }): Promise<ExportResult>;
45
47
  /**
46
48
  * 查询导出进度
47
49
  */
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkGCVOKQZP_js = require('../chunk-GCVOKQZP.js');
3
+ var chunkUIYKZ73N_js = require('../chunk-UIYKZ73N.js');
4
4
  require('../chunk-DGUM43GV.js');
5
5
  var React = require('react');
6
6
  var lucideReact = require('lucide-react');
@@ -380,25 +380,38 @@ var UniversalExportClient = class {
380
380
  async exportData(request) {
381
381
  const url = `${this.config.baseUrl}${API_ENDPOINTS.EXPORT_DATA}`;
382
382
  try {
383
+ const isDataArray = Array.isArray(request.dataSource);
384
+ const requestBody = {
385
+ configId: request.configId,
386
+ queryParams: request.queryParams,
387
+ fieldMapping: request.fieldMapping,
388
+ filters: request.filters,
389
+ sortBy: request.sortBy,
390
+ pagination: request.pagination,
391
+ customFileName: request.customFileName
392
+ };
393
+ if (isDataArray) {
394
+ requestBody.data = request.dataSource;
395
+ } else {
396
+ requestBody.dataSource = request.dataSource;
397
+ }
383
398
  const response = await this.fetchWithTimeout(url, {
384
399
  method: "POST",
385
400
  headers: {
386
401
  ...this.getHeaders(),
387
402
  "Content-Type": "application/json"
388
403
  },
389
- body: JSON.stringify({
390
- configId: request.configId,
391
- dataSource: typeof request.dataSource === "string" ? request.dataSource : void 0,
392
- queryParams: request.queryParams,
393
- fieldMapping: request.fieldMapping,
394
- filters: request.filters,
395
- sortBy: request.sortBy,
396
- pagination: request.pagination,
397
- customFileName: request.customFileName
398
- })
404
+ body: JSON.stringify(requestBody)
399
405
  });
400
406
  if (!response.ok) {
401
- throw new Error(`\u5BFC\u51FA\u5931\u8D25: ${response.statusText}`);
407
+ const errorText = await response.text();
408
+ let errorData;
409
+ try {
410
+ errorData = JSON.parse(errorText);
411
+ } catch {
412
+ errorData = { message: errorText };
413
+ }
414
+ throw new Error(errorData.message || `\u5BFC\u51FA\u5931\u8D25: ${response.statusText}`);
402
415
  }
403
416
  const data = await response.json();
404
417
  return this.transformExportResultFromAPI(data.result);
@@ -947,51 +960,82 @@ var UniversalExportButton = ({
947
960
  setIsExporting(true);
948
961
  setExportProgress(null);
949
962
  try {
963
+ console.log("\u{1F4CA} [UniversalExportButton] \u83B7\u53D6\u6570\u636E...");
964
+ const data = await dataSource();
965
+ console.log("\u2705 [UniversalExportButton] \u6570\u636E\u83B7\u53D6\u6210\u529F:", {
966
+ dataType: typeof data,
967
+ isArray: Array.isArray(data),
968
+ length: Array.isArray(data) ? data.length : "N/A"
969
+ });
950
970
  const request = {
951
971
  configId: config,
952
- dataSource,
953
- callbacks: {
954
- onProgress: (progress) => {
955
- console.log("\u{1F4CA} [UniversalExportButton] \u5BFC\u51FA\u8FDB\u5EA6:", progress);
956
- setExportProgress(progress);
957
- },
958
- onSuccess: (result) => {
959
- console.log("\u2705 [UniversalExportButton] \u5BFC\u51FA\u6210\u529F:", {
960
- fileName: result.fileName,
961
- fileSize: result.fileSize,
962
- exportedRows: result.exportedRows
963
- });
964
- setIsExporting(false);
965
- setExportProgress(null);
966
- if (result.fileBlob) {
967
- console.log("\u{1F4E5} [UniversalExportButton] \u5F00\u59CB\u4E0B\u8F7D\u6587\u4EF6...");
968
- const url = window.URL.createObjectURL(result.fileBlob);
969
- const link = document.createElement("a");
970
- link.href = url;
971
- link.download = result.fileName;
972
- document.body.appendChild(link);
973
- link.click();
974
- document.body.removeChild(link);
975
- window.URL.revokeObjectURL(url);
976
- console.log("\u2705 [UniversalExportButton] \u6587\u4EF6\u4E0B\u8F7D\u5B8C\u6210");
977
- }
978
- onExportSuccess?.(result);
979
- },
980
- onError: (error) => {
981
- console.error("\u274C [UniversalExportButton] \u5BFC\u51FA\u5931\u8D25:", error);
982
- setIsExporting(false);
983
- setExportProgress(null);
984
- onExportError?.(error.message);
985
- }
986
- }
972
+ dataSource: data,
973
+ // 传递实际数据而不是函数
974
+ queryParams: void 0,
975
+ fieldMapping: void 0,
976
+ filters: void 0,
977
+ sortBy: void 0,
978
+ pagination: void 0,
979
+ customFileName: void 0
987
980
  };
988
981
  console.log("\u{1F4DE} [UniversalExportButton] \u8C03\u7528\u5BFC\u51FA\u670D\u52A1...");
989
- await exportService.exportData(request);
982
+ const result = await exportService.exportData(request);
983
+ console.log("\u2705 [UniversalExportButton] \u5BFC\u51FA\u6210\u529F:", {
984
+ fileName: result.fileName,
985
+ fileSize: result.fileSize,
986
+ exportedRows: result.exportedRows
987
+ });
988
+ const progress = {
989
+ exportId: result.exportId,
990
+ status: "completed",
991
+ progress: 100,
992
+ processedRows: result.exportedRows,
993
+ totalRows: result.exportedRows,
994
+ startTime: result.startTime,
995
+ estimatedEndTime: result.endTime
996
+ };
997
+ setExportProgress(progress);
998
+ if (result.fileUrl) {
999
+ console.log("\u{1F4E5} [UniversalExportButton] \u4ECEURL\u4E0B\u8F7D\u6587\u4EF6...");
1000
+ const link = document.createElement("a");
1001
+ link.href = result.fileUrl;
1002
+ link.download = result.fileName;
1003
+ document.body.appendChild(link);
1004
+ link.click();
1005
+ document.body.removeChild(link);
1006
+ console.log("\u2705 [UniversalExportButton] \u6587\u4EF6\u4E0B\u8F7D\u5B8C\u6210");
1007
+ } else if (result.fileBlob) {
1008
+ console.log("\u{1F4E5} [UniversalExportButton] \u4ECEBlob\u4E0B\u8F7D\u6587\u4EF6...");
1009
+ const url = window.URL.createObjectURL(result.fileBlob);
1010
+ const link = document.createElement("a");
1011
+ link.href = url;
1012
+ link.download = result.fileName;
1013
+ document.body.appendChild(link);
1014
+ link.click();
1015
+ document.body.removeChild(link);
1016
+ window.URL.revokeObjectURL(url);
1017
+ console.log("\u2705 [UniversalExportButton] \u6587\u4EF6\u4E0B\u8F7D\u5B8C\u6210");
1018
+ }
1019
+ setTimeout(() => {
1020
+ setIsExporting(false);
1021
+ setExportProgress(null);
1022
+ }, 1e3);
1023
+ onExportSuccess?.(result);
990
1024
  } catch (error) {
991
1025
  console.error("\u274C [UniversalExportButton] \u5BFC\u51FA\u5F02\u5E38:", error);
992
1026
  setIsExporting(false);
993
1027
  setExportProgress(null);
994
- onExportError?.(error instanceof Error ? error.message : "\u5BFC\u51FA\u5931\u8D25");
1028
+ let errorMessage = "\u5BFC\u51FA\u5931\u8D25";
1029
+ if (error && typeof error === "object") {
1030
+ if ("message" in error && typeof error.message === "string") {
1031
+ errorMessage = error.message;
1032
+ } else if ("code" in error && "message" in error) {
1033
+ errorMessage = `${error.code}: ${error.message}`;
1034
+ }
1035
+ } else if (typeof error === "string") {
1036
+ errorMessage = error;
1037
+ }
1038
+ onExportError?.(errorMessage);
995
1039
  }
996
1040
  }, [exportService, dataSource, onExportSuccess, onExportError]);
997
1041
  const handleQuickExport = React.useCallback(async () => {
@@ -1118,19 +1162,19 @@ var UniversalExportButton = ({
1118
1162
 
1119
1163
  Object.defineProperty(exports, "ExportConfigError", {
1120
1164
  enumerable: true,
1121
- get: function () { return chunkGCVOKQZP_js.ExportConfigError; }
1165
+ get: function () { return chunkUIYKZ73N_js.ExportConfigError; }
1122
1166
  });
1123
1167
  Object.defineProperty(exports, "ExportDataError", {
1124
1168
  enumerable: true,
1125
- get: function () { return chunkGCVOKQZP_js.ExportDataError; }
1169
+ get: function () { return chunkUIYKZ73N_js.ExportDataError; }
1126
1170
  });
1127
1171
  Object.defineProperty(exports, "ExportFileError", {
1128
1172
  enumerable: true,
1129
- get: function () { return chunkGCVOKQZP_js.ExportFileError; }
1173
+ get: function () { return chunkUIYKZ73N_js.ExportFileError; }
1130
1174
  });
1131
1175
  Object.defineProperty(exports, "ExportServiceError", {
1132
1176
  enumerable: true,
1133
- get: function () { return chunkGCVOKQZP_js.ExportServiceError; }
1177
+ get: function () { return chunkUIYKZ73N_js.ExportServiceError; }
1134
1178
  });
1135
1179
  exports.API_BASE_PATH = API_BASE_PATH;
1136
1180
  exports.API_ENDPOINTS = API_ENDPOINTS;