/** * Import/Export module for Momentum CMS. * * Provides JSON and CSV export/import for collection documents. * - Export: Fetches all documents and serializes to JSON or CSV * - Import: Parses JSON or CSV data and creates documents via batch operations * * No external dependencies - uses built-in CSV serialization. */ import type { CollectionConfig } from '@momentumcms/core'; export type ExportFormat = 'json' | 'csv'; export interface ExportOptions { /** Export format (default: 'json') */ format?: ExportFormat; /** Max documents to export (default: unlimited) */ limit?: number; } export interface ExportResult { /** Format of the exported data */ format: ExportFormat; /** Number of documents exported */ totalDocs: number; /** For JSON format: the array of documents */ docs?: Record[]; /** For CSV format: the CSV string */ data?: string; /** Content-Type header value */ contentType: string; } export interface ImportOptions { /** Import format (default: 'json') */ format?: ExportFormat; } export interface ImportResult { /** Number of successfully imported documents */ imported: number; /** Total items attempted */ total: number; /** Error details for failed items */ errors: ImportError[]; /** Successfully created documents */ docs: Record[]; } export interface ImportError { /** Index of the item in the import data */ index: number; /** Error message */ message: string; /** The data that failed to import */ data?: Record; } /** * Export documents from a collection as JSON. */ export declare function exportToJson(docs: Record[], _collection: CollectionConfig): ExportResult; /** * Export documents from a collection as CSV. */ export declare function exportToCsv(docs: Record[], collection: CollectionConfig): ExportResult; /** * Parse JSON import data into document records. * Accepts either an array of objects or `{ docs: [...] }`. */ export declare function parseJsonImport(body: unknown): { docs: Record[]; error?: string; }; /** * Parse CSV import data into document records. * First row is treated as header (field names). */ export declare function parseCsvImport(csvData: string, collection: CollectionConfig): { docs: Record[]; error?: string; };