web / lib/services/data-export-service
lib/services/data-export-service
Service for exporting user data as a downloadable ZIP archive.
Collects all user data (catalogs, datasets, events, media, etc.) and packages it into a ZIP file with JSON files for each collection. Events are chunked into multiple files for large datasets.
Classes
DataExportService
Service for creating user data exports.
Constructors
Constructor
new DataExportService(
payload):DataExportService
Parameters
payload
BasePayload
Returns
Methods
getExportSummary()
getExportSummary(
userId):Promise<ExportSummary>
Get a summary of data that will be exported.
Parameters
userId
number
Returns
Promise<ExportSummary>
fetchAllUserData()
fetchAllUserData(
userId):Promise<Omit<ExportData,"events">>
Fetch all user data for export (except events which are batched).
Parameters
userId
number
Returns
Promise<Omit<ExportData, "events">>
createArchive()
createArchive(
exportId,userId,baseData,summary):Promise<{ filePath: string; fileSize: number; }>
Create ZIP archive from export data.
Parameters
exportId
number
userId
number
baseData
Omit<ExportData, "events">
summary
Returns
Promise<{ filePath: string; fileSize: number; }>
executeExport()
executeExport(
exportId):Promise<ExecuteExportResult>
Execute the full export process.
Parameters
exportId
number
Returns
Promise<ExecuteExportResult>
Functions
createDataExportService()
createDataExportService(
payload):DataExportService
Create a data export service instance.
Returns a fresh instance each call. The service is stateless (all data lives in the database), so there is no benefit to caching the instance.
Parameters
payload
BasePayload