AOSSIE-Org / AOSSIE-Org/IndexedDB-Import-Export

[FEATURE]: Add storeNames to ImportOptions for selective restore

Đang mở
#67 0 bình luận 0 reaction 1 người được giao Được @Atharva0506 nhận Xem trên GitHub
enhancement
Ngôn ngữ chính
YAML
Star
7
Fork
3
Merge trung bình
3 ngày 55 phút
Pull request đã merge (30 ngày)
8

Mô tả

### Feature and its Use Cases

`ExportOptions` supports `storeNames?: string[]`, so callers can export a subset of stores.
`ImportOptions` has no equivalent, exposing only `dbName`, `backupData` and `strategy`.

The result is an asymmetry in the public API: a backup can be produced selectively but not consumed
selectively. Callers who want a partial restore have to mutate `backupData.stores` themselves before
handing it to `importDB`, which means reaching into the envelope structure the library otherwise owns.

**What the feature is:** add `storeNames?: string[]` to `ImportOptions`. When present, only the named
stores are restored. When omitted, behaviour is unchanged, so this is backwards compatible.

**Who benefits**

- Any app whose database mixes durable user data with derived caches. Restoring a stale cache is
usually worse than refetching it, so "restore some stores" is the common case rather than an edge case.
- It closes the export/import symmetry gap, which also makes the two option types easier to document
together.
- Fate Protocol has 9 stores in `FatePoolsDB`, of which 3 hold user portfolio data
(`portfolioPositions`, `portfolioTransactions`, `portfolioCache`). The other 6 are RPC caches that
should be refetched from chain rather than restored from a file that may be days old.

### Additional Context

The current workaround is to filter `backupData.stores` before calling `importDB`, which works but
couples the caller to the envelope shape. A `backupVersion` 2 that changed that shape would break
such callers silently, with no type error.

Related: pairs naturally with an `onBeforeImport` hook, filed separately as #68.

### Code of Conduct

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.