mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-28 00:06:50 +00:00
add sql file frontend api
This commit is contained in:
@@ -303,6 +303,61 @@ export async function deleteHistoryEntry(id: string): Promise<void> {
|
||||
return invoke("delete_history_entry", { id });
|
||||
}
|
||||
|
||||
// --- SQL File Execution ---
|
||||
export type SqlFileStatus =
|
||||
| "started"
|
||||
| "running"
|
||||
| "statementDone"
|
||||
| "statementFailed"
|
||||
| "done"
|
||||
| "error"
|
||||
| "cancelled";
|
||||
|
||||
export interface SqlFileRequest {
|
||||
executionId: string;
|
||||
connectionId: string;
|
||||
database: string;
|
||||
filePath: string;
|
||||
continueOnError: boolean;
|
||||
}
|
||||
|
||||
export interface SqlFilePreview {
|
||||
fileName: string;
|
||||
filePath: string;
|
||||
sizeBytes: number;
|
||||
preview: string;
|
||||
}
|
||||
|
||||
export interface SqlFileProgress {
|
||||
executionId: string;
|
||||
status: SqlFileStatus;
|
||||
statementIndex: number;
|
||||
successCount: number;
|
||||
failureCount: number;
|
||||
affectedRows: number;
|
||||
elapsedMs: number;
|
||||
statementSummary: string;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
export async function previewSqlFile(filePath: string): Promise<SqlFilePreview> {
|
||||
return invoke("preview_sql_file", { filePath });
|
||||
}
|
||||
|
||||
export async function executeSqlFile(request: SqlFileRequest): Promise<void> {
|
||||
return invoke("execute_sql_file", { request });
|
||||
}
|
||||
|
||||
export async function cancelSqlFileExecution(executionId: string): Promise<boolean> {
|
||||
return invoke("cancel_sql_file_execution", { executionId });
|
||||
}
|
||||
|
||||
export async function listenSqlFileProgress(
|
||||
handler: (progress: SqlFileProgress) => void,
|
||||
): Promise<UnlistenFn> {
|
||||
return listen<SqlFileProgress>("sql-file-progress", (event) => handler(event.payload));
|
||||
}
|
||||
|
||||
// --- Data Transfer ---
|
||||
export interface TransferRequest {
|
||||
transferId: string;
|
||||
|
||||
@@ -18,6 +18,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
const completionColumnsCache = ref<Record<string, ColumnInfo[]>>({});
|
||||
const transferSource = ref<{ connectionId: string; database: string } | null>(null);
|
||||
const schemaDiffSource = ref<{ connectionId: string; database: string } | null>(null);
|
||||
const sqlFileSource = ref<{ connectionId: string; database: string } | null>(null);
|
||||
|
||||
function startEditing(id: string) {
|
||||
editingConnectionId.value = id;
|
||||
@@ -647,5 +648,6 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
importConnectionsFromFile,
|
||||
transferSource,
|
||||
schemaDiffSource,
|
||||
sqlFileSource,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user