antd-import-export 1.0.12 → 1.0.13

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.
Files changed (65) hide show
  1. package/README.md +125 -23
  2. package/README_EN.md +125 -23
  3. package/dist/components/EditableImportCell.d.cts +12 -0
  4. package/dist/components/EditableImportCell.d.ts +2 -2
  5. package/dist/components/ExportButton.d.cts +20 -0
  6. package/dist/components/ExportButton.d.ts +2 -2
  7. package/dist/components/ExportTaskModal.d.cts +7 -0
  8. package/dist/components/ImportButton.d.cts +25 -0
  9. package/dist/components/ImportButton.d.ts +6 -6
  10. package/dist/components/ImportCheckContent.d.cts +10 -0
  11. package/dist/components/ImportPreviewModal.d.cts +19 -0
  12. package/dist/components/ImportPreviewModal.d.ts +2 -2
  13. package/dist/components/importBatchResult.d.cts +7 -0
  14. package/dist/components/importBatchResult.d.ts +4 -6
  15. package/dist/components/importPreviewStatus.d.cts +20 -0
  16. package/dist/components/importPreviewStatus.d.ts +2 -2
  17. package/dist/core/dateTime.d.cts +56 -0
  18. package/dist/core/dateTime.d.ts +56 -0
  19. package/dist/core/excel/exportFile.d.cts +14 -0
  20. package/dist/core/excel/exportFile.d.ts +1 -1
  21. package/dist/core/excel/importEditor.d.cts +7 -0
  22. package/dist/core/excel/importEditor.d.ts +2 -2
  23. package/dist/core/excel/importRow.d.cts +28 -0
  24. package/dist/core/excel/importRow.d.ts +13 -10
  25. package/dist/core/excel/parseSheet.d.cts +31 -0
  26. package/dist/core/excel/parseSheet.d.ts +18 -5
  27. package/dist/core/excel/runtime.d.cts +18 -0
  28. package/dist/core/excel/runtime.d.ts +8 -3
  29. package/dist/core/excel/worksheet.d.cts +8 -0
  30. package/dist/core/excel/worksheet.d.ts +2 -7
  31. package/dist/core/httpError.d.cts +34 -0
  32. package/dist/core/limits.d.cts +2 -0
  33. package/dist/core/schema/defaultValue.d.cts +17 -0
  34. package/dist/core/schema/defaultValue.d.ts +17 -0
  35. package/dist/core/schema/index.d.cts +91 -0
  36. package/dist/core/schema/index.d.ts +4 -1
  37. package/dist/core/schema/multiValue.d.cts +4 -0
  38. package/dist/core/schema/optionMap.d.cts +10 -0
  39. package/dist/core/schema/optionMap.d.ts +10 -0
  40. package/dist/core/schema/validate.d.cts +21 -0
  41. package/dist/core/schema/validate.d.ts +2 -2
  42. package/dist/core/task/exportRunner.d.cts +4 -0
  43. package/dist/core/task/exportRunner.d.ts +1 -1
  44. package/dist/core/task/importRunner.d.cts +21 -0
  45. package/dist/core/task/importRunner.d.ts +4 -4
  46. package/dist/core/task/index.d.cts +12 -0
  47. package/dist/core/task/index.d.ts +6 -6
  48. package/dist/core/task/stats.d.cts +16 -0
  49. package/dist/core/task/stats.d.ts +3 -3
  50. package/dist/core/task/store.d.cts +17 -0
  51. package/dist/core/task/store.d.ts +1 -1
  52. package/dist/core/task/types.d.cts +106 -0
  53. package/dist/core/task/types.d.ts +10 -5
  54. package/dist/core/types.d.cts +16 -0
  55. package/dist/index.cjs +9 -6
  56. package/dist/index.d.cts +15 -0
  57. package/dist/index.d.ts +15 -14
  58. package/dist/index.mjs +1122 -1012
  59. package/dist/react/useActiveTask.d.cts +5 -0
  60. package/dist/react/useActiveTask.d.ts +1 -1
  61. package/dist/react/useDebouncedValue.d.cts +2 -0
  62. package/dist/react/useTaskDetail.d.cts +2 -0
  63. package/dist/react/useTaskDetail.d.ts +1 -1
  64. package/dist/react/useThrottledValue.d.cts +2 -0
  65. package/package.json +18 -8
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 选项映射方向: **key = 接口内部值(唯一), value = Excel/界面展示文案**。
3
+ * 两个方向的查找集中在这里, 避免各模块各写一套反查逻辑。
4
+ */
5
+ /** 接口内部值 -> 展示文案; 未命中返回 undefined */
6
+ export declare function optionLabelOf(optionMap: Record<string, string>, value: unknown): string | undefined;
7
+ /** 展示文案 -> 接口内部值; 文案重复时取对象属性顺序里的第一个(配置应保证文案唯一) */
8
+ export declare function optionValueOf(optionMap: Record<string, string>, label: string): string | undefined;
9
+ /** 展示文案列表(按对象属性顺序; 整数形 key 会按数值升序) */
10
+ export declare function optionLabels(optionMap: Record<string, string>): string[];
@@ -0,0 +1,21 @@
1
+ import type { BooleanFieldSchema, FieldSchema, ListFieldSchema, MultipleChoiceFieldSchema, NumberFieldSchema, SingleChoiceFieldSchema, TextFieldSchema } from "./index.cjs";
2
+ interface ValidateSuccess {
3
+ validateSuccess: true;
4
+ validateValue: unknown;
5
+ }
6
+ interface ValidateFail {
7
+ validateSuccess: false;
8
+ validateMessage: string;
9
+ }
10
+ export type ValidateResult = ValidateSuccess | ValidateFail;
11
+ export declare function validateTextField(value: string, fieldSchema: TextFieldSchema): ValidateResult;
12
+ export declare function validateNumberField(value: string, fieldSchema: NumberFieldSchema): ValidateResult;
13
+ export declare function validateBooleanField(value: string, fieldSchema: BooleanFieldSchema): ValidateResult;
14
+ export declare function validateDateField(value: string): ValidateResult;
15
+ export declare function validateTimeField(value: string): ValidateResult;
16
+ export declare function validateDateTimeField(value: string): ValidateResult;
17
+ export declare function validateListField(value: string, fieldSchema: ListFieldSchema): ValidateResult;
18
+ export declare function validateSingleChoiceField(value: string, fieldSchema: SingleChoiceFieldSchema): ValidateResult;
19
+ export declare function validateMultipleChoiceField(value: string, fieldSchema: MultipleChoiceFieldSchema): ValidateResult;
20
+ export declare function validateField(value: string | null, fieldSchema: FieldSchema): ValidateResult;
21
+ export {};
@@ -1,4 +1,4 @@
1
- import type { BooleanFieldSchema, FieldSchema, ListFieldSchema, MultipleChoiceFieldSchema, NumberFieldSchema, SingleChoiceFieldSchema, TextFieldSchema } from "./index";
1
+ import type { BooleanFieldSchema, FieldSchema, ListFieldSchema, MultipleChoiceFieldSchema, NumberFieldSchema, SingleChoiceFieldSchema, TextFieldSchema } from "./index.js";
2
2
  interface ValidateSuccess {
3
3
  validateSuccess: true;
4
4
  validateValue: unknown;
@@ -7,7 +7,7 @@ interface ValidateFail {
7
7
  validateSuccess: false;
8
8
  validateMessage: string;
9
9
  }
10
- type ValidateResult = ValidateSuccess | ValidateFail;
10
+ export type ValidateResult = ValidateSuccess | ValidateFail;
11
11
  export declare function validateTextField(value: string, fieldSchema: TextFieldSchema): ValidateResult;
12
12
  export declare function validateNumberField(value: string, fieldSchema: NumberFieldSchema): ValidateResult;
13
13
  export declare function validateBooleanField(value: string, fieldSchema: BooleanFieldSchema): ValidateResult;
@@ -0,0 +1,4 @@
1
+ import type { ExportTaskOptions } from "./types.cjs";
2
+ export declare function enqueueExport(options: ExportTaskOptions): string;
3
+ /** 重复下载已完成的导出文件 */
4
+ export declare function downloadTask(taskId: string): boolean;
@@ -1,4 +1,4 @@
1
- import type { ExportTaskOptions } from "./types";
1
+ import type { ExportTaskOptions } from "./types.js";
2
2
  export declare function enqueueExport(options: ExportTaskOptions): string;
3
3
  /** 重复下载已完成的导出文件 */
4
4
  export declare function downloadTask(taskId: string): boolean;
@@ -0,0 +1,21 @@
1
+ import type { ImportRow } from "../excel/importRow.cjs";
2
+ import type { ImportTaskOptions } from "./types.cjs";
3
+ export declare function clearImportFlush(taskId: string): void;
4
+ /** 清空合批队列与定时器; 退出登录、清空任务时调用 */
5
+ export declare function clearImportFlushTimer(): void;
6
+ /** 新增并立即执行导入任务; 任务内部按配置的并发数逐行执行 */
7
+ export declare function enqueueImport(options: ImportTaskOptions): string;
8
+ /**
9
+ * 继续导入: 从头扫一遍, 只执行非已完成行, 让暂停/失败后编辑过的行重新提交.
10
+ */
11
+ export declare function continueTask(taskId: string): void;
12
+ /** 暂停导入: 停止取新批次, 等在途批次返回后进入 paused; 不 abort 已发出的请求 */
13
+ export declare function pauseTask(taskId: string): void;
14
+ /** 暂停时保存待导入行的编辑结果, 继续任务时使用新数据 */
15
+ export declare function updateImportRowData(taskId: string, rowIndex: number, row: ImportRow): void;
16
+ /** 校验失败行仍留在任务里, 只标记跳过并保存校验错误; 修复后取消标记即可, 不移动数组 */
17
+ export declare function setImportRowValidation(taskId: string, rowIndex: number, validationErrors: Record<string, string>): void;
18
+ /** 暂停时删除待导入/失败行: 从后续调度中跳过; 已完成/进行中的行不允许删除 */
19
+ export declare function deleteImportRows(taskId: string, rowIndexes: number[]): void;
20
+ /** 编辑失败行某个字段后, 清掉该字段上一次的后端错误 */
21
+ export declare function clearImportRowFieldError(taskId: string, rowIndex: number, field: string): void;
@@ -1,5 +1,5 @@
1
- import type { ImportRow } from "../excel/importRow";
2
- import type { ImportTaskOptions } from "./types";
1
+ import type { ImportRow } from "../excel/importRow.js";
2
+ import type { ImportTaskOptions } from "./types.js";
3
3
  export declare function clearImportFlush(taskId: string): void;
4
4
  /** 清空合批队列与定时器; 退出登录、清空任务时调用 */
5
5
  export declare function clearImportFlushTimer(): void;
@@ -9,13 +9,13 @@ export declare function enqueueImport(options: ImportTaskOptions): string;
9
9
  * 继续导入: 从头扫一遍, 只执行非已完成行, 让暂停/失败后编辑过的行重新提交.
10
10
  */
11
11
  export declare function continueTask(taskId: string): void;
12
- /** 暂停导入: 当前请求/当前行结束后停下, 不 abort 已发出的导入写请求 */
12
+ /** 暂停导入: 停止取新批次, 等在途批次返回后进入 paused; 不 abort 已发出的请求 */
13
13
  export declare function pauseTask(taskId: string): void;
14
14
  /** 暂停时保存待导入行的编辑结果, 继续任务时使用新数据 */
15
15
  export declare function updateImportRowData(taskId: string, rowIndex: number, row: ImportRow): void;
16
16
  /** 校验失败行仍留在任务里, 只标记跳过并保存校验错误; 修复后取消标记即可, 不移动数组 */
17
17
  export declare function setImportRowValidation(taskId: string, rowIndex: number, validationErrors: Record<string, string>): void;
18
- /** 暂停时删除尚未导入的行: 从后续调度中跳过, 已完成/失败/进行中的行不允许删除 */
18
+ /** 暂停时删除待导入/失败行: 从后续调度中跳过; 已完成/进行中的行不允许删除 */
19
19
  export declare function deleteImportRows(taskId: string, rowIndexes: number[]): void;
20
20
  /** 编辑失败行某个字段后, 清掉该字段上一次的后端错误 */
21
21
  export declare function clearImportRowFieldError(taskId: string, rowIndex: number, field: string): void;
@@ -0,0 +1,12 @@
1
+ export type { ExportTaskOptions, ImportRowStatus, ImportTaskOptions, TaskItem, TaskStatus } from "./types.cjs";
2
+ export { ImportPauseError } from "./types.cjs";
3
+ export { getTasksSnapshot, subscribeTasks } from "./store.cjs";
4
+ export { downloadTask, enqueueExport } from "./exportRunner.cjs";
5
+ export { clearImportRowFieldError, continueTask, deleteImportRows, enqueueImport, pauseTask, setImportRowValidation, updateImportRowData, } from "./importRunner.cjs";
6
+ export { formatTaskPercent, formatTaskRemainingSeconds, getTaskDisplayPercent, getTaskRemainingSeconds, getTaskSuccessCount, } from "./stats.cjs";
7
+ /** 取消: 停止任务但保留任务和预览, 由用户关闭/清除 */
8
+ export declare function cancelTask(taskId: string): void;
9
+ /** 移除任务; 执行中的任务先中断, 完成任务的 Blob 也会随引用释放 */
10
+ export declare function dismissTask(taskId: string): void;
11
+ /** 退出登录/切换账号时清空当前用户的任务, 同时中断所有在途请求 */
12
+ export declare function resetTasks(): void;
@@ -1,9 +1,9 @@
1
- export type { ExportTaskOptions, ImportRowStatus, ImportTaskOptions, TaskItem, TaskStatus } from "./types";
2
- export { ImportPauseError } from "./types";
3
- export { getTasksSnapshot, subscribeTasks } from "./store";
4
- export { downloadTask, enqueueExport } from "./exportRunner";
5
- export { clearImportRowFieldError, continueTask, deleteImportRows, enqueueImport, pauseTask, setImportRowValidation, updateImportRowData, } from "./importRunner";
6
- export { formatTaskPercent, formatTaskRemainingSeconds, getTaskDisplayPercent, getTaskRemainingSeconds, getTaskSuccessCount, } from "./stats";
1
+ export type { ExportTaskOptions, ImportRowStatus, ImportTaskOptions, TaskItem, TaskStatus } from "./types.js";
2
+ export { ImportPauseError } from "./types.js";
3
+ export { getTasksSnapshot, subscribeTasks } from "./store.js";
4
+ export { downloadTask, enqueueExport } from "./exportRunner.js";
5
+ export { clearImportRowFieldError, continueTask, deleteImportRows, enqueueImport, pauseTask, setImportRowValidation, updateImportRowData, } from "./importRunner.js";
6
+ export { formatTaskPercent, formatTaskRemainingSeconds, getTaskDisplayPercent, getTaskRemainingSeconds, getTaskSuccessCount, } from "./stats.js";
7
7
  /** 取消: 停止任务但保留任务和预览, 由用户关闭/清除 */
8
8
  export declare function cancelTask(taskId: string): void;
9
9
  /** 移除任务; 执行中的任务先中断, 完成任务的 Blob 也会随引用释放 */
@@ -0,0 +1,16 @@
1
+ import type { TaskItem, TaskSample } from "./types.cjs";
2
+ /** 采样只保留最近 15 秒内的点且最多 20 个: 用近期速度估算剩余时间, 不被任务开始阶段的慢速拖住 */
3
+ export declare function appendSample(previousSamples: TaskSample[], processed: number): TaskSample[];
4
+ /**
5
+ * 剩余时间估算: 采样只保留最近 15 秒内的点且最多 20 个, 取首尾两点算近期速度, 再按剩余行数外推.
6
+ * 任务刚起步、采样不足或速度算不出来时返回 null, 调用方显示"计算中".
7
+ */
8
+ export declare function getTaskRemainingSeconds(task: TaskItem): number | null;
9
+ /** 导入任务的完成数只看成功导入的行; 失败/跳过/校验失败都不算完成 */
10
+ export declare function getTaskSuccessCount(task: TaskItem): number;
11
+ /** 显示用百分比: 未完成时直接截断, 不四舍五入成 100% */
12
+ export declare function getTaskDisplayPercent(task: TaskItem): number;
13
+ /** 百分比展示固定一位小数; 传入值已经截断, 这里不会再发生进位 */
14
+ export declare function formatTaskPercent(percent: number): string;
15
+ /** 剩余时间转中文文案; null 表示采样点还不够, 算不出速度 */
16
+ export declare function formatTaskRemainingSeconds(remainingSeconds: number | null): string;
@@ -1,8 +1,8 @@
1
- import type { TaskItem, TaskSample } from "./types";
2
- /** 采样只保留最近 15 秒(最多 20 个点): 用近期速度估算剩余时间, 不被任务开始阶段的慢速拖住 */
1
+ import type { TaskItem, TaskSample } from "./types.js";
2
+ /** 采样只保留最近 15 秒内的点且最多 20 个: 用近期速度估算剩余时间, 不被任务开始阶段的慢速拖住 */
3
3
  export declare function appendSample(previousSamples: TaskSample[], processed: number): TaskSample[];
4
4
  /**
5
- * 剩余时间估算: 采样只覆盖最近 15 秒, 取首尾两点算近期速度, 再按剩余行数外推.
5
+ * 剩余时间估算: 采样只保留最近 15 秒内的点且最多 20 个, 取首尾两点算近期速度, 再按剩余行数外推.
6
6
  * 任务刚起步、采样不足或速度算不出来时返回 null, 调用方显示"计算中".
7
7
  */
8
8
  export declare function getTaskRemainingSeconds(task: TaskItem): number | null;
@@ -0,0 +1,17 @@
1
+ import type { ExportRuntime, ImportRuntime, TaskItem } from "./types.cjs";
2
+ export declare const exportRuntimes: Map<string, ExportRuntime>;
3
+ export declare const importRuntimes: Map<string, ImportRuntime>;
4
+ export declare const controllers: Map<string, AbortController>;
5
+ /** 供框架层订阅任务变化; store 本身不依赖 React */
6
+ export declare function subscribeTasks(listener: () => void): () => void;
7
+ /** 供框架层读取当前任务快照; 没有变化时返回同一引用 */
8
+ export declare function getTasksSnapshot(): TaskItem[];
9
+ export declare function makeTaskId(): string;
10
+ export declare function findTask(taskId: string): TaskItem | undefined;
11
+ export declare function updateTask(taskId: string, patch: Partial<TaskItem>): void;
12
+ /** 新增任务并通知订阅者 */
13
+ export declare function addTask(task: TaskItem): void;
14
+ /** 移除任务并通知订阅者 */
15
+ export declare function removeTask(taskId: string): void;
16
+ /** 清空所有任务与在途请求 */
17
+ export declare function resetStore(): void;
@@ -1,4 +1,4 @@
1
- import type { ExportRuntime, ImportRuntime, TaskItem } from "./types";
1
+ import type { ExportRuntime, ImportRuntime, TaskItem } from "./types.js";
2
2
  export declare const exportRuntimes: Map<string, ExportRuntime>;
3
3
  export declare const importRuntimes: Map<string, ImportRuntime>;
4
4
  export declare const controllers: Map<string, AbortController>;
@@ -0,0 +1,106 @@
1
+ import type { ImportRow } from "../excel/importRow.cjs";
2
+ import type { FieldSchema } from "../schema/index.cjs";
3
+ import type { ImportRowFieldError, ImportRowResult, PagedData } from "../types.cjs";
4
+ export type TaskStatus = "running" | "paused" | "completed" | "failed" | "canceled";
5
+ type TaskType = "export" | "import";
6
+ export interface TaskSample {
7
+ time: number;
8
+ processed: number;
9
+ }
10
+ export type ImportRowStatus = "queued" | "running" | "completed" | "failed" | "canceled" | "deleted";
11
+ export interface ImportRowState {
12
+ status: ImportRowStatus;
13
+ message?: string;
14
+ fieldErrors?: ImportRowFieldError[];
15
+ validationErrors?: Record<string, string>;
16
+ }
17
+ interface ImportFailure {
18
+ index: number;
19
+ rowNumber: number;
20
+ message: string;
21
+ fieldErrors?: ImportRowFieldError[];
22
+ }
23
+ export type ImportPauseReason = "batch-exception" | "failures" | "validation" | "user-pause";
24
+ export interface TaskItem {
25
+ id: string;
26
+ type: TaskType;
27
+ title: string;
28
+ status: TaskStatus;
29
+ pausing?: boolean;
30
+ total: number;
31
+ processed: number;
32
+ errorMessage?: string;
33
+ /** 导入任务暂停原因; UI 用结构化原因判断, 不依赖 errorMessage 文案 */
34
+ pauseReason?: ImportPauseReason;
35
+ fileName?: string;
36
+ blob?: Blob;
37
+ failures?: ImportFailure[];
38
+ rowStates?: ImportRowState[];
39
+ /** 导入成功行数; 导出任务不使用 */
40
+ successCount?: number;
41
+ /** 导入失败行数; 导出任务不使用 */
42
+ failureCount?: number;
43
+ /** 导入中因前端校验待修复的行数 */
44
+ validationFailedCount?: number;
45
+ /** 导出任务正在生成文件/触发下载 */
46
+ finalizing?: boolean;
47
+ /** 导入任务正在取消, 在途行结束前保持该状态 */
48
+ canceling?: boolean;
49
+ samples: TaskSample[];
50
+ }
51
+ export interface TaskState {
52
+ tasks: TaskItem[];
53
+ }
54
+ export interface ExportTaskOptions {
55
+ title: string;
56
+ fileName: string;
57
+ fieldSchemas: FieldSchema[];
58
+ exportRows: (params: Record<string, unknown>) => Promise<PagedData<object>>;
59
+ /** 任务结束(成功/失败/取消)时回调一次, 用于埋点或清理 */
60
+ onFinished?: () => void;
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[]) => Promise<ImportRowResult[]>;
74
+ /** 每批行数; 批越小请求返回越快, 默认 20 */
75
+ batchSize?: number;
76
+ onFinished?: () => void;
77
+ }
78
+ export interface ExportRuntime {
79
+ options: ExportTaskOptions;
80
+ cursorId?: number;
81
+ rows: object[];
82
+ total: number;
83
+ cancelRequested: boolean;
84
+ controller: AbortController | null;
85
+ }
86
+ export interface ImportRuntime {
87
+ options: ImportTaskOptions;
88
+ /** 每轮执行递增; 旧 run 的 finally 用它区分自己和新一轮 run 的资源 */
89
+ runId: number;
90
+ nextIndex: number;
91
+ processed: number;
92
+ successCount: number;
93
+ failures: ImportFailure[];
94
+ rowStates: ImportRowState[];
95
+ validationFailedCount: number;
96
+ pauseRequested: boolean;
97
+ cancelRequested: boolean;
98
+ deletedIndexes: Set<number>;
99
+ skippedIndexes: Set<number>;
100
+ /** 本轮执行累计的失败行数, 超过阈值触发暂停 */
101
+ runFailureCount: number;
102
+ /** 最近一次批次异常的原因(网络/超时等), 用于任务级暂停提示 */
103
+ lastBatchErrorMessage?: string;
104
+ controller: AbortController | null;
105
+ }
106
+ export {};
@@ -1,6 +1,6 @@
1
- import type { ImportRow } from "../excel/importRow";
2
- import type { FieldSchema } from "../schema";
3
- import type { ImportRowFieldError, ImportRowResult, PagedData } from "../types";
1
+ import type { ImportRow } from "../excel/importRow.js";
2
+ import type { FieldSchema } from "../schema/index.js";
3
+ import type { ImportRowFieldError, ImportRowResult, PagedData } from "../types.js";
4
4
  export type TaskStatus = "running" | "paused" | "completed" | "failed" | "canceled";
