feat: support compression when importing/exporting events (gzip/xz) - #514
Conversation
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
a20e5ba to
1161d88Compare1161d88 to
f048f9fCompareThere was a problem hiding this comment.
Pull request overview
Adds streaming gzip/xz compression support to the event import/export CLIs while preserving the existing JSONL-based workflow, improving portability and storage/transfer efficiency for large exports.
Changes:
- Introduces
src/utils/compression.tswith format parsing, detection (extension + magic bytes), and streaming (de)compression helpers. - Updates
export-eventsto optionally compress output, add CLI flags, and print end-of-run size/throughput metrics. - Updates
import-eventsto auto-detect compressed inputs and decompress on-the-fly; adds unit + integration coverage and docs.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/compression.ts | New shared compression utilities (format parsing, detection, gzip/xz streams, xz tuning). |
src/scripts/export-events.ts | Adds compression flags, streaming compression pipeline, and export metrics/usage handling. |
src/import-events.ts | Removes .jsonl-only restriction; adds compression auto-detection + decompression stream creation and updated CLI parsing/help. |
src/services/event-import-service.ts | Refactors importer to accept a readable stream (importFromReadable) and keeps file-path import as a wrapper. |
test/unit/utils/compression.spec.ts | Unit tests for compression helpers, detection, env tuning, and stream round-trips. |
test/unit/scripts/export-events.spec.ts | Unit tests for export CLI arg parsing and metrics formatting helpers. |
test/unit/import-events.spec.ts | Unit tests for import CLI arg parsing and updated error cases. |
test/unit/services/event-import-service.spec.ts | Adds coverage for importing from a readable stream. |
test/integration/features/compression/compression-roundtrip.feature | New cucumber feature for gzip/xz export+import roundtrip. |
test/integration/features/compression/compression-roundtrip.feature.ts | Step definitions to seed DB, run CLIs, and verify roundtrip restore. |
README.md | Documents compressed import support, export compression flags, and xz tuning env vars. |
package.json | Adds lzma-native dependency for xz support. |
package-lock.json | Locks lzma-native and related transitive dependencies. |
.knip.json | Ignores lzma-native dependency (used via dynamic require). |
.changeset/quick-maps-marry.md | Changeset documenting the new compression feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
cameri
commented
Apr 19, 2026
@Anshumancanrock how did you manually test this? |
Anshumancanrock
commented
Apr 19, 2026
Hi @cameri , so I tested this locally before submitting.
It looked solid on my side, happy to dig into anything specific if you want. |
…t-export-compression
11ececc to
46d1eacCompare46d1eac to
11ececcCompare
Description
This PR adds practical compression support to event import/export, without changing the existing JSONL workflow.
Related Issue
Closes#407
Motivation and Context
People already compress exported event files for storage and transfer. This change removes the manual steps around that and keeps the flow memory-safe by streaming throughout.
How Has This Been Tested?
Tested locally on Linux.
Screenshots (if appropriate):
N/A (CLI/backend changes)
Types of changes
Checklist: