Skip to content

Big datasets export#18

Open
yaroslav8765 wants to merge 5 commits into
mainfrom
big-datasets-export
Open

Big datasets export#18
yaroslav8765 wants to merge 5 commits into
mainfrom
big-datasets-export

Conversation

@yaroslav8765

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a “big dataset” CSV export mode to the import-export plugin, shifting large exports into a background job that streams CSV output to a configurable storage adapter to avoid high server RAM usage.

Changes:

  • Introduces exportBigDataset plugin options (buffer size, read chunk size, storage adapter) and wires background-jobs task registration.
  • Adds new server endpoints to start an export job and retrieve a presigned download URL.
  • Adds UI components to start background exports and to display/download finished export jobs.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
types.ts Adds exportBigDataset options and storage adapter typing.
index.ts Registers background export job handler + adds endpoints for starting exports and fetching download links; passes UI meta.
exportMultipartUpload.ts Implements streamed CSV generation + multipart upload export job runner and download URL retrieval.
custom/ExportCsv.vue Switches export action to background job when enabled; reuses previously fetched counts for progress estimates.
custom/ExportCsvJobViewComponent.vue Adds a job details UI panel with download action for completed exports.
package.json Adds csv dependency and @adminforth/background-jobs dev dependency; bumps dev adminforth.
pnpm-workspace.yaml Allows building classic-level (dependency of background jobs).
pnpm-lock.yaml Locks new dependencies and updates adminforth version.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)

types.ts:13

  • Typo in docs: “more that” → “more than” (and minor units/wording).
    /**
     * Size of the buffer, where records will be stored before upload. Min size is 5 MB. The default value is 5 MB. (takes RAM memory on the server)
     * AWS S3 doesn't support more that 10000 parts per upload, so if you have a huge database you want to export (for default settings more that 100 Gb) - increase buffer size
     */

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread types.ts
@@ -1,5 +1,24 @@
import {type PluginsCommonOptions } from "adminforth";
import {type PluginsCommonOptions, StorageAdapter } from "adminforth";
Comment thread types.ts
Comment on lines +4 to +8
/**
* If you are going to export a huge dataset - it can make your server run out of memory, because all exported records are stored in RAM
* To prevent this, you can use exportBigDataset option.
* It requires a background jobs plugin to be setted up
*/
Comment thread index.ts
Comment on lines 42 to 44
auditLogPlugin: Record<string, any> | undefined;

backgroundJobsPlugin: any;

Comment thread exportMultipartUpload.ts
Comment on lines +101 to +107
function getJobsResourceMeta(backgroundJobsPlugin: BackgroundJobsPlugin): { resourceId: string; pkColumn: string } {
const resourceConfig = backgroundJobsPlugin.resourceConfig;
return {
resourceId: resourceConfig.resourceId,
pkColumn: resourceConfig.columns.find((col) => col.primaryKey).name,
};
}
Comment thread exportMultipartUpload.ts
Comment on lines +43 to +50
// numbers and booleans are left bare, everything else is quoted:
// quoting all columns breaks BI/Excel tasks
columnsToForceQuote: columns.map((col) => (
col.type !== AdminForthDataTypes.FLOAT
&& col.type !== AdminForthDataTypes.INTEGER
&& col.type !== AdminForthDataTypes.BOOLEAN
&& col.type !== AdminForthDataTypes.DECIMAL
)),
Comment thread exportMultipartUpload.ts
Comment on lines +194 to +196
// BOM keeps Excel happy with non-ASCII values
// Add this symbol to the beginning of the file to indicate that it is UTF-8 encoded. (requred for some versions of Excel for some reason. Without this symbol encoding can be broken)
await writer.write('' + buildCsvChunk([fields], columnsToForceQuote));
Comment thread package.json
Comment on lines 27 to 34
"peerDependencies": {
"adminforth": "^3.8.2"
},
"devDependencies": {
"@adminforth/background-jobs": "^1.18.4",
"@types/node": "^22.10.7",
"adminforth": "^3.8.2",
"adminforth": "^3.12.1",
"semantic-release": "^24.2.1",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants