@docstack/pouchdb-adapter-googledrive 0.1.4 → 0.1.6

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/lib/index.d.ts CHANGED
File without changes
package/lib/index.js CHANGED
File without changes
package/lib/types.d.ts CHANGED
@@ -36,6 +36,16 @@ export interface ChangeEntry {
36
36
  doc?: Record<string, any>;
37
37
  /** Timestamp of the change */
38
38
  timestamp: number;
39
+ /**
40
+ * When set (computed by adapter.ts's `_bulkDocs` via pouchdb-merge before
41
+ * appending), fully describes the resulting IndexEntry for this doc - any
42
+ * `location`/`conflictLocations[rev]` that should point at *this* change's own
43
+ * (not-yet-uploaded) file is left as `{fileId: '__SELF__'}`;
44
+ * `DriveHandler.updateIndex()` substitutes the real fileId once known.
45
+ * Absent for the low-level `DriveHandler.appendChange()` API's raw callers
46
+ * (e.g. concurrency tests), which fall back to a synthesized single-node tree.
47
+ */
48
+ nextIndexEntry?: Omit<IndexEntry, 'seq'>;
39
49
  }
40
50
  /** Location pointer for lazy loading */
41
51
  export interface FilePointer {
@@ -49,14 +59,24 @@ export interface FilePointer {
49
59
  }
50
60
  /** In-Memory Index Entry */
51
61
  export interface IndexEntry {
52
- /** Current revision */
62
+ /** Opaque pouchdb-merge rev tree, JSON-stringified. JS (this file's callers)
63
+ * owns tree shape entirely - nothing here parses it beyond handing it to
64
+ * pouchdb-merge's own functions. */
65
+ tree: string;
66
+ /** Winning revision, computed via pouchdb-merge's winningRev() - the real
67
+ * deterministic CouchDB algorithm (generation, then lexicographic rev-hash
68
+ * tie-break), not "whichever write landed last". */
53
69
  rev: string;
54
70
  /** Sequence number where this rev was minted */
55
71
  seq: number;
56
- /** Whether it is a deletion marker */
72
+ /** Whether the winning revision is a deletion marker */
57
73
  deleted?: boolean;
58
- /** Pointer to the file containing the body (changes-*.ndjson or snapshot-data-*.json) */
74
+ /** Pointer to the file containing the winning revision's body (changes-*.ndjson
75
+ * or snapshot-data-*.json) */
59
76
  location: FilePointer;
77
+ /** Every OTHER known leaf's body location, keyed by rev string. Absent/empty
78
+ * when there's no conflict. */
79
+ conflictLocations?: Record<string, FilePointer>;
60
80
  }
61
81
  /** Old Legacy Snapshot (Compact + Data) - Kept for migration */
62
82
  export interface LegacySnapshotData {
@@ -75,8 +95,11 @@ export interface SnapshotIndex {
75
95
  }
76
96
  /** New Snapshot Data (Bulk Content) */
77
97
  export interface SnapshotDataChunk {
78
- /** Map of DocID -> Document Body */
98
+ /** Map of DocID -> Document Body (winning revision only) */
79
99
  docs: Record<string, any>;
100
+ /** Non-winning leaf bodies carried forward through compaction, DocID -> rev ->
101
+ * Document Body. Absent when nothing in this chunk has a conflict. */
102
+ conflicts?: Record<string, Record<string, any>>;
80
103
  }
81
104
  /** Metadata file content */
82
105
  export interface MetaData {
@@ -84,6 +107,13 @@ export interface MetaData {
84
107
  seq: number;
85
108
  /** List of active change log file IDs */
86
109
  changeLogIds: string[];
110
+ /** Change logs a compaction has folded into the snapshot and deleted.
111
+ * Tombstones: without them a writer that still remembers writing one of these
112
+ * would keep putting it back (see DriveHandler.reconcileOwnLogs). Capped at
113
+ * RETIRED_LOG_HISTORY entries - a writer that slept through more compactions
114
+ * than that may resurrect a dead file id, which replays as a skipped 404 and is
115
+ * pruned by the next compaction. */
116
+ retiredLogIds?: string[];
87
117
  /** Snapshot Index file ID */
88
118
  snapshotIndexId: string | null;
89
119
  /** Last compaction timestamp */
package/lib/types.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@docstack/pouchdb-adapter-googledrive",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "PouchDB adapter for Google Drive",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
9
  "test": "jest",
10
- "test:prod": "TEST_ENV=production jest"
10
+ "test:prod": "TEST_ENV=production jest",
11
+ "test:prod:explore": "TEST_ENV=production jest tests/production.explore.test.ts",
12
+ "test:prod:replication": "TEST_ENV=production jest tests/production.replication.test.ts"
11
13
  },
12
14
  "keywords": [
13
15
  "pouchdb",
@@ -28,7 +30,9 @@
28
30
  "node": ">=18"
29
31
  },
30
32
  "dependencies": {
31
- "pouchdb-core": "^7.3.1"
33
+ "pouchdb-core": "^7.3.1",
34
+ "pouchdb-merge": "^9.0.0",
35
+ "pouchdb-adapter-utils": "^9.0.0"
32
36
  },
33
37
  "devDependencies": {
34
38
  "@types/express": "^5.0.6",
package/.env.example DELETED
@@ -1,9 +0,0 @@
1
- # Google Drive API Credentials
2
- GOOGLE_CLIENT_ID=your_client_id
3
- GOOGLE_CLIENT_SECRET=your_client_secret
4
- GOOGLE_REDIRECT_URL=your_redirect_url
5
- GOOGLE_ACCESS_TOKEN=your_access_token
6
- GOOGLE_REFRESH_TOKEN=your_refresh_token
7
-
8
- # Used for testing purposes
9
- GOOGLE_ACCESS_TOKEN=your_pasted_token_here