@bobfrankston/mailx 1.0.94 → 1.0.96

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.94",
3
+ "version": "1.0.96",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { ImapClient, createAutoImapConfig, CompatImapClient, NodeTransport } from "@bobfrankston/iflow";
7
7
  import { FileMessageStore } from "@bobfrankston/mailx-store";
8
- import { loadSettings, getStorePath, getConfigDir } from "@bobfrankston/mailx-settings";
8
+ import { loadSettings, getStorePath, getConfigDir, getHistoryDays } from "@bobfrankston/mailx-settings";
9
9
  import { EventEmitter } from "node:events";
10
10
  import * as fs from "node:fs";
11
11
  import * as path from "node:path";
@@ -267,8 +267,7 @@ export class ImapManager extends EventEmitter {
267
267
  }
268
268
  else {
269
269
  // First sync: use date-based fetch with bodies for local-first
270
- const settings = loadSettings();
271
- const historyDays = settings.sync.historyDays || 0;
270
+ const historyDays = getHistoryDays(accountId);
272
271
  const startDate = historyDays > 0
273
272
  ? new Date(Date.now() - historyDays * 86400000)
274
273
  : new Date(0);
@@ -123,7 +123,7 @@ ${accountInfo.map((a) => `<tr><td>${a.name}</td><td>${a.folders}</td><td>${a.inb
123
123
  </body></html>`);
124
124
  });
125
125
  // Graceful exit — close IMAP, DB, HTTP then exit
126
- app.post("/api/exit", (req, res) => {
126
+ app.all("/api/exit", (req, res) => {
127
127
  res.json({ ok: true });
128
128
  setTimeout(() => shutdown(), 100);
129
129
  });
@@ -72,5 +72,7 @@ export { getSharedDir };
72
72
  /** Initialize local config if it doesn't exist */
73
73
  export declare function initLocalConfig(sharedDir?: string, storePath?: string): void;
74
74
  declare const DEFAULT_SETTINGS: MailxSettings;
75
+ /** Get historyDays for an account: per-account override > system override > shared default */
76
+ export declare function getHistoryDays(accountId?: string): number;
75
77
  export { DEFAULT_SETTINGS, DEFAULT_ALLOWLIST, DEFAULT_PREFERENCES, LOCAL_DIR };
76
78
  //# sourceMappingURL=index.d.ts.map
@@ -346,14 +346,30 @@ export function loadAccounts() {
346
346
  }
347
347
  const raw = accounts.accounts || accounts;
348
348
  const globalName = accounts.name || "";
349
- return raw.map((a) => normalizeAccount(a, globalName));
349
+ const result = raw.map((a) => normalizeAccount(a, globalName));
350
+ return applyAccountOverrides(result);
350
351
  }
351
352
  // Legacy: read from settings.jsonc
352
353
  const legacy = loadLegacySettings();
353
354
  if (legacy?.accounts)
354
- return legacy.accounts.map((a) => normalizeAccount(a, legacy.name));
355
+ return applyAccountOverrides(legacy.accounts.map((a) => normalizeAccount(a, legacy.name)));
355
356
  return DEFAULT_ACCOUNTS;
356
357
  }
358
+ /** Apply local per-account overrides (enabled, etc.) */
359
+ function applyAccountOverrides(accounts) {
360
+ const localConfig = readLocalConfig();
361
+ const overrides = localConfig.accountOverrides;
362
+ if (!overrides)
363
+ return accounts;
364
+ for (const acct of accounts) {
365
+ const ov = overrides[acct.id];
366
+ if (!ov)
367
+ continue;
368
+ if (ov.enabled !== undefined)
369
+ acct.enabled = ov.enabled;
370
+ }
371
+ return accounts;
372
+ }
357
373
  /** Save account configs */
358
374
  export function saveAccounts(accounts) {
359
375
  saveFile("accounts.jsonc", { accounts });
@@ -498,5 +514,16 @@ const DEFAULT_SETTINGS = {
498
514
  sync: DEFAULT_PREFERENCES.sync,
499
515
  store: { basePath: DEFAULT_STORE_PATH, compressionBoundaryDays: 365 },
500
516
  };
517
+ /** Get historyDays for an account: per-account override > system override > shared default */
518
+ export function getHistoryDays(accountId) {
519
+ const localConfig = readLocalConfig();
520
+ if (accountId && localConfig.accountOverrides?.[accountId]?.historyDays !== undefined) {
521
+ return localConfig.accountOverrides[accountId].historyDays;
522
+ }
523
+ if (localConfig.historyDays !== undefined)
524
+ return localConfig.historyDays;
525
+ const prefs = loadPreferences();
526
+ return prefs.sync.historyDays || 0;
527
+ }
501
528
  export { DEFAULT_SETTINGS, DEFAULT_ALLOWLIST, DEFAULT_PREFERENCES, LOCAL_DIR };
502
529
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-settings",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",