- Add POST /api/knowledge/import endpoint for .md and .zip files - Add GET /api/knowledge/export endpoint with markdown/json formats - Import parses frontmatter (title, tags, status, visibility) - Export includes frontmatter in markdown format - Add ImportExportActions component with drag-and-drop UI - Add import progress dialog with success/error summary - Add export dropdown with format selection - Include comprehensive test suite - Support bulk import with detailed error reporting
This commit is contained in:
52
apps/api/src/knowledge/dto/import-export.dto.ts
Normal file
52
apps/api/src/knowledge/dto/import-export.dto.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
IsEnum,
|
||||
IsArray,
|
||||
ArrayMinSize,
|
||||
} from "class-validator";
|
||||
|
||||
/**
|
||||
* Export format enum
|
||||
*/
|
||||
export enum ExportFormat {
|
||||
MARKDOWN = "markdown",
|
||||
JSON = "json",
|
||||
}
|
||||
|
||||
/**
|
||||
* DTO for export query parameters
|
||||
*/
|
||||
export class ExportQueryDto {
|
||||
@IsOptional()
|
||||
@IsEnum(ExportFormat, { message: "format must be either 'markdown' or 'json'" })
|
||||
format?: ExportFormat = ExportFormat.MARKDOWN;
|
||||
|
||||
@IsOptional()
|
||||
@IsArray({ message: "entryIds must be an array" })
|
||||
@IsString({ each: true, message: "each entryId must be a string" })
|
||||
entryIds?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Import result for a single entry
|
||||
*/
|
||||
export interface ImportResult {
|
||||
filename: string;
|
||||
success: boolean;
|
||||
entryId?: string;
|
||||
slug?: string;
|
||||
title?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response DTO for import operation
|
||||
*/
|
||||
export interface ImportResponseDto {
|
||||
success: boolean;
|
||||
totalFiles: number;
|
||||
imported: number;
|
||||
failed: number;
|
||||
results: ImportResult[];
|
||||
}
|
||||
@@ -10,3 +10,9 @@ export {
|
||||
RecentEntriesDto,
|
||||
} from "./search-query.dto";
|
||||
export { GraphQueryDto } from "./graph-query.dto";
|
||||
export {
|
||||
ExportQueryDto,
|
||||
ExportFormat,
|
||||
ImportResult,
|
||||
ImportResponseDto,
|
||||
} from "./import-export.dto";
|
||||
|
||||
Reference in New Issue
Block a user