@dawnlit/outlook-bridge 1.0.0 → 1.1.1
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/README.md +2 -1
- package/dist/OutlookService.d.ts +1 -1
- package/dist/OutlookService.js +2 -2
- package/dist/OutlookService.js.map +1 -1
- package/dist/errors.js +19 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mac/drafts.d.ts +12 -1
- package/dist/mac/drafts.js +71 -0
- package/dist/mac/drafts.js.map +1 -1
- package/dist/mac/index.js +1 -0
- package/dist/mac/index.js.map +1 -1
- package/dist/mac/read.d.ts +4 -2
- package/dist/mac/read.js +4 -2
- package/dist/mac/read.js.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/types.d.ts +26 -5
- package/dist/windows/accounts.d.ts +15 -1
- package/dist/windows/accounts.js +32 -5
- package/dist/windows/accounts.js.map +1 -1
- package/dist/windows/bounces.js +2 -1
- package/dist/windows/bounces.js.map +1 -1
- package/dist/windows/cleanup.js +2 -1
- package/dist/windows/cleanup.js.map +1 -1
- package/dist/windows/drafts.d.ts +12 -1
- package/dist/windows/drafts.js +62 -2
- package/dist/windows/drafts.js.map +1 -1
- package/dist/windows/folders.js +2 -1
- package/dist/windows/folders.js.map +1 -1
- package/dist/windows/index.d.ts +1 -1
- package/dist/windows/index.js +3 -1
- package/dist/windows/index.js.map +1 -1
- package/dist/windows/read.d.ts +18 -3
- package/dist/windows/read.js +66 -34
- package/dist/windows/read.js.map +1 -1
- package/dist/windows/scripts.d.ts +29 -6
- package/dist/windows/scripts.js +39 -11
- package/dist/windows/scripts.js.map +1 -1
- package/dist/windows/send.js +12 -1
- package/dist/windows/send.js.map +1 -1
- package/dist/windows/templates.js +4 -2
- package/dist/windows/templates.js.map +1 -1
- package/package.json +2 -2
package/dist/windows/bounces.js
CHANGED
|
@@ -214,7 +214,8 @@ async function readSentRecipientGroups(emailAccount, daysBack = 30, limit = 3000
|
|
|
214
214
|
const days = (0, mail_1.clamp)(daysBack, 1, 365);
|
|
215
215
|
const cap = (0, mail_1.clamp)(limit, 1, 10000);
|
|
216
216
|
const script = `${(0, scripts_1.accountScript)(emailAccount)}
|
|
217
|
-
$
|
|
217
|
+
${scripts_1.DELIVERY_STORE_PS}
|
|
218
|
+
$sent = $store.GetDefaultFolder(5) # olFolderSentMail
|
|
218
219
|
$cutoff = (Get-Date).AddDays(-${days}).ToString('MM/dd/yyyy HH:mm')
|
|
219
220
|
$items = $sent.Items.Restrict("[SentOn] >= '$cutoff'")
|
|
220
221
|
$items.Sort('[SentOn]', $true)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounces.js","sourceRoot":"","sources":["../../src/windows/bounces.ts"],"names":[],"mappings":";;AAuFA,4DAoFC;AAWD,4DAiCC;AASD,
|
|
1
|
+
{"version":3,"file":"bounces.js","sourceRoot":"","sources":["../../src/windows/bounces.ts"],"names":[],"mappings":";;AAuFA,4DAoFC;AAWD,4DAiCC;AASD,0DA2DC;AA3RD,wEAAwE;AACxE,yBAAyB;AACzB,+BAAsE;AACtE,uCAA+E;AAC/E,yCAAoF;AACpF,uDAM+B;AAC/B,kCAAgC;AAGhC;;;;GAIG;AACH,MAAM,eAAe,GAAG;eACT,IAAA,YAAM,EAAC,oCAAsB,CAAC;kBAC3B,IAAA,YAAM,EAAC,qCAAuB,CAAC;kBAC/B,IAAA,YAAM,EAAC,iCAAmB,CAAC;CAC5C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;2BAiBA,sCAAwB;;;;;;;;gDAQH,kCAAoB;;;;;;;;;;;CAWnE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,wBAAwB,CAC1C,YAAoB,EACpB,QAAQ,GAAG,EAAE,EACb,MAAM,GAAG,IAAI;IA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O,CAAC,CAAC;AACpF,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,uBAAuB,CACzC,YAAoB,EACpB,QAAQ,GAAG,EAAE,EACb,KAAK,GAAG,IAAI;IAEZ,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,EAAE,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAA,YAAK,EAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,IAAA,YAAK,EAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,YAAY,CAAC;EAC/C,2BAAiB;;gCAEa,IAAI;;;;qCAIC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCvC,CAAC;IACE,OAAO,IAAA,iBAAU,EAAC,MAAM,IAAA,mBAAa,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QAC5D,MAAM,CAAC,GAAG,IAAA,aAAM,EAAC,EAAE,CAAC,CAAC;QACrB,OAAO;YACH,OAAO,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,OAAO,CAAC;YACvB,OAAO,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,OAAO,CAAC;YACvB,MAAM,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,MAAM,CAAC;YACrB,UAAU,EAAE,IAAA,cAAO,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,UAAG,CAAC;SAC7C,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/windows/cleanup.js
CHANGED
|
@@ -129,7 +129,8 @@ ConvertTo-Json @{ dryRun = ${(0, run_1.psBool)(dryRun)}; deleted = $deleted; ref
|
|
|
129
129
|
async function purgeDeletedItems(emailAccount, olderThanDays = 0, dryRun = false) {
|
|
130
130
|
(0, run_1.requireWindows)();
|
|
131
131
|
const script = `${(0, scripts_1.accountScript)(emailAccount)}
|
|
132
|
-
$
|
|
132
|
+
${scripts_1.DELIVERY_STORE_PS}
|
|
133
|
+
$folder = $store.GetDefaultFolder(3)
|
|
133
134
|
$cutoff = (Get-Date).AddDays(-${olderThanDays})
|
|
134
135
|
$matched = 0
|
|
135
136
|
$purged = 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../src/windows/cleanup.ts"],"names":[],"mappings":";;AAgDA,kDA0EC;AAWD,
|
|
1
|
+
{"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../src/windows/cleanup.ts"],"names":[],"mappings":";;AAgDA,kDA0EC;AAWD,8CAwCC;AA7KD,wDAAwD;AACxD,+BAAgF;AAChF,uCAA6D;AAC7D,yCAAwE;AACxE,kCAAgD;AAGhD,mFAAmF;AACnF,MAAM,oBAAoB,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,0FAA0F;AAC1F,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;CAkBvB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACI,KAAK,UAAU,mBAAmB,CACrC,YAAoB,EACpB,QAAkB,EAClB,UAA6B,EAAE;IAE/B,IAAA,oBAAc,GAAE,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAC3D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACpE,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,YAAY,CAAC;EAC/C,2BAAiB;EACjB,eAAe;;qBAEI,oBAAoB,CAAC,I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GAAG,KAAK;IAEd,IAAA,oBAAc,GAAE,CAAC;IACjB,MAAM,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,YAAY,CAAC;EAC/C,2BAAiB;;gCAEa,aAAa;;;;;;;;;;;;;;;UAenC,aAAa;;UAEb,IAAA,YAAM,EAAC,MAAM,CAAC;;;;CAIvB,CAAC;IACE,MAAM,MAAM,GAAG,IAAA,kBAAW,EAAC,MAAM,IAAA,mBAAa,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChE,OAAO;QACH,UAAU,EAAE,IAAA,UAAG,EAAC,MAAM,CAAC,UAAU,CAAC;QAClC,MAAM;QACN,OAAO,EAAE,IAAA,UAAG,EAAC,MAAM,CAAC,OAAO,CAAC;QAC5B,MAAM,EAAE,IAAA,UAAG,EAAC,MAAM,CAAC,MAAM,CAAC;QAC1B,IAAI,EAAE,IAAA,UAAG,EAAC,MAAM,CAAC,IAAI,CAAC;QACtB,MAAM,EAAE,IAAA,UAAG,EAAC,MAAM,CAAC,MAAM,CAAC;KAC7B,CAAC;AACN,CAAC"}
|
package/dist/windows/drafts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeleteDraftsResult, ListDraftsResult, SendAllDraftsResult } from '../types';
|
|
1
|
+
import type { DeleteDraftsResult, ListDraftsResult, SendAllDraftsResult, SendDraftsResult } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Send the mail drafts that belong to `emailAccount`, wherever Outlook filed them.
|
|
4
4
|
* Which drafts those are is DRAFTS_SCAN_PS's rule, not this function's.
|
|
@@ -27,3 +27,14 @@ export declare function listOutlookDrafts(emailAccount: string, limit?: number,
|
|
|
27
27
|
* general-purpose "delete any email by id" tool, which is not what it is for.
|
|
28
28
|
*/
|
|
29
29
|
export declare function deleteOutlookDrafts(emailAccount: string, entryIds: string[]): Promise<DeleteDraftsResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Send a chosen subset of `emailAccount`'s drafts by EntryID — e.g. after
|
|
32
|
+
* `listOutlookDrafts` and a user review pass — instead of `sendAllDrafts`'s
|
|
33
|
+
* account-wide sweep.
|
|
34
|
+
*
|
|
35
|
+
* Same ownership gate as `deleteOutlookDrafts`: every id must resolve to a mail
|
|
36
|
+
* item sitting in one of THIS account's Drafts folders before anything is sent.
|
|
37
|
+
* An id pointing at ordinary inbox mail, or at another account's draft, is
|
|
38
|
+
* refused and reported rather than sent.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sendDrafts(emailAccount: string, entryIds: string[]): Promise<SendDraftsResult>;
|
package/dist/windows/drafts.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.sendAllDrafts = sendAllDrafts;
|
|
4
4
|
exports.listOutlookDrafts = listOutlookDrafts;
|
|
5
5
|
exports.deleteOutlookDrafts = deleteOutlookDrafts;
|
|
6
|
+
exports.sendDrafts = sendDrafts;
|
|
6
7
|
// Drafts: which ones belong to an account, and sending, listing or deleting them.
|
|
7
8
|
const run_1 = require("./run");
|
|
8
9
|
const scripts_1 = require("./scripts");
|
|
@@ -34,7 +35,7 @@ $scan = @()
|
|
|
34
35
|
$seen = @{}
|
|
35
36
|
|
|
36
37
|
$homeDrafts = $null
|
|
37
|
-
try { $homeDrafts = $
|
|
38
|
+
try { $homeDrafts = $store.GetDefaultFolder(16) } catch {} # olFolderDrafts
|
|
38
39
|
if ($homeDrafts -ne $null) {
|
|
39
40
|
$seen["$($homeDrafts.StoreID)|$($homeDrafts.EntryID)"] = $true
|
|
40
41
|
$scan += [pscustomobject]@{ folder = $homeDrafts; includeNull = $true }
|
|
@@ -61,7 +62,7 @@ function Test-DraftMatches($item, $includeNull) {
|
|
|
61
62
|
`;
|
|
62
63
|
/** Session, account and the drafts scan rule — the prelude all three share. */
|
|
63
64
|
function draftsScript(emailAccount) {
|
|
64
|
-
return (0, scripts_1.accountScript)(emailAccount) + DRAFTS_SCAN_PS;
|
|
65
|
+
return (0, scripts_1.accountScript)(emailAccount) + scripts_1.DELIVERY_STORE_PS + DRAFTS_SCAN_PS;
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Send the mail drafts that belong to `emailAccount`, wherever Outlook filed them.
|
|
@@ -250,4 +251,63 @@ ConvertTo-Json @{ deleted = $deleted; failed = @($failed) } -Depth 3
|
|
|
250
251
|
}),
|
|
251
252
|
};
|
|
252
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Send a chosen subset of `emailAccount`'s drafts by EntryID — e.g. after
|
|
256
|
+
* `listOutlookDrafts` and a user review pass — instead of `sendAllDrafts`'s
|
|
257
|
+
* account-wide sweep.
|
|
258
|
+
*
|
|
259
|
+
* Same ownership gate as `deleteOutlookDrafts`: every id must resolve to a mail
|
|
260
|
+
* item sitting in one of THIS account's Drafts folders before anything is sent.
|
|
261
|
+
* An id pointing at ordinary inbox mail, or at another account's draft, is
|
|
262
|
+
* refused and reported rather than sent.
|
|
263
|
+
*/
|
|
264
|
+
async function sendDrafts(emailAccount, entryIds) {
|
|
265
|
+
(0, run_1.requireWindows)();
|
|
266
|
+
if (entryIds.length === 0)
|
|
267
|
+
return { sent: 0, failed: [] };
|
|
268
|
+
const script = `${draftsScript(emailAccount)}
|
|
269
|
+
# Index this account's Drafts folders by EntryID, so a resolved item can be PROVED
|
|
270
|
+
# to live in one of them before it is sent.
|
|
271
|
+
$draftFolderIds = @{}
|
|
272
|
+
foreach ($entry in $scan) { $draftFolderIds[$entry.folder.EntryID] = $entry.includeNull }
|
|
273
|
+
|
|
274
|
+
$sent = 0
|
|
275
|
+
$failed = @()
|
|
276
|
+
foreach ($id in @(${(0, run_1.psList)(entryIds)})) {
|
|
277
|
+
$subj = ''
|
|
278
|
+
try {
|
|
279
|
+
$it = $null
|
|
280
|
+
foreach ($entry in $scan) {
|
|
281
|
+
try {
|
|
282
|
+
$it = $ns.GetItemFromID($id, $entry.folder.StoreID)
|
|
283
|
+
if ($it -ne $null) { break }
|
|
284
|
+
} catch { $it = $null }
|
|
285
|
+
}
|
|
286
|
+
if ($it -eq $null) { throw "no such item in this account's Drafts folders" }
|
|
287
|
+
try { $subj = $it.Subject } catch {}
|
|
288
|
+
$parentId = ''
|
|
289
|
+
try { $parentId = $it.Parent.EntryID } catch {}
|
|
290
|
+
if (-not $draftFolderIds.ContainsKey($parentId)) {
|
|
291
|
+
throw "item is not in this account's Drafts folder - refusing to send"
|
|
292
|
+
}
|
|
293
|
+
if (-not (Test-DraftMatches $it $draftFolderIds[$parentId])) {
|
|
294
|
+
throw "draft is not bound to $target - refusing to send"
|
|
295
|
+
}
|
|
296
|
+
$it.Send()
|
|
297
|
+
$sent++
|
|
298
|
+
} catch {
|
|
299
|
+
$failed += [pscustomobject]@{ entryId = $id; subject = $subj; error = $_.Exception.Message }
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
[pscustomobject]@{ sent = $sent; failed = @($failed) } | ConvertTo-Json -Compress -Depth 4
|
|
303
|
+
`;
|
|
304
|
+
const parsed = (0, json_1.parseObject)(await (0, run_1.runPowerShell)(script, 300000));
|
|
305
|
+
return {
|
|
306
|
+
sent: (0, json_1.num)(parsed.sent),
|
|
307
|
+
failed: (0, json_1.toArray)(parsed.failed).map(f => {
|
|
308
|
+
const e = (0, json_1.record)(f);
|
|
309
|
+
return { entryId: (0, json_1.str)(e.entryId), subject: (0, json_1.str)(e.subject), error: (0, json_1.str)(e.error) };
|
|
310
|
+
}),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
253
313
|
//# sourceMappingURL=drafts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drafts.js","sourceRoot":"","sources":["../../src/windows/drafts.ts"],"names":[],"mappings":";;AAuEA,sCA0CC;AAWD,8CAyEC;AAWD,kDAgDC;
|
|
1
|
+
{"version":3,"file":"drafts.js","sourceRoot":"","sources":["../../src/windows/drafts.ts"],"names":[],"mappings":";;AAuEA,sCA0CC;AAWD,8CAyEC;AAWD,kDAgDC;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AE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC1D,MAAM,MAAM,GAAG,GAAG,YAAY,CAAC,YAAY,CAAC;;;;;;;;oBAQ5B,IAAA,YAAM,EAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BnC,CAAC;IACE,MAAM,MAAM,GAAG,IAAA,kBAAW,EAAC,MAAM,IAAA,mBAAa,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChE,OAAO;QACH,IAAI,EAAE,IAAA,UAAG,EAAC,MAAM,CAAC,IAAI,CAAC;QACtB,MAAM,EAAE,IAAA,cAAO,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACnC,MAAM,CAAC,GAAG,IAAA,aAAM,EAAC,CAAC,CAAC,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACrF,CAAC,CAAC;KACL,CAAC;AACN,CAAC"}
|
package/dist/windows/folders.js
CHANGED
|
@@ -13,7 +13,8 @@ async function listInboxFolders(emailAccount, maxDepth = 2) {
|
|
|
13
13
|
return [];
|
|
14
14
|
const depth = (0, mail_1.clamp)(maxDepth, 1, 4);
|
|
15
15
|
const script = `${(0, scripts_1.accountScript)(emailAccount)}
|
|
16
|
-
$
|
|
16
|
+
${scripts_1.DELIVERY_STORE_PS}
|
|
17
|
+
$inbox = $store.GetDefaultFolder(6)
|
|
17
18
|
function Walk-Folders($folder, $level) {
|
|
18
19
|
foreach ($f in $folder.Folders) {
|
|
19
20
|
[PSCustomObject]@{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folders.js","sourceRoot":"","sources":["../../src/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AC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC1E,CAAC;IACD,MAAM,GAAG,GAAG,IAAA,oBAAa,EAAC,UAAU,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,YAAY,CAAC;EAC/C,2BAAiB;EACjB,IAAA,yBAAe,EAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC;;;;;oBAK/B,IAAA,YAAM,EAAC,QAAQ,CAAC;;;;;;;;;;CAUnC,CAAC;IACE,MAAM,MAAM,GAAG,IAAA,kBAAW,EAAC,MAAM,IAAA,mBAAa,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChE,OAAO;QACH,UAAU,EAAE,IAAA,UAAG,EAAC,MAAM,CAAC,UAAU,CAAC;QAClC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;QAC5C,KAAK,EAAE,IAAA,UAAG,EAAC,MAAM,CAAC,KAAK,CAAC;QACxB,MAAM,EAAE,IAAA,cAAO,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACnC,MAAM,CAAC,GAAG,IAAA,aAAM,EAAC,CAAC,CAAC,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5D,CAAC,CAAC;KACL,CAAC;AACN,CAAC"}
|
package/dist/windows/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export * from './bounces';
|
|
|
19
19
|
export * from './attachments';
|
|
20
20
|
export * from './signatures';
|
|
21
21
|
export * from './templates';
|
|
22
|
-
export { mailScopeScript } from './scripts';
|
|
22
|
+
export { accountScript, mailScopeScript } from './scripts';
|
|
23
23
|
/**
|
|
24
24
|
* Windows drives the full COM object model, so every operation is available —
|
|
25
25
|
* this is the reference the macOS map is measured against.
|
package/dist/windows/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.capabilities = exports.mailScopeScript = exports.bridge = void 0;
|
|
17
|
+
exports.capabilities = exports.mailScopeScript = exports.accountScript = exports.bridge = void 0;
|
|
18
18
|
// The Windows implementation: Outlook driven through PowerShell + COM.
|
|
19
19
|
//
|
|
20
20
|
// Split by feature rather than kept as one file — every operation here is
|
|
@@ -58,6 +58,7 @@ const bridge = {
|
|
|
58
58
|
moveOutlookEmails: folders_1.moveOutlookEmails,
|
|
59
59
|
listOutlookDrafts: drafts_1.listOutlookDrafts,
|
|
60
60
|
deleteOutlookDrafts: drafts_1.deleteOutlookDrafts,
|
|
61
|
+
sendDrafts: drafts_1.sendDrafts,
|
|
61
62
|
deleteOutlookEmails: cleanup_1.deleteOutlookEmails,
|
|
62
63
|
purgeDeletedItems: cleanup_1.purgeDeletedItems,
|
|
63
64
|
saveEmailAttachment: attachments_1.saveEmailAttachment,
|
|
@@ -91,6 +92,7 @@ __exportStar(require("./templates"), exports);
|
|
|
91
92
|
// without an Outlook session — a syntax error in it would otherwise only ever
|
|
92
93
|
// surface as a failed live run.
|
|
93
94
|
var scripts_1 = require("./scripts");
|
|
95
|
+
Object.defineProperty(exports, "accountScript", { enumerable: true, get: function () { return scripts_1.accountScript; } });
|
|
94
96
|
Object.defineProperty(exports, "mailScopeScript", { enumerable: true, get: function () { return scripts_1.mailScopeScript; } });
|
|
95
97
|
/**
|
|
96
98
|
* Windows drives the full COM object model, so every operation is available —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/windows/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uEAAuE;AACvE,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,mCAAmC;AACnC,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,yCAAgD;AAChD,iCAA6D;AAC7D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/windows/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uEAAuE;AACvE,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,mCAAmC;AACnC,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,yCAAgD;AAChD,iCAA6D;AAC7D,qCAA6F;AAC7F,iCAAmH;AACnH,uCAAgE;AAChE,uCAAmE;AACnE,uCAAyG;AACzG,+CAAwG;AACxG,6CAA+E;AAC/E,2CAAuF;AACvF,yDAAuD;AAGvD;;;;;;;GAOG;AACH,MAAM,MAAM,GAAkB;IAC1B,kBAAkB,EAAlB,6BAAkB;IAClB,gBAAgB,EAAhB,uBAAgB;IAChB,iBAAiB,EAAjB,wBAAiB;IACjB,aAAa,EAAb,sBAAa;IACb,eAAe,EAAf,sBAAe;IACf,mBAAmB,EAAnB,0BAAmB;IACnB,iBAAiB,EAAjB,wBAAiB;IACjB,aAAa,EAAb,oBAAa;IACb,gBAAgB,EAAhB,uBAAgB;IAChB,gBAAgB,EAAhB,0BAAgB;IAChB,iBAAiB,EAAjB,2BAAiB;IACjB,iBAAiB,EAAjB,0BAAiB;IACjB,mBAAmB,EAAnB,4BAAmB;IACnB,UAAU,EAAV,mBAAU;IACV,mBAAmB,EAAnB,6BAAmB;IACnB,iBAAiB,EAAjB,2BAAiB;IACjB,mBAAmB,EAAnB,iCAAmB;IACnB,2BAA2B,EAA3B,yCAA2B;IAC3B,oBAAoB,EAApB,kCAAoB;IACpB,wBAAwB,EAAxB,kCAAwB;IACxB,wBAAwB,EAAxB,kCAAwB;IACxB,uBAAuB,EAAvB,iCAAuB;IACvB,qBAAqB,EAArB,kCAAqB;IACrB,wBAAwB,EAAxB,qCAAwB;IACxB,kBAAkB,EAAlB,8BAAkB;IAClB,iBAAiB,EAAjB,6BAAiB;IACjB,iBAAiB,EAAjB,6BAAiB;CACpB,CAAC;AAEO,wBAAM;AAEf,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,oBAAoB;AACpB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB;AACzB,yCAAuB;AACvB,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,8CAA4B;AAE5B,4EAA4E;AAC5E,8EAA8E;AAC9E,gCAAgC;AAChC,qCAA2D;AAAlD,wGAAA,aAAa,OAAA;AAAE,0GAAA,eAAe,OAAA;AAEvC;;;GAGG;AACU,QAAA,YAAY,GAAkB,IAAA,4BAAa,EAAC,MAAM,CAAC,CAAC"}
|
package/dist/windows/read.d.ts
CHANGED
|
@@ -42,7 +42,10 @@ export declare function readEmailBody(entryId: string, storeId?: string, maxChar
|
|
|
42
42
|
* daily batch run wants, since a subject filter alone walks the whole Inbox
|
|
43
43
|
* tree and returns every match ever received. 0 keeps that unbounded
|
|
44
44
|
* behavior, and is only sane paired with `filter.subjectLike` so Restrict can
|
|
45
|
-
* narrow the set server-side before anything crosses COM.
|
|
45
|
+
* narrow the set server-side before anything crosses COM. Where the store
|
|
46
|
+
* won't run that subject query — an IMAP mailbox accepts it and then matches
|
|
47
|
+
* nothing — an unbounded scan falls back to the last 60 days rather than
|
|
48
|
+
* walking every item the mailbox has ever held.
|
|
46
49
|
*/
|
|
47
50
|
export declare function searchInboxByFilter(emailAccount: string, filter?: InboxSearchFilter, daysBack?: number): Promise<InboxSearchMatch[]>;
|
|
48
51
|
/**
|
|
@@ -50,5 +53,17 @@ export declare function searchInboxByFilter(emailAccount: string, filter?: Inbox
|
|
|
50
53
|
* attachments listed by name but not saved.
|
|
51
54
|
*/
|
|
52
55
|
export declare function readSelectedEmail(): Promise<SelectedEmail>;
|
|
53
|
-
/**
|
|
54
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Open an email in Outlook by its EntryID.
|
|
58
|
+
*
|
|
59
|
+
* `storeId` disambiguates across mailboxes — without one, `GetItemFromID` only
|
|
60
|
+
* looks in the default store, so an id from a shared or secondary mailbox
|
|
61
|
+
* simply isn't found. It's tried first and the bare lookup is the fallback, so
|
|
62
|
+
* a caller holding a stale StoreID (or none) still resolves whatever it can.
|
|
63
|
+
*
|
|
64
|
+
* EntryIDs are rewritten when an item MOVES between folders, so an id recorded
|
|
65
|
+
* before its mail was filed can resolve to nothing — or, worse, to a different
|
|
66
|
+
* message. The caller is the one that knows what the email was supposed to be;
|
|
67
|
+
* this throws a plain not-found rather than guessing.
|
|
68
|
+
*/
|
|
69
|
+
export declare function openOutlookEmail(entryId: string, storeId?: string): Promise<void>;
|
package/dist/windows/read.js
CHANGED
|
@@ -194,26 +194,25 @@ ConvertTo-Json $out -Depth 3 -Compress
|
|
|
194
194
|
* daily batch run wants, since a subject filter alone walks the whole Inbox
|
|
195
195
|
* tree and returns every match ever received. 0 keeps that unbounded
|
|
196
196
|
* behavior, and is only sane paired with `filter.subjectLike` so Restrict can
|
|
197
|
-
* narrow the set server-side before anything crosses COM.
|
|
197
|
+
* narrow the set server-side before anything crosses COM. Where the store
|
|
198
|
+
* won't run that subject query — an IMAP mailbox accepts it and then matches
|
|
199
|
+
* nothing — an unbounded scan falls back to the last 60 days rather than
|
|
200
|
+
* walking every item the mailbox has ever held.
|
|
198
201
|
*/
|
|
199
202
|
async function searchInboxByFilter(emailAccount, filter = {}, daysBack = 0) {
|
|
200
203
|
if (process.platform !== 'win32')
|
|
201
204
|
return [];
|
|
202
205
|
const subjectLike = filter.subjectLike ? (0, run_1.psEscape)(filter.subjectLike) : '';
|
|
206
|
+
// DASL's `like` takes SQL wildcards, so the glob the filter is written in is
|
|
207
|
+
// translated for the server-side prefilter. The client-side re-check keeps
|
|
208
|
+
// the glob form, which is what PowerShell's own -like reads.
|
|
209
|
+
const subjectDasl = filter.subjectLike
|
|
210
|
+
? (0, run_1.psEscape)(filter.subjectLike.replace(/\*/g, '%').replace(/\?/g, '_'))
|
|
211
|
+
: '';
|
|
203
212
|
const subjectPatternSrc = filter.subjectPattern ? (0, run_1.psEscape)(filter.subjectPattern.source) : '';
|
|
204
|
-
// The subject filter reaches PowerShell as a single-quoted literal assigned to
|
|
205
|
-
// $subjLike, and the Restrict query is CONCATENATED from it. Interpolating it
|
|
206
|
-
// into the double-quoted query string directly — which is what the query needs
|
|
207
|
-
// to be, so `$cutoff` expands — would let a caller's `$(...)` execute, and
|
|
208
|
-
// would break the query outright on an apostrophe.
|
|
209
|
-
const boundedRestrict = subjectLike
|
|
210
|
-
? `$folder.Items.Restrict("[ReceivedTime] >= '$cutoff' AND [Subject] like '" + $subjLike + "'")`
|
|
211
|
-
: `$folder.Items.Restrict("[ReceivedTime] >= '$cutoff'")`;
|
|
212
|
-
const unboundedRestrict = subjectLike
|
|
213
|
-
? `$folder.Items.Restrict("[Subject] like '" + $subjLike + "'")`
|
|
214
|
-
: `$folder.Items`;
|
|
215
213
|
const script = `
|
|
216
214
|
$subjLike = '${subjectLike}'
|
|
215
|
+
$subjDasl = '${subjectDasl}'
|
|
217
216
|
${(0, scripts_1.accountScript)(emailAccount)}
|
|
218
217
|
${(0, scripts_1.namedStoreScript)(emailAccount)}
|
|
219
218
|
$inbox = $store.GetDefaultFolder(6)
|
|
@@ -225,31 +224,42 @@ while ($fi -lt $folders.Count) {
|
|
|
225
224
|
try { foreach ($sub in $folders[$fi].Folders) { [void]$folders.Add($sub) } } catch {}
|
|
226
225
|
$fi++
|
|
227
226
|
}
|
|
227
|
+
# The subject prefilter is a DASL property query rather than Outlook's Jet
|
|
228
|
+
# syntax: "[Subject] like '...'" is rejected outright by some stores — an IMAP
|
|
229
|
+
# mailbox answers "Condition is not valid" — while DASL is accepted wherever
|
|
230
|
+
# Restrict is. The two syntaxes cannot be mixed in one filter string, so the
|
|
231
|
+
# date clause stays Jet and the subject one is applied as a second Restrict on
|
|
232
|
+
# top of it. The pattern is CONCATENATED into the query, never interpolated:
|
|
233
|
+
# interpolating would let a caller's $(...) run, and would break the query
|
|
234
|
+
# outright on an apostrophe.
|
|
235
|
+
$subjQuery = '@SQL=' + [char]34 + 'urn:schemas:httpmail:subject' + [char]34 + ' like ' + [char]39 + $subjDasl + [char]39
|
|
228
236
|
$daysBack = ${daysBack}
|
|
229
237
|
foreach ($folder in $folders) {
|
|
230
238
|
if ($daysBack -gt 0) {
|
|
231
|
-
# Bounded scan. Filter on BOTH date and subject in the Restrict so Outlook does the
|
|
232
|
-
# work server-side — a date-only restrict hands back every item in the window for
|
|
233
|
-
# every folder in the tree, which is thousands of COM round-trips on a busy mailbox.
|
|
234
|
-
# Any stricter subject regex still runs on whatever survives.
|
|
235
239
|
$cutoff = (Get-Date).AddDays(-$daysBack).ToString('MM/dd/yyyy HH:mm')
|
|
236
|
-
|
|
237
|
-
$filtered = ${boundedRestrict}
|
|
238
|
-
$fCount = $filtered.Count
|
|
239
|
-
} catch {
|
|
240
|
-
# Some stores reject the compound query; fall back to date-only.
|
|
241
|
-
$filtered = $folder.Items.Restrict("[ReceivedTime] >= '$cutoff'")
|
|
242
|
-
$fCount = $filtered.Count
|
|
243
|
-
}
|
|
240
|
+
$filtered = $folder.Items.Restrict("[ReceivedTime] >= '$cutoff'")
|
|
244
241
|
} else {
|
|
245
|
-
$filtered = $
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
242
|
+
$filtered = $folder.Items
|
|
243
|
+
}
|
|
244
|
+
${subjectLike ? ` # Narrowing on the subject server-side is what keeps this cheap — a date-only
|
|
245
|
+
# restrict hands back every item in the window for every folder in the tree,
|
|
246
|
+
# which is thousands of COM round-trips on a busy mailbox. It is only an
|
|
247
|
+
# optimization though: every subject is re-checked below, so a store that
|
|
248
|
+
# cannot run the query returns the same answer, slower.
|
|
249
|
+
$narrowed = $null
|
|
250
|
+
try {
|
|
251
|
+
$candidate = $filtered.Restrict($subjQuery)
|
|
252
|
+
if ($candidate.Count -gt 0) { $narrowed = $candidate }
|
|
253
|
+
} catch {}
|
|
254
|
+
if ($narrowed -ne $null) {
|
|
255
|
+
$filtered = $narrowed
|
|
256
|
+
} elseif ($daysBack -le 0) {
|
|
257
|
+
# Nothing narrowed it and nothing bounds it, which would walk every item
|
|
258
|
+
# the folder has ever held; cap the sweep at a window instead.
|
|
259
|
+
$cutoff = (Get-Date).AddDays(-60).ToString('MM/dd/yyyy HH:mm')
|
|
260
|
+
$filtered = $folder.Items.Restrict("[ReceivedTime] >= '$cutoff'")
|
|
252
261
|
}
|
|
262
|
+
` : ''} $fCount = $filtered.Count
|
|
253
263
|
for ($i = 1; $i -le $fCount; $i++) {
|
|
254
264
|
$item = $filtered.Item($i)
|
|
255
265
|
if ($seen.ContainsKey($item.EntryID)) { continue }
|
|
@@ -257,6 +267,7 @@ foreach ($folder in $folders) {
|
|
|
257
267
|
$subject = $item.Subject
|
|
258
268
|
if (-not $subject) { continue }
|
|
259
269
|
$subject = $subject.Trim()
|
|
270
|
+
${subjectLike ? `if ($subject -notlike $subjLike) { continue }` : ''}
|
|
260
271
|
${subjectPatternSrc ? `if ($subject -notmatch '${subjectPatternSrc}') { continue }` : ''}
|
|
261
272
|
${filter.excludeReplies ? `if ($subject -imatch '^(re|fw[d]?)\\s*:') { continue }` : ''}
|
|
262
273
|
${filter.requireAttachment ? `if ($item.Attachments.Count -eq 0) { continue }` : ''}
|
|
@@ -363,10 +374,31 @@ ConvertTo-Json $result -Depth 3
|
|
|
363
374
|
attachmentNames: (0, json_1.toArray)(e.attachmentNames).map(json_1.str),
|
|
364
375
|
};
|
|
365
376
|
}
|
|
366
|
-
/**
|
|
367
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Open an email in Outlook by its EntryID.
|
|
379
|
+
*
|
|
380
|
+
* `storeId` disambiguates across mailboxes — without one, `GetItemFromID` only
|
|
381
|
+
* looks in the default store, so an id from a shared or secondary mailbox
|
|
382
|
+
* simply isn't found. It's tried first and the bare lookup is the fallback, so
|
|
383
|
+
* a caller holding a stale StoreID (or none) still resolves whatever it can.
|
|
384
|
+
*
|
|
385
|
+
* EntryIDs are rewritten when an item MOVES between folders, so an id recorded
|
|
386
|
+
* before its mail was filed can resolve to nothing — or, worse, to a different
|
|
387
|
+
* message. The caller is the one that knows what the email was supposed to be;
|
|
388
|
+
* this throws a plain not-found rather than guessing.
|
|
389
|
+
*/
|
|
390
|
+
async function openOutlookEmail(entryId, storeId) {
|
|
368
391
|
(0, run_1.requireWindows)();
|
|
369
|
-
const script = `
|
|
392
|
+
const script = `
|
|
393
|
+
$outlook = New-Object -ComObject Outlook.Application
|
|
394
|
+
$ns = $outlook.GetNamespace('mapi')
|
|
395
|
+
$ns.Logon()
|
|
396
|
+
$item = $null
|
|
397
|
+
${storeId ? `try { ${(0, scripts_1.getItemScript)(entryId, storeId)} } catch { $item = $null }` : ''}
|
|
398
|
+
if ($item -eq $null) { try { ${(0, scripts_1.getItemScript)(entryId)} } catch { $item = $null } }
|
|
399
|
+
if ($item -eq $null) { throw "Email not found for EntryID '${(0, run_1.psEscape)(entryId)}'" }
|
|
400
|
+
$item.Display()
|
|
401
|
+
`;
|
|
370
402
|
await (0, run_1.runPowerShell)(script);
|
|
371
403
|
}
|
|
372
404
|
//# sourceMappingURL=read.js.map
|
package/dist/windows/read.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/windows/read.ts"],"names":[],"mappings":";;AAsCA,0CA0EC;AAmBD,sCA0DC;
|
|
1
|
+
{"version":3,"file":"read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CAAC,CAAC,OAAO,CAAC;QACvB,OAAO,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,OAAO,CAAC;QACvB,UAAU,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,UAAU,CAAC;QAC7B,WAAW,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,WAAW,CAAC;QAC/B,YAAY,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,YAAY,CAAC;QACjC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;QACxB,eAAe,EAAE,IAAA,cAAO,EAAC,CAAC,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,UAAG,CAAC;KACvD,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAAe,EAAE,OAAgB;IACpE,IAAA,oBAAc,GAAE,CAAC;IACjB,MAAM,MAAM,GAAG;;;;;EAKjB,OAAO,CAAC,CAAC,CAAC,SAAS,IAAA,uBAAa,EAAC,OAAO,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC,CAAC,EAAE;+BACtD,IAAA,uBAAa,EAAC,OAAO,CAAC;6DACQ,IAAA,cAAQ,EAAC,OAAO,CAAC;;CAE7E,CAAC;IACE,MAAM,IAAA,mBAAa,EAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
import type { MailFolderRef } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Session plus the
|
|
4
|
-
* `$
|
|
3
|
+
* Session plus the mailbox the address names; binds `$target`, `$account` and
|
|
4
|
+
* `$storeFolder`.
|
|
5
|
+
*
|
|
6
|
+
* An address can name a mailbox two different ways, and only one of them is an
|
|
7
|
+
* Account. A mailbox opened as a secondary store has no Account object, so
|
|
8
|
+
* resolving through Accounts alone closes every operation to it — including the
|
|
9
|
+
* reads, which never needed an Account in the first place. Both are resolved
|
|
10
|
+
* here and EITHER is enough: `$account` is null for a store-only mailbox, and
|
|
11
|
+
* the operations that genuinely require an identity to act as (sending) check
|
|
12
|
+
* for it themselves rather than being denied the mailbox up front.
|
|
5
13
|
*
|
|
6
14
|
* Fails rather than falling back to the default account. A bad address must
|
|
7
15
|
* never silently send from — or read — the wrong mailbox, and the thrown
|
|
8
16
|
* sentence is the one `classifyRunFailure` recognises to raise
|
|
9
17
|
* `AccountNotFoundError`, so the wording is load-bearing.
|
|
18
|
+
*
|
|
19
|
+
* The store is matched on the target address BEFORE the account's display name,
|
|
20
|
+
* which is what keeps the named-store route (see `namedStoreScript`) selecting
|
|
21
|
+
* the folders it selected before on a profile where the two differ.
|
|
10
22
|
*/
|
|
11
23
|
export declare function accountScript(emailAccount: string): string;
|
|
12
|
-
/** The account's own delivery store, as `$store`. Requires `accountScript`. */
|
|
13
|
-
export declare const DELIVERY_STORE_PS = "\n$store = $account.DeliveryStore\n$storeId = $store.StoreID\n";
|
|
14
24
|
/**
|
|
15
|
-
* The
|
|
16
|
-
*
|
|
25
|
+
* The mailbox's own store, as `$store`. Requires `accountScript`.
|
|
26
|
+
*
|
|
27
|
+
* Falls back to the resolved store folder because a store-only mailbox has no
|
|
28
|
+
* account to read a DeliveryStore off — reaching through `$account` directly is
|
|
29
|
+
* what makes an operation fail on exactly those mailboxes.
|
|
30
|
+
*/
|
|
31
|
+
export declare const DELIVERY_STORE_PS = "\n$store = if ($account -ne $null) { $account.DeliveryStore } else { $storeFolder.Store }\n$storeId = $store.StoreID\n";
|
|
32
|
+
/**
|
|
33
|
+
* The store `accountScript` resolved through the namespace's top-level folders,
|
|
34
|
+
* as `$store`.
|
|
17
35
|
*
|
|
18
36
|
* Kept alongside `DELIVERY_STORE_PS` rather than replaced by it: the reading
|
|
19
37
|
* operations resolve the store this way, and on a profile where a mailbox is
|
|
20
38
|
* open under a display name that differs from the delivery store's, the two do
|
|
21
39
|
* not select the same folders. Changing which one a reader uses changes what it
|
|
22
40
|
* returns, so each keeps the route it was verified against.
|
|
41
|
+
*
|
|
42
|
+
* The folder search itself now lives in `accountScript`, which has to attempt it
|
|
43
|
+
* anyway to resolve a mailbox that has no account. This throws when it found
|
|
44
|
+
* nothing, which is the case where the address named an account whose store is
|
|
45
|
+
* not open in this profile.
|
|
23
46
|
*/
|
|
24
47
|
export declare function namedStoreScript(emailAccount: string): string;
|
|
25
48
|
/**
|
package/dist/windows/scripts.js
CHANGED
|
@@ -25,13 +25,25 @@ $ns = $outlook.GetNamespace('mapi')
|
|
|
25
25
|
$ns.Logon()
|
|
26
26
|
`;
|
|
27
27
|
/**
|
|
28
|
-
* Session plus the
|
|
29
|
-
* `$
|
|
28
|
+
* Session plus the mailbox the address names; binds `$target`, `$account` and
|
|
29
|
+
* `$storeFolder`.
|
|
30
|
+
*
|
|
31
|
+
* An address can name a mailbox two different ways, and only one of them is an
|
|
32
|
+
* Account. A mailbox opened as a secondary store has no Account object, so
|
|
33
|
+
* resolving through Accounts alone closes every operation to it — including the
|
|
34
|
+
* reads, which never needed an Account in the first place. Both are resolved
|
|
35
|
+
* here and EITHER is enough: `$account` is null for a store-only mailbox, and
|
|
36
|
+
* the operations that genuinely require an identity to act as (sending) check
|
|
37
|
+
* for it themselves rather than being denied the mailbox up front.
|
|
30
38
|
*
|
|
31
39
|
* Fails rather than falling back to the default account. A bad address must
|
|
32
40
|
* never silently send from — or read — the wrong mailbox, and the thrown
|
|
33
41
|
* sentence is the one `classifyRunFailure` recognises to raise
|
|
34
42
|
* `AccountNotFoundError`, so the wording is load-bearing.
|
|
43
|
+
*
|
|
44
|
+
* The store is matched on the target address BEFORE the account's display name,
|
|
45
|
+
* which is what keeps the named-store route (see `namedStoreScript`) selecting
|
|
46
|
+
* the folders it selected before on a profile where the two differ.
|
|
35
47
|
*/
|
|
36
48
|
function accountScript(emailAccount) {
|
|
37
49
|
return `${PS_PRELUDE}
|
|
@@ -40,30 +52,46 @@ $account = $null
|
|
|
40
52
|
foreach ($a in $ns.Accounts) {
|
|
41
53
|
if ($a.SmtpAddress -ieq $target) { $account = $a; break }
|
|
42
54
|
}
|
|
43
|
-
|
|
55
|
+
$storeFolder = $null
|
|
56
|
+
foreach ($f in $ns.Folders) {
|
|
57
|
+
if ($f.Name -ieq $target) { $storeFolder = $f; break }
|
|
58
|
+
}
|
|
59
|
+
if ($storeFolder -eq $null -and $account -ne $null) {
|
|
60
|
+
foreach ($f in $ns.Folders) {
|
|
61
|
+
if ($f.Name -ieq $account.DisplayName) { $storeFolder = $f; break }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if ($account -eq $null -and $storeFolder -eq $null) { throw "Account '$target' not found" }
|
|
44
65
|
`;
|
|
45
66
|
}
|
|
46
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* The mailbox's own store, as `$store`. Requires `accountScript`.
|
|
69
|
+
*
|
|
70
|
+
* Falls back to the resolved store folder because a store-only mailbox has no
|
|
71
|
+
* account to read a DeliveryStore off — reaching through `$account` directly is
|
|
72
|
+
* what makes an operation fail on exactly those mailboxes.
|
|
73
|
+
*/
|
|
47
74
|
exports.DELIVERY_STORE_PS = `
|
|
48
|
-
$store = $account.DeliveryStore
|
|
75
|
+
$store = if ($account -ne $null) { $account.DeliveryStore } else { $storeFolder.Store }
|
|
49
76
|
$storeId = $store.StoreID
|
|
50
77
|
`;
|
|
51
78
|
/**
|
|
52
|
-
* The
|
|
53
|
-
*
|
|
79
|
+
* The store `accountScript` resolved through the namespace's top-level folders,
|
|
80
|
+
* as `$store`.
|
|
54
81
|
*
|
|
55
82
|
* Kept alongside `DELIVERY_STORE_PS` rather than replaced by it: the reading
|
|
56
83
|
* operations resolve the store this way, and on a profile where a mailbox is
|
|
57
84
|
* open under a display name that differs from the delivery store's, the two do
|
|
58
85
|
* not select the same folders. Changing which one a reader uses changes what it
|
|
59
86
|
* returns, so each keeps the route it was verified against.
|
|
87
|
+
*
|
|
88
|
+
* The folder search itself now lives in `accountScript`, which has to attempt it
|
|
89
|
+
* anyway to resolve a mailbox that has no account. This throws when it found
|
|
90
|
+
* nothing, which is the case where the address named an account whose store is
|
|
91
|
+
* not open in this profile.
|
|
60
92
|
*/
|
|
61
93
|
function namedStoreScript(emailAccount) {
|
|
62
94
|
return `
|
|
63
|
-
$storeFolder = $null
|
|
64
|
-
foreach ($f in $ns.Folders) {
|
|
65
|
-
if ($f.Name -ieq $account.DisplayName) { $storeFolder = $f; break }
|
|
66
|
-
}
|
|
67
95
|
if ($storeFolder -eq $null) { throw "Store folder not found for account '${(0, run_1.psEscape)(emailAccount)}'" }
|
|
68
96
|
$store = $storeFolder.Store
|
|
69
97
|
$storeId = $store.StoreID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../src/windows/scripts.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../src/windows/scripts.ts"],"names":[],"mappings":";;;AA2CA,sCAkBC;AA6BD,4CAMC;AAMD,sCAIC;AAgDD,0CAoCC;AA9LD,0EAA0E;AAC1E,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,iCAAiC;AACjC,+BAAiC;AAGjC;;;;;;GAMG;AACH,MAAM,UAAU,GAAG;;;;;CAKlB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,aAAa,CAAC,YAAoB;IAC9C,OAAO,GAAG,UAAU;aACX,IAAA,cAAQ,EAAC,YAAY,CAAC;;;;;;;;;;;;;;;CAelC,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACU,QAAA,iBAAiB,GAAG;;;CAGhC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,SAAgB,gBAAgB,CAAC,YAAoB;IACjD,OAAO;2EACgE,IAAA,cAAQ,EAAC,YAAY,CAAC;;;CAGhG,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,OAAgB;IAC3D,OAAO,OAAO;QACV,CAAC,CAAC,8BAA8B,IAAA,cAAQ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