feat(export): run data dictionary PDF exports in background

This commit is contained in:
ccq authored and GitHub committed 2026-09-26 00:04:52 +08:00
1 parent 4baec21fb7
commit 705ea7464d
18 files changed
+702 -104

No files matched your search

@@ -4,7 +4,7 @@ import { isTerminalTransferProgress } from "@/lib/backend/transferProgress";
import { uuid } from "@/lib/common/utils";
import { formatQueryDuration } from "@/lib/format/duration";
export type BackgroundTaskKind = "table-export" | "database-export" | "sql-file" | "data-transfer" | "multi-db-execution" | "schema-diff" | "data-compare";
export type BackgroundTaskKind = "table-export" | "database-export" | "data-dictionary" | "sql-file" | "data-transfer" | "multi-db-execution" | "schema-diff" | "data-compare";
export type BackgroundTaskStatus = "Running" | "Writing" | "Cancelling" | "Done" | "Error" | "Cancelled";
export type DatabaseExportSource = "manual" | "scheduled";
@@ -86,6 +86,12 @@ export interface ExportTask {
compareAddedCount?: number;
compareRemovedCount?: number;
compareModifiedCount?: number;
dictionaryPhase?: "preparing" | "collecting" | "generating" | "saving";
dictionaryCompleted?: number;
dictionaryTotal?: number;
dictionaryCurrent?: string;
dictionaryWarnings?: number;
dictionaryProgressKnown?: boolean;
canCancel?: boolean;
onOpen?: () => void;
onRemove?: () => void;
@@ -422,6 +428,35 @@ export function useExportTracker() {
return task;
}
function addDataDictionaryTask(exportId: string, label: string, total: number): ExportTask {
const task = reactive<ExportTask>({
exportId,
kind: "data-dictionary",
tableName: label,
format: "pdf",
filePath: "",
rowsExported: 0,
totalRows: null,
status: "Running",
errorMessage: null,
dictionaryPhase: "preparing",
dictionaryCompleted: 0,
dictionaryTotal: total,
dictionaryProgressKnown: false,
canCancel: false,
startedAt: Date.now(),
});
taskMap.set(exportId, task);
return task;
}
function updateDataDictionaryTask(exportId: string, changes: Partial<ExportTask>): void {
const task = taskMap.get(exportId);
if (!task || task.kind !== "data-dictionary") return;
Object.assign(task, changes);
if (task.status === "Done" || task.status === "Error") finishExportTask(task);
}
function addSqlFileTask(executionId: string, fileName: string, filePath: string): ExportTask {
sqlFileFailureStates.delete(executionId);
const task = reactive<ExportTask>({
@@ -771,6 +806,8 @@ export function useExportTracker() {
hasActive,
addTask,
addDatabaseExportTask,
addDataDictionaryTask,
updateDataDictionaryTask,
addSqlFileTask,
addDataTransferTask,
addSchemaDiffTask,