refactor(desktop): organize lib modules by domain

This commit is contained in:
t8y2 committed 2026-07-04 13:53:52 +08:00
1 parent 90f0594e93
commit 7e7c4944e9
700 files changed
+1292 -1264

No files matched your search

@@ -0,0 +1,28 @@
import type { DatabaseType } from "@/types/database";
import * as api from "@/lib/backend/api";
export type ExportCellValue = string | number | boolean | null;
export function formatCsv(columns: string[], rows: ExportCellValue[][]): string {
const esc = (v: string) => `"${v.replace(/"/g, '""')}"`;
const header = columns.map(esc).join(",");
const body = rows.map((row) => row.map((c) => esc(c === null ? "NULL" : String(c))).join(",")).join("\n");
return `${header}\n${body}`;
}
export interface FormatSqlInsertOptions {
databaseType?: DatabaseType;
schema?: string;
tableName?: string;
qualifiedTableName?: string;
columns: string[];
columnTypes?: Array<string | null | undefined>;
rows: ExportCellValue[][];
}
export function formatSqlInsert(options: FormatSqlInsertOptions): Promise<string> {
return api.buildExportSqlInsert({
...options,
batchSize: 1,
});
}