antd-import-export 1.0.5 → 1.0.7
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.
- package/README.md +78 -75
- package/README_EN.md +83 -67
- package/dist/components/EditableImportCell.d.ts +12 -0
- package/dist/components/ExportButton.d.ts +12 -5
- package/dist/components/ImportButton.d.ts +11 -1
- package/dist/components/importBatchResult.d.ts +9 -0
- package/dist/components/importPreviewStatus.d.ts +20 -0
- package/dist/core/excel/exportFile.d.ts +4 -4
- package/dist/core/httpError.d.ts +15 -2
- package/dist/core/limits.d.ts +5 -1
- package/dist/core/task/exportRunner.d.ts +4 -0
- package/dist/core/task/importRunner.d.ts +21 -0
- package/dist/core/task/index.d.ts +12 -0
- package/dist/core/task/stats.d.ts +16 -0
- package/dist/core/task/store.d.ts +17 -0
- package/dist/core/task/types.d.ts +107 -0
- package/dist/index.cjs +6 -6
- package/dist/index.d.ts +4 -12
- package/dist/index.mjs +805 -771
- package/dist/react/useActiveTask.d.ts +5 -0
- package/dist/react/useTaskDetail.d.ts +1 -1
- package/package.json +1 -1
- package/dist/core/taskManager.d.ts +0 -123
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** 只订阅指定任务, 避免预览等组件被其他任务更新带着重渲染 */
|
|
2
|
-
export declare function useTaskDetail(taskId?: string): import("
|
|
2
|
+
export declare function useTaskDetail(taskId?: string): import("../core/task").TaskItem | undefined;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-import-export",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.7",
|
|
5
5
|
"description": "Schema-driven Excel import and export for Ant Design: template generation, client-side validation, batched submission, row-level error feedback and cursor-based export",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { ImportRow } from "./excel/importRow";
|
|
2
|
-
import type { FieldSchema } from "./schema";
|
|
3
|
-
import type { ImportRowFieldError, ImportRowResult, PagedData } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* 导入/导出任务执行器
|
|
6
|
-
*
|
|
7
|
-
* 任务只属于当前弹窗: 负责分批/游标执行、生成 Excel 和触发下载。
|
|
8
|
-
* 导入/导出弹窗通过 useTaskDetail 订阅指定任务, 关闭弹窗时释放任务数据。
|
|
9
|
-
*
|
|
10
|
-
* 任务只存在内存: 刷新/关闭页面即丢失, 不做刷新恢复。
|
|
11
|
-
*/
|
|
12
|
-
export type TaskStatus = "running" | "paused" | "completed" | "failed" | "canceled";
|
|
13
|
-
type TaskType = "export" | "import";
|
|
14
|
-
interface TaskSample {
|
|
15
|
-
time: number;
|
|
16
|
-
processed: number;
|
|
17
|
-
}
|
|
18
|
-
export type ImportRowStatus = "queued" | "running" | "completed" | "failed" | "canceled" | "deleted";
|
|
19
|
-
interface ImportRowState {
|
|
20
|
-
status: ImportRowStatus;
|
|
21
|
-
message?: string;
|
|
22
|
-
fieldErrors?: ImportRowFieldError[];
|
|
23
|
-
validationErrors?: Record<string, string>;
|
|
24
|
-
}
|
|
25
|
-
interface ImportFailure {
|
|
26
|
-
index: number;
|
|
27
|
-
rowNumber: number;
|
|
28
|
-
message: string;
|
|
29
|
-
fieldErrors?: ImportRowFieldError[];
|
|
30
|
-
}
|
|
31
|
-
export interface TaskItem {
|
|
32
|
-
id: string;
|
|
33
|
-
type: TaskType;
|
|
34
|
-
title: string;
|
|
35
|
-
status: TaskStatus;
|
|
36
|
-
pausing?: boolean;
|
|
37
|
-
total: number;
|
|
38
|
-
processed: number;
|
|
39
|
-
errorMessage?: string;
|
|
40
|
-
fileName?: string;
|
|
41
|
-
blob?: Blob;
|
|
42
|
-
failures?: ImportFailure[];
|
|
43
|
-
rowStates?: ImportRowState[];
|
|
44
|
-
/** 导入成功行数; 导出任务不使用 */
|
|
45
|
-
successCount?: number;
|
|
46
|
-
/** 导入失败行数; 导出任务不使用 */
|
|
47
|
-
failureCount?: number;
|
|
48
|
-
/** 导入中因前端校验待修复的行数 */
|
|
49
|
-
validationFailedCount?: number;
|
|
50
|
-
/** 导出任务正在生成文件/触发下载 */
|
|
51
|
-
finalizing?: boolean;
|
|
52
|
-
/** 导入任务正在取消, 在途行结束前保持该状态 */
|
|
53
|
-
canceling?: boolean;
|
|
54
|
-
samples: TaskSample[];
|
|
55
|
-
}
|
|
56
|
-
export interface ExportTaskOptions {
|
|
57
|
-
title: string;
|
|
58
|
-
fileName: string;
|
|
59
|
-
fieldSchemas: FieldSchema[];
|
|
60
|
-
fetchPage: (params: Record<string, unknown>, signal: AbortSignal) => Promise<PagedData<object>>;
|
|
61
|
-
}
|
|
62
|
-
/** 导入行遇到权限/系统错误时立即暂停任务, 不按普通行级失败继续执行 */
|
|
63
|
-
export declare class ImportPauseError extends Error {
|
|
64
|
-
constructor(message: string);
|
|
65
|
-
}
|
|
66
|
-
export interface ImportTaskOptions {
|
|
67
|
-
title: string;
|
|
68
|
-
/** 唯一数据源: 行值、校验错误、行号都在这里, 提交时再派生接口 payload */
|
|
69
|
-
rows: ImportRow[];
|
|
70
|
-
fieldSchemas: FieldSchema[];
|
|
71
|
-
/** 文件里实际存在的列; 更新时未包含的列表示不修改 */
|
|
72
|
-
includedKeys: string[];
|
|
73
|
-
importRows: (rows: ImportRow[], signal: AbortSignal) => Promise<ImportRowResult[]>;
|
|
74
|
-
/** 每批行数; 批越小请求返回越快, 默认 20 */
|
|
75
|
-
batchSize?: number;
|
|
76
|
-
/** 同时执行的批次数量, 默认 3 */
|
|
77
|
-
concurrency?: number;
|
|
78
|
-
onFinished?: () => void;
|
|
79
|
-
}
|
|
80
|
-
/** 供框架层订阅任务变化; store 本身不依赖 React */
|
|
81
|
-
export declare function subscribeTasks(listener: () => void): () => void;
|
|
82
|
-
/** 供框架层读取当前任务快照; 没有变化时返回同一引用 */
|
|
83
|
-
export declare function getTasksSnapshot(): TaskItem[];
|
|
84
|
-
/** 新增并立即执行导出任务 */
|
|
85
|
-
export declare function enqueueExport(options: ExportTaskOptions): string;
|
|
86
|
-
/** 新增并立即执行导入任务; 任务内部按配置的并发数逐行执行 */
|
|
87
|
-
export declare function enqueueImport(options: ImportTaskOptions): string;
|
|
88
|
-
/**
|
|
89
|
-
* 继续导入: 从头扫一遍, 只执行非已完成行, 让暂停/失败后编辑过的行重新提交.
|
|
90
|
-
*/
|
|
91
|
-
export declare function continueTask(taskId: string): void;
|
|
92
|
-
/** 暂停导入: 当前请求/当前行结束后停下, 不 abort 已发出的导入写请求 */
|
|
93
|
-
export declare function pauseTask(taskId: string): void;
|
|
94
|
-
/** 暂停时保存待导入行的编辑结果, 继续任务时使用新数据 */
|
|
95
|
-
export declare function updateImportRowData(taskId: string, rowIndex: number, row: ImportRow): void;
|
|
96
|
-
/** 校验失败行仍留在任务里, 只标记跳过并保存校验错误; 修复后取消标记即可, 不移动数组 */
|
|
97
|
-
export declare function setImportRowValidation(taskId: string, rowIndex: number, validationErrors: Record<string, string>): void;
|
|
98
|
-
/** 暂停时删除尚未导入的行: 从后续调度中跳过, 已完成/失败/进行中的行不允许删除 */
|
|
99
|
-
export declare function deleteImportRows(taskId: string, rowIndexes: number[]): void;
|
|
100
|
-
/** 编辑失败行某个字段后, 清掉该字段上一次的后端错误 */
|
|
101
|
-
export declare function clearImportRowFieldError(taskId: string, rowIndex: number, field: string): void;
|
|
102
|
-
/** 取消: 停止任务但保留任务和预览, 由用户关闭/清除 */
|
|
103
|
-
export declare function cancelTask(taskId: string): void;
|
|
104
|
-
/** 移除任务; 执行中的任务先中断, 完成任务的 Blob 也会随引用释放 */
|
|
105
|
-
export declare function dismissTask(taskId: string): void;
|
|
106
|
-
/** 重复下载已完成的导出文件 */
|
|
107
|
-
export declare function downloadTask(taskId: string): boolean;
|
|
108
|
-
/** 退出登录/切换账号时清空当前用户的任务, 同时中断所有在途请求 */
|
|
109
|
-
export declare function resetTasks(): void;
|
|
110
|
-
/**
|
|
111
|
-
* 剩余时间估算: 采样只覆盖最近 15 秒, 取首尾两点算近期速度, 再按剩余行数外推.
|
|
112
|
-
* 任务刚起步、采样不足或速度算不出来时返回 null, 调用方显示"计算中".
|
|
113
|
-
*/
|
|
114
|
-
export declare function getTaskRemainingSeconds(task: TaskItem): number | null;
|
|
115
|
-
/** 导入任务的完成数只看成功导入的行; 失败/跳过/校验失败都不算完成 */
|
|
116
|
-
export declare function getTaskSuccessCount(task: TaskItem): number;
|
|
117
|
-
/** 显示用百分比: 未完成时直接截断, 不四舍五入成 100% */
|
|
118
|
-
export declare function getTaskDisplayPercent(task: TaskItem): number;
|
|
119
|
-
/** 百分比展示固定一位小数; 传入值已经截断, 这里不会再发生进位 */
|
|
120
|
-
export declare function formatTaskPercent(percent: number): string;
|
|
121
|
-
/** 剩余时间转中文文案; null 表示采样点还不够, 算不出速度 */
|
|
122
|
-
export declare function formatTaskRemainingSeconds(remainingSeconds: number | null): string;
|
|
123
|
-
export {};
|