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

[FEATURE]: Add an onBeforeImport hook to importDB

Abierto
#68 0 comentarios 0 reacciones 1 asignado Reclamado por @rohans02 Ver en GitHub
enhancement
Lenguaje dominante
YAML
Estrellas
7
Forks
3
Merge medio
3 d 55 min
PR fusionados (30 d)
8

Descripción

### Feature and its Use Cases

There is currently no point between parsing a backup and writing it where a caller can inspect or
reject it. `importDB` takes the parsed `backupData` and proceeds. Any validation therefore has to
happen in the caller, against the raw envelope, before the call.

**What the feature is:** an optional `onBeforeImport?: (summary) => boolean | Promise` on
`ImportOptions`. Returning `false` aborts the import before anything is written.

The hook should receive a **stable summary** rather than the raw envelope, so the contract survives
envelope changes. Something along the lines of store names, per-store record counts, `backupVersion`,
`databaseName` and `exportedAt`.

**Who benefits**

- Any app where a backup is user-supplied and therefore untrusted. Importing the wrong file is
destructive under `overwrite` and merely confusing under `merge`, and today there is no
library-supported place to catch it.
- It lets callers confirm with the user before a destructive restore, which is the normal
expectation for an import flow.
- Fate Protocol would use it to verify a backup belongs to the currently connected wallet before
restoring, since portfolio records are keyed by address and restoring another wallet's data would
silently produce wrong balances and P&L.

### Additional Context

The summary shape is the real design question here, more than the hook itself. Passing the raw
`ExportFormat` would be simpler but reintroduces the coupling this is meant to remove.

Related: pairs with `storeNames` on `ImportOptions`, filed separately as #67.

### 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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.