feat(mongodb): add Compass-style collection import/export

This commit is contained in:
onenewcode authored and GitHub committed 2026-09-12 21:59:29 +08:00
1 parent bf4874906c
commit 8ff56b4837
47 files changed
+5626 -52

No files matched your search

@@ -0,0 +1,25 @@
export type ImportFileSource = string | File;
export interface UploadedImportSource {
sourceRef: string;
filePath: string;
}
export function importSourceDisplayName(source: ImportFileSource): string {
return typeof source === "string" ? source.split(/[\\/]/).pop() || source : source.name;
}
export function importTextDelimiterForName(name: string): string {
return name.toLowerCase().endsWith(".tsv") ? "\\t" : ",";
}
/** Reuse a server-side upload on later previews instead of sending the File again. */
export function importPreviewInput(uploaded: UploadedImportSource | null | undefined, source: ImportFileSource): { fileOrPath: ImportFileSource; sourceRef: string | null } {
if (uploaded?.sourceRef) return { fileOrPath: uploaded.filePath, sourceRef: uploaded.sourceRef };
return { fileOrPath: source, sourceRef: null };
}
export function uploadedImportSourceFromPreview(preview: { sourceRef?: string | null; filePath?: string } | null | undefined): UploadedImportSource | null {
if (!preview?.sourceRef || !preview.filePath) return null;
return { sourceRef: preview.sourceRef, filePath: preview.filePath };
}