5
5
  type TaskType = "export" | "import";
6
6
  export interface TaskSample {
@@ -20,6 +20,7 @@ interface ImportFailure {
20
20
  message: string;
21
21
  fieldErrors?: ImportRowFieldError[];
22
22
  }
23
+ export type ImportPauseReason = "batch-exception" | "failures" | "validation" | "user-pause";
23
24
  export interface TaskItem {
24
25
  id: string;
25
26
  type: TaskType;
@@ -29,6 +30,8 @@ export interface TaskItem {
29
30
  total: number;
30
31
  processed: number;
31
32
  errorMessage?: string;
33
+ /** 导入任务暂停原因; UI 用结构化原因判断, 不依赖 errorMessage 文案 */
34
+ pauseReason?: ImportPauseReason;
32
35
  fileName?: string;
33
36
  blob?: Blob;
34
37
  failures?: ImportFailure[];
@@ -70,8 +73,6 @@ export interface ImportTaskOptions {
70
73
  importRows: (rows: ImportRow[]) => Promise<ImportRowResult[]>;
71
74
  /** 每批行数; 批越小请求返回越快, 默认 20 */
72
75
  batchSize?: number;
73
- /** 同时执行的批次数量, 默认 3 */
74
- concurrency?: number;
75
76
  onFinished?: () => void;
76
77
  }
77
78
  export interface ExportRuntime {
@@ -84,6 +85,8 @@ export interface ExportRuntime {
84
85
  }
85
86
  export interface ImportRuntime {
86
87
  options: ImportTaskOptions;
88
+ /** 每轮执行递增; 旧 run 的 finally 用它区分自己和新一轮 run 的资源 */
89
+ runId: number;
87
90
  nextIndex: number;
88
91
  processed: number;
89
92
  successCount: number;
@@ -96,6 +99,8 @@ export interface ImportRuntime {
96
99
  skippedIndexes: Set<number>;
97
100
  /** 本轮执行累计的失败行数, 超过阈值触发暂停 */
98
101
  runFailureCount: number;
102
+ /** 最近一次批次异常的原因(网络/超时等), 用于任务级暂停提示 */
103
+ lastBatchErrorMessage?: string;
99
104
  controller: AbortController | null;
100
105
  }
101
106
  export {};
@@ -0,0 +1,16 @@
1
+ /** 分页数据: 导入导出只依赖这个最小结构, 具体请求库由使用方决定 */
2
+ export interface PagedData<Row extends object = Record<string, unknown>> {
3
+ count: number;
4
+ results: Row[];
5
+ }
6
+ export type ImportRowFieldError = Record<string, string>;
7
+ /** 批量导入接口返回的单行原始错误 body; 空对象表示成功 */
8
+ export type ImportRowErrorBody = Record<string, unknown>;
9
+ /** 单行导入结果: 成功行是空对象, 失败行带行级错误 */
10
+ export type ImportRowResult = {
11
+ success: true;
12
+ } | {
13
+ success: false;
14
+ message?: string;
15
+ fieldErrors?: ImportRowFieldError[];
16
+ };