mongofire 6.5.1 → 6.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/bin/mongofire.cjs +852 -0
- package/dist/bin/mongofire.cjs +851 -1
- package/dist/src/changetrack.js +1 -1
- package/dist/src/connection.js +1 -1
- package/dist/src/device.js +1 -1
- package/dist/src/index.cjs +1 -1
- package/dist/src/plugin.js +1 -1
- package/dist/src/reconcile.js +1 -0
- package/dist/src/state.js +1 -1
- package/dist/src/sync.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/types/index.d.ts +133 -6
- package/package.json +14 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
+
## [6.6.0] - 2025-03-10
|
|
2
|
+
|
|
3
|
+
### 🐛 Critical Bug Fixes
|
|
4
|
+
|
|
5
|
+
#### BUG-1 — Delta cursor `$or` overwrite (data loss on every sync after first)
|
|
6
|
+
**File:** `src/sync.js` — `_downloadCollection()` delta section
|
|
7
|
+
When `cursor.id` was set (every delta sync after the first), spreading `tsFilter`
|
|
8
|
+
and `applyCondition` into the same object silently discarded the timestamp `$or`
|
|
9
|
+
because JavaScript objects cannot have two `$or` keys. MongoDB received no
|
|
10
|
+
timestamp constraint and re-fetched the entire changetrack collection on every
|
|
11
|
+
delta sync. Fixed by using `$and: [tsCondition, applyCondition]` when both
|
|
12
|
+
conditions contain a top-level `$or`.
|
|
13
|
+
|
|
14
|
+
#### BUG-2 — Per-instance connection never wired (CRIT-3 was incomplete)
|
|
15
|
+
**Files:** `src/index.cjs`, `src/sync.js`, `src/changetrack.js`, `src/state.js`, `src/reconcile.js`
|
|
16
|
+
`MongoFire` constructor created a new `Connection` instance (`this._conn`) but
|
|
17
|
+
`sync.js`, `changetrack.js`, `state.js`, and `reconcile.js` all used the
|
|
18
|
+
module-level singleton. `this._conn.local` was never `null.collection(...)` —
|
|
19
|
+
it threw `TypeError` on every operation. Added `setConnection(conn)` to all four
|
|
20
|
+
modules; `MongoFire._doStart()` now calls each after `connectLocal()`.
|
|
21
|
+
|
|
22
|
+
#### BUG-3 — Bulk path non-idempotent on replica-set transaction retries
|
|
23
|
+
**File:** `src/changetrack.js` — `_doRecordChangeBulk()`
|
|
24
|
+
`_doRecordChangeBulk()` used `insertOne` in its `bulkWrite` array. When a
|
|
25
|
+
replica-set transaction was retried by `withTransaction()`, the same `opId` was
|
|
26
|
+
re-inserted, hitting the unique sparse index and throwing `E11000 duplicate key`.
|
|
27
|
+
Fixed by switching to `updateOne / $setOnInsert` (same pattern as the single
|
|
28
|
+
`recordChange` path) — idempotent by design.
|
|
29
|
+
|
|
30
|
+
#### BUG-4 — Bootstrap resume cursor silently lost on crash-resume
|
|
31
|
+
**Files:** `src/sync.js`, `src/state.js`
|
|
32
|
+
Bootstrap resume was saved as `setCursor(..., new Date(0))` plus a separate raw
|
|
33
|
+
`updateOne` writing a plain ObjectId string. `_normalizeCursor()` tried to parse
|
|
34
|
+
the ObjectId string as a `Date`, got `Invalid Date`, and returned `null` —
|
|
35
|
+
so resume always restarted from scratch. Fixed: `setCursor()` now accepts
|
|
36
|
+
`{ ts: null, id: ObjectId-string }`; `_normalizeCursor()` recognises 24-char hex
|
|
37
|
+
strings as ObjectId cursors and returns `{ ts: null, id }` correctly.
|
|
38
|
+
|
|
39
|
+
### 🐛 Medium Bug Fixes
|
|
40
|
+
|
|
41
|
+
#### BUG-5 — `conflictResolved` event declared but never emitted
|
|
42
|
+
**File:** `src/index.cjs`
|
|
43
|
+
TypeScript types declared `conflictResolved` in `MongoFireEvents` but
|
|
44
|
+
`retryConflict()` and `dismissConflict()` never called `this.emit(...)`. Any
|
|
45
|
+
listener registered with `mongofire.on('conflictResolved', ...)` never fired.
|
|
46
|
+
Both methods now emit `conflictResolved` with `{ opId, resolution }`.
|
|
47
|
+
|
|
48
|
+
#### BUG-6 — Module-level `_deviceId` shared across multiple instances
|
|
49
|
+
**File:** `src/device.js`
|
|
50
|
+
The module-level `_deviceId` singleton meant multiple `MongoFire` instances
|
|
51
|
+
in the same process shared the same deviceId. The download de-dup filter
|
|
52
|
+
(`op.deviceId === deviceId`) then skipped ops from sibling instances.
|
|
53
|
+
Introduced `DeviceManager` class; each `MongoFire` instance creates its own
|
|
54
|
+
via `newDeviceManager()`. Module-level singleton retained for backward compat.
|
|
55
|
+
|
|
56
|
+
### ✨ New Features
|
|
57
|
+
|
|
58
|
+
#### Interactive CLI (Inquirer.js)
|
|
59
|
+
All `mongofire` CLI commands now run in interactive prompt mode when no flags
|
|
60
|
+
are passed. Uses `inquirer` when available, falls back to `readline` so the
|
|
61
|
+
CLI always works without extra deps.
|
|
62
|
+
|
|
63
|
+
- `npx mongofire init` — Setup wizard: module system, collections, realtime, sync interval
|
|
64
|
+
- `npx mongofire clean` — Interactive days selector with confirmation prompt
|
|
65
|
+
- `npx mongofire conflicts` *(new)* — View, retry, or dismiss unresolved conflicts interactively
|
|
66
|
+
- `npx mongofire reconcile` *(new)* — Run recovery scan and view per-collection results
|
|
67
|
+
|
|
1
68
|
# Changelog
|
|
2
69
|
|
|
3
70
|
All notable changes to MongoFire are documented here.
|