Repository navigation
feat: add .taskora data package export and import - #235
Merged
Merged
Conversation
pnpm -r --parallel ran the api and backend pretest scripts, which rebuild engine's dist while frontend/desktop/mobile/ui tests already import it, so a test could load a half-written module (LocalReplica is not a constructor). Build shared, engine and the Prisma client once up front and run the package tests with pre/post scripts disabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the old Prisma-row JSON export with a versioned
.taskoradata package (zip) and adds a full import as copy pipeline on the hub.Previously users could export but never import: backups could not be restored, and accounts/hubs could not be migrated. The old export was also incomplete (no attachments, no calendar subscriptions) and bound to raw Prisma columns, so schema changes silently broke old files.
Data package format (format 1)
serializeRow(...).fields, no clocks), soENTITIESstays the single source of truth.formatis an integer. Imports migrate older formats step by step; newer formats are rejected withunsupported-format.taskora-export-*.jsonfiles are recognized as format 0 and migrated on import.Changes
Backend
DataPackageModule:GET /users/me/export?blobs=0|1— streams the zip viayazl; blobs are read lazily and not recompressed, so hub memory does not grow with attachment size. Missing blobs are skipped.POST /users/me/import/preview— raw-byte upload (bypasses the JSON body parser and its 4 MB limit), stored in a per-user temp dir with a 1-hour TTL; returnsuploadId, manifest summary andalreadyImportedAt.POST /users/me/import—{ uploadId, importPreferences }.buildImportPlan(pure function, no DB access): remaps every id to a new UUID, rewrites references fromREFERENCE_FIELDSplusrepeatSourceIdandproject-heading.projectId, handles dangling references with compact semantics, merges tags by title path, and appends top-level items to the end of each container usingpositionsBetween(including the feed key space).blob-mismatch. All rows are written in a singlewriteAsHubtransaction, so the operation is all-or-nothing and produces change events for devices.DataImportPrisma model + migration to detect repeated imports byexportId.HUB_VERSIONextracted intocommon/hub-version.ts, shared with the health controller.UsersService.exportDataandGET /users/me/exportJSON endpoint.Frontend / API
exportData(includeBlobs)now downloads aBlob;previewImport/importDatahooks added, with upload progress. Import invalidates all queries and re-hydrates preferences when requested.DataImportDialoghandles progress, the already-imported warning, the preferences switch, per-entity counts, skip reasons and error-code messages.enandzh.Shared
data-package.tswith the format constant, manifest/data types, error codes, skip reasons and import stats, used by both backend and UI.Tests
data-package.import-plan.spec.ts— id remapping, dangling references, orphaned children, tag path merging, position ordering, feed interleaving, missing blobs, calendar dedup, format upgrade/rejection.data-package.export.e2e-spec.ts— zip structure, wire fields, blob dedup,blobs=0, exclusion of secrets, per-user isolation.data-package.import.e2e-spec.ts— round-trip equality (including blob bytes), non-destructive import into a populated account, atomic rollback, error codes, duplicate-import notice, cross-useruploadId, legacy format 0 import, and that devices canpullimported rows.SettingsData.test.tsx— preview → import with the preferences toggle → result, duplicate notice, error text.Notes
.taskoraand<a download>saving on desktop (Tauri) and Android.CONTEXT.md("Data Package", "Import as Copy") and the feature spec/issues under.scratch/data-import/.