@bobfrankston/mailx-imap 0.1.45 → 0.1.47
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/index.d.ts +13 -4
- package/index.js +24 -8
- package/package.json +11 -11
package/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Syncs messages to local store, emits events for new mail.
|
|
5
5
|
*/
|
|
6
6
|
import type { TransportFactory } from "@bobfrankston/tcp-transport";
|
|
7
|
-
import {
|
|
7
|
+
import { FileMessageStore, Store } from "@bobfrankston/mailx-store";
|
|
8
8
|
import type { AccountConfig, MessageEnvelope, Folder } from "@bobfrankston/mailx-types";
|
|
9
9
|
import { EventEmitter } from "node:events";
|
|
10
10
|
/** Events emitted by the IMAP manager */
|
|
@@ -60,8 +60,17 @@ export declare class ImapManager extends EventEmitter {
|
|
|
60
60
|
private configs;
|
|
61
61
|
private watchers;
|
|
62
62
|
private fetchClients;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
/** The Store is the architectural nexus — owner of MailxDB +
|
|
64
|
+
* FileMessageStore + the event bus. This package (mailx-imap) is a
|
|
65
|
+
* *consumer* of the Store. `this.db` and `this.bodyStore` are getters
|
|
66
|
+
* onto Store-owned objects, kept as fields here for source-diff
|
|
67
|
+
* compatibility during the inversion (so the ~120 existing
|
|
68
|
+
* `this.db.X(...)` callsites don't all need touching at once). Future:
|
|
69
|
+
* every mutation moves to `this.store.X(...)` with bus-emit baked in;
|
|
70
|
+
* these fields shrink to read-only convenience refs. */
|
|
71
|
+
private store;
|
|
72
|
+
private get db();
|
|
73
|
+
private get bodyStore();
|
|
65
74
|
private syncIntervals;
|
|
66
75
|
/** Track which accounts have already shown an error banner — only emit once per session */
|
|
67
76
|
private accountErrorShown;
|
|
@@ -88,7 +97,7 @@ export declare class ImapManager extends EventEmitter {
|
|
|
88
97
|
/** Public read for the IPC surface: snapshot of all account diagnostics. */
|
|
89
98
|
getDiagnosticsSnapshot(): AccountDiagnostics[];
|
|
90
99
|
private transportFactory;
|
|
91
|
-
constructor(
|
|
100
|
+
constructor(store: Store, transportFactory: TransportFactory);
|
|
92
101
|
/** Get OAuth access token for an account (for SMTP auth) */
|
|
93
102
|
getOAuthToken(accountId: string): Promise<string | null>;
|
|
94
103
|
/** Accounts currently re-authenticating — all operations skip these */
|
package/index.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { createAutoImapConfig, CompatImapClient } from "@bobfrankston/iflow-direct";
|
|
7
7
|
import { authenticateOAuth } from "@bobfrankston/oauthsupport";
|
|
8
|
-
import {
|
|
9
|
-
import { loadSettings,
|
|
8
|
+
import { parseSerial, storeBus } from "@bobfrankston/mailx-store";
|
|
9
|
+
import { loadSettings, getConfigDir, getHistoryDays, getPrefetch } from "@bobfrankston/mailx-settings";
|
|
10
10
|
import { EventEmitter } from "node:events";
|
|
11
11
|
import * as fs from "node:fs";
|
|
12
12
|
import * as path from "node:path";
|
|
@@ -135,8 +135,17 @@ export class ImapManager extends EventEmitter {
|
|
|
135
135
|
configs = new Map();
|
|
136
136
|
watchers = new Map();
|
|
137
137
|
fetchClients = new Map();
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
/** The Store is the architectural nexus — owner of MailxDB +
|
|
139
|
+
* FileMessageStore + the event bus. This package (mailx-imap) is a
|
|
140
|
+
* *consumer* of the Store. `this.db` and `this.bodyStore` are getters
|
|
141
|
+
* onto Store-owned objects, kept as fields here for source-diff
|
|
142
|
+
* compatibility during the inversion (so the ~120 existing
|
|
143
|
+
* `this.db.X(...)` callsites don't all need touching at once). Future:
|
|
144
|
+
* every mutation moves to `this.store.X(...)` with bus-emit baked in;
|
|
145
|
+
* these fields shrink to read-only convenience refs. */
|
|
146
|
+
store;
|
|
147
|
+
get db() { return this.store.db; }
|
|
148
|
+
get bodyStore() { return this.store.bodyStore; }
|
|
140
149
|
syncIntervals = new Map();
|
|
141
150
|
/** Track which accounts have already shown an error banner — only emit once per session */
|
|
142
151
|
accountErrorShown = new Set();
|
|
@@ -197,12 +206,11 @@ export class ImapManager extends EventEmitter {
|
|
|
197
206
|
return Array.from(this.diagnostics.values()).map(d => ({ ...d }));
|
|
198
207
|
}
|
|
199
208
|
transportFactory;
|
|
200
|
-
constructor(
|
|
209
|
+
constructor(store, transportFactory) {
|
|
201
210
|
super();
|
|
202
|
-
this.
|
|
211
|
+
this.store = store;
|
|
203
212
|
this.transportFactory = transportFactory;
|
|
204
|
-
|
|
205
|
-
this.bodyStore = new FileMessageStore(storePath);
|
|
213
|
+
// bodyStore is now owned by Store; getter above forwards to it.
|
|
206
214
|
// Cancel pending deferred-delete when move-detect rebinds a row.
|
|
207
215
|
// Without this, the source folder's reconcile-delete grace timer
|
|
208
216
|
// would fire 30 minutes after detection for a row that's already
|
|
@@ -1205,10 +1213,18 @@ export class ImapManager extends EventEmitter {
|
|
|
1205
1213
|
// emits them only via state-change FETCH if their flags
|
|
1206
1214
|
// changed since modSeq, which is unreliable. Pull them
|
|
1207
1215
|
// explicitly via the existing incremental path.
|
|
1216
|
+
// INSTRUMENTATION (2026-05-15): phase timestamps so the
|
|
1217
|
+
// log pinpoints which operation eats wall-clock during a
|
|
1218
|
+
// slow sync. The 27 s INBOX block had a silent log hole;
|
|
1219
|
+
// these markers fill it.
|
|
1220
|
+
const __t1 = Date.now();
|
|
1208
1221
|
const fetched = await client.fetchMessagesSinceUid(folder.path, highestUid, { source: false });
|
|
1222
|
+
console.log(` [qr-phase] ${folder.path}: fetchMessagesSinceUid → ${fetched.length} msgs in ${Date.now() - __t1}ms`);
|
|
1209
1223
|
const newOnes = fetched.filter((m) => m.uid > highestUid);
|
|
1210
1224
|
if (newOnes.length > 0) {
|
|
1225
|
+
const __t2 = Date.now();
|
|
1211
1226
|
await this.storeMessages(accountId, folderId, folder, newOnes, highestUid);
|
|
1227
|
+
console.log(` [qr-phase] ${folder.path}: storeMessages(${newOnes.length}) in ${Date.now() - __t2}ms`);
|
|
1212
1228
|
}
|
|
1213
1229
|
// Persist new watermark — next resync starts here.
|
|
1214
1230
|
if (qr.newHighestModSeq !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx-imap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
},
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@bobfrankston/mailx-types": "^0.1.
|
|
13
|
-
"@bobfrankston/mailx-settings": "^0.1.
|
|
14
|
-
"@bobfrankston/mailx-store": "^0.1.
|
|
15
|
-
"@bobfrankston/iflow-direct": "^0.1.
|
|
12
|
+
"@bobfrankston/mailx-types": "^0.1.14",
|
|
13
|
+
"@bobfrankston/mailx-settings": "^0.1.17",
|
|
14
|
+
"@bobfrankston/mailx-store": "^0.1.26",
|
|
15
|
+
"@bobfrankston/iflow-direct": "^0.1.46",
|
|
16
16
|
"@bobfrankston/tcp-transport": "^0.1.6",
|
|
17
17
|
"@bobfrankston/smtp-direct": "^0.1.8",
|
|
18
|
-
"@bobfrankston/mailx-sync": "^0.1.
|
|
18
|
+
"@bobfrankston/mailx-sync": "^0.1.17",
|
|
19
19
|
"@bobfrankston/oauthsupport": "^1.0.26"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
".transformedSnapshot": {
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@bobfrankston/mailx-types": "^0.1.
|
|
41
|
-
"@bobfrankston/mailx-settings": "^0.1.
|
|
42
|
-
"@bobfrankston/mailx-store": "^0.1.
|
|
43
|
-
"@bobfrankston/iflow-direct": "^0.1.
|
|
40
|
+
"@bobfrankston/mailx-types": "^0.1.14",
|
|
41
|
+
"@bobfrankston/mailx-settings": "^0.1.17",
|
|
42
|
+
"@bobfrankston/mailx-store": "^0.1.26",
|
|
43
|
+
"@bobfrankston/iflow-direct": "^0.1.46",
|
|
44
44
|
"@bobfrankston/tcp-transport": "^0.1.6",
|
|
45
45
|
"@bobfrankston/smtp-direct": "^0.1.8",
|
|
46
|
-
"@bobfrankston/mailx-sync": "^0.1.
|
|
46
|
+
"@bobfrankston/mailx-sync": "^0.1.17",
|
|
47
47
|
"@bobfrankston/oauthsupport": "^1.0.26"
|
|
48
48
|
}
|
|
49
49
|
}
|