@dawnlit/outlook-bridge 1.1.1 → 2.0.0

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.
Files changed (139) hide show
  1. package/README.md +150 -183
  2. package/dist/backend.d.ts +151 -0
  3. package/dist/backend.js +3 -0
  4. package/dist/backend.js.map +1 -0
  5. package/dist/bridge.d.ts +56 -0
  6. package/dist/bridge.js +507 -0
  7. package/dist/bridge.js.map +1 -0
  8. package/dist/errors.d.ts +81 -43
  9. package/dist/errors.js +98 -52
  10. package/dist/errors.js.map +1 -1
  11. package/dist/index.d.ts +10 -10
  12. package/dist/index.js +25 -52
  13. package/dist/index.js.map +1 -1
  14. package/dist/mac/accounts.d.ts +7 -2
  15. package/dist/mac/accounts.js +23 -6
  16. package/dist/mac/accounts.js.map +1 -1
  17. package/dist/mac/attachments.d.ts +5 -25
  18. package/dist/mac/attachments.js +40 -99
  19. package/dist/mac/attachments.js.map +1 -1
  20. package/dist/mac/bounces.d.ts +12 -27
  21. package/dist/mac/bounces.js +95 -112
  22. package/dist/mac/bounces.js.map +1 -1
  23. package/dist/mac/cleanup.d.ts +11 -25
  24. package/dist/mac/cleanup.js +50 -76
  25. package/dist/mac/cleanup.js.map +1 -1
  26. package/dist/mac/drafts.d.ts +13 -34
  27. package/dist/mac/drafts.js +95 -169
  28. package/dist/mac/drafts.js.map +1 -1
  29. package/dist/mac/folders.d.ts +10 -21
  30. package/dist/mac/folders.js +33 -47
  31. package/dist/mac/folders.js.map +1 -1
  32. package/dist/mac/index.d.ts +2 -22
  33. package/dist/mac/index.js +19 -81
  34. package/dist/mac/index.js.map +1 -1
  35. package/dist/mac/profile.d.ts +13 -0
  36. package/dist/mac/profile.js +149 -0
  37. package/dist/mac/profile.js.map +1 -0
  38. package/dist/mac/read.d.ts +18 -38
  39. package/dist/mac/read.js +154 -210
  40. package/dist/mac/read.js.map +1 -1
  41. package/dist/mac/run.d.ts +35 -39
  42. package/dist/mac/run.js +97 -102
  43. package/dist/mac/run.js.map +1 -1
  44. package/dist/mac/scripts.d.ts +78 -86
  45. package/dist/mac/scripts.js +125 -115
  46. package/dist/mac/scripts.js.map +1 -1
  47. package/dist/mac/send.d.ts +10 -20
  48. package/dist/mac/send.js +64 -86
  49. package/dist/mac/send.js.map +1 -1
  50. package/dist/mac/signatures.d.ts +2 -2
  51. package/dist/mac/signatures.js +9 -11
  52. package/dist/mac/signatures.js.map +1 -1
  53. package/dist/mac/templates.d.ts +14 -26
  54. package/dist/mac/templates.js +75 -113
  55. package/dist/mac/templates.js.map +1 -1
  56. package/dist/mail.d.ts +77 -45
  57. package/dist/mail.js +166 -73
  58. package/dist/mail.js.map +1 -1
  59. package/dist/runtime.d.ts +76 -43
  60. package/dist/runtime.js +103 -48
  61. package/dist/runtime.js.map +1 -1
  62. package/dist/shared/args.d.ts +48 -0
  63. package/dist/shared/args.js +216 -0
  64. package/dist/shared/args.js.map +1 -0
  65. package/dist/shared/attachmentMatch.d.ts +28 -16
  66. package/dist/shared/attachmentMatch.js +60 -22
  67. package/dist/shared/attachmentMatch.js.map +1 -1
  68. package/dist/shared/bounceReport.d.ts +11 -0
  69. package/dist/shared/bounceReport.js +45 -0
  70. package/dist/shared/bounceReport.js.map +1 -0
  71. package/dist/shared/bounceRules.d.ts +38 -10
  72. package/dist/shared/bounceRules.js +50 -32
  73. package/dist/shared/bounceRules.js.map +1 -1
  74. package/dist/shared/exec.d.ts +21 -0
  75. package/dist/shared/exec.js +47 -0
  76. package/dist/shared/exec.js.map +1 -0
  77. package/dist/shared/json.d.ts +12 -6
  78. package/dist/shared/json.js +29 -23
  79. package/dist/shared/json.js.map +1 -1
  80. package/dist/shared/locate.d.ts +39 -0
  81. package/dist/shared/locate.js +129 -0
  82. package/dist/shared/locate.js.map +1 -0
  83. package/dist/shared/replyBody.d.ts +42 -32
  84. package/dist/shared/replyBody.js +84 -71
  85. package/dist/shared/replyBody.js.map +1 -1
  86. package/dist/templateBody.d.ts +63 -0
  87. package/dist/{outlookTemplateSections.js → templateBody.js} +72 -72
  88. package/dist/templateBody.js.map +1 -0
  89. package/dist/types.d.ts +360 -167
  90. package/dist/types.js +8 -9
  91. package/dist/types.js.map +1 -1
  92. package/dist/windows/accounts.d.ts +7 -12
  93. package/dist/windows/accounts.js +19 -34
  94. package/dist/windows/accounts.js.map +1 -1
  95. package/dist/windows/attachments.d.ts +9 -24
  96. package/dist/windows/attachments.js +94 -119
  97. package/dist/windows/attachments.js.map +1 -1
  98. package/dist/windows/bounces.d.ts +13 -26
  99. package/dist/windows/bounces.js +168 -200
  100. package/dist/windows/bounces.js.map +1 -1
  101. package/dist/windows/cleanup.d.ts +19 -23
  102. package/dist/windows/cleanup.js +92 -111
  103. package/dist/windows/cleanup.js.map +1 -1
  104. package/dist/windows/drafts.d.ts +16 -35
  105. package/dist/windows/drafts.js +167 -253
  106. package/dist/windows/drafts.js.map +1 -1
  107. package/dist/windows/folders.d.ts +8 -13
  108. package/dist/windows/folders.js +44 -52
  109. package/dist/windows/folders.js.map +1 -1
  110. package/dist/windows/index.d.ts +2 -27
  111. package/dist/windows/index.js +11 -66
  112. package/dist/windows/index.js.map +1 -1
  113. package/dist/windows/read.d.ts +24 -60
  114. package/dist/windows/read.js +261 -306
  115. package/dist/windows/read.js.map +1 -1
  116. package/dist/windows/run.d.ts +39 -39
  117. package/dist/windows/run.js +151 -111
  118. package/dist/windows/run.js.map +1 -1
  119. package/dist/windows/scripts.d.ts +65 -55
  120. package/dist/windows/scripts.js +109 -85
  121. package/dist/windows/scripts.js.map +1 -1
  122. package/dist/windows/send.d.ts +6 -11
  123. package/dist/windows/send.js +68 -88
  124. package/dist/windows/send.js.map +1 -1
  125. package/dist/windows/signatures.d.ts +4 -10
  126. package/dist/windows/signatures.js +30 -37
  127. package/dist/windows/signatures.js.map +1 -1
  128. package/dist/windows/templates.d.ts +12 -18
  129. package/dist/windows/templates.js +122 -149
  130. package/dist/windows/templates.js.map +1 -1
  131. package/package.json +4 -3
  132. package/dist/OutlookService.d.ts +0 -43
  133. package/dist/OutlookService.js +0 -137
  134. package/dist/OutlookService.js.map +0 -1
  135. package/dist/outlookTemplateSections.d.ts +0 -62
  136. package/dist/outlookTemplateSections.js.map +0 -1
  137. package/dist/shared/capabilities.d.ts +0 -3
  138. package/dist/shared/capabilities.js +0 -9
  139. package/dist/shared/capabilities.js.map +0 -1
@@ -7,30 +7,31 @@ const run_1 = require("./run");
7
7
  const scripts_1 = require("./scripts");
8
8
  const json_1 = require("../shared/json");
9
9
  const mail_1 = require("../mail");
10
- /** List the folders under an account's Inbox (the user's filing folders). */
11
- async function listInboxFolders(emailAccount, maxDepth = 2) {
12
- if (process.platform !== 'win32')
13
- return [];
14
- const depth = (0, mail_1.clamp)(maxDepth, 1, 4);
15
- const script = `${(0, scripts_1.accountScript)(emailAccount)}
10
+ /** The folders under an account's Inbox, depth-first. */
11
+ async function listInboxFolders(request) {
12
+ const output = await (0, run_1.runPowerShellJson)(`${(0, scripts_1.accountScript)(request.account)}
16
13
  ${scripts_1.DELIVERY_STORE_PS}
17
- $inbox = $store.GetDefaultFolder(6)
18
- function Walk-Folders($folder, $level) {
14
+ $inbox = $store.GetDefaultFolder(${(0, run_1.psInt)(mail_1.FolderId.Inbox)})
15
+ $maxDepth = ${(0, run_1.psInt)(request.maxDepth)}
16
+ $rows = New-Object System.Collections.ArrayList
17
+ function Add-Folders($folder, [int]$level) {
19
18
  foreach ($f in $folder.Folders) {
20
- [PSCustomObject]@{
21
- name = $f.Name
22
- folderPath = $f.FolderPath
23
- itemCount = $f.Items.Count
19
+ $itemCount = 0
20
+ try { $itemCount = [int]$f.Items.Count } catch {}
21
+ [void]$rows.Add([PSCustomObject]@{
22
+ name = [string]$f.Name
23
+ folderPath = [string]$f.FolderPath
24
+ itemCount = $itemCount
24
25
  depth = $level
25
- }
26
- if ($level -lt ${depth}) { Walk-Folders $f ($level + 1) }
26
+ })
27
+ if ($level -lt $maxDepth) { Add-Folders $f ($level + 1) }
27
28
  }
28
29
  }
29
- $results = @(Walk-Folders $inbox 1)
30
- ConvertTo-Json $results -Depth 3
31
- `;
32
- return (0, json_1.parseArray)(await (0, run_1.runPowerShell)(script, 60000)).map(item => {
33
- const e = (0, json_1.record)(item);
30
+ Add-Folders $inbox 1
31
+ ConvertTo-Json -Depth 3 -InputObject @($rows)
32
+ `, 'standard');
33
+ return (0, json_1.toArray)(output).map(row => {
34
+ const e = (0, json_1.record)(row);
34
35
  return {
35
36
  name: (0, json_1.str)(e.name),
36
37
  folderPath: (0, json_1.str)(e.folderPath),
@@ -40,50 +41,41 @@ ConvertTo-Json $results -Depth 3
40
41
  });
41
42
  }
42
43
  /**
43
- * Move emails (by EntryID) into any folder of the account — a filing folder under
44
- * the Inbox, or a well-known folder by name (see WELL_KNOWN_FOLDERS).
45
- *
46
- * **Moving to "Deleted Items" is how mail gets deleted reversibly**, which is why
47
- * this takes well-known roots at all: it means the destructive path and the filing
48
- * path are one tool, and the destructive one is undoable from the folder it lands in.
49
- *
50
- * `createIfMissing` builds the WHOLE missing chain, so a nested destination
51
- * ("Clients\\Acme\\2026") is one call rather than a manual mkdir first.
52
- * NOTE: moving changes an item's EntryID — the passed ids are dead afterwards.
44
+ * File emails into a folder of the account: one under the Inbox, or a
45
+ * well-known one by name. Moving to Deleted Items is how mail is deleted
46
+ * recoverably. Moving rewrites each item's entry id, so the ids passed in are
47
+ * dead afterwards.
53
48
  */
54
- async function moveOutlookEmails(emailAccount, entryIds, folderName, createIfMissing = false) {
55
- (0, run_1.requireWindows)();
56
- if (entryIds.length === 0) {
57
- return { folderPath: '', folderCreated: false, moved: 0, failed: [] };
58
- }
59
- const ref = (0, mail_1.mailFolderRef)(folderName);
60
- const script = `${(0, scripts_1.accountScript)(emailAccount)}
49
+ async function moveOutlookEmails(request) {
50
+ const output = await (0, run_1.runPowerShellJson)(`${(0, scripts_1.accountScript)(request.account)}
61
51
  ${scripts_1.DELIVERY_STORE_PS}
62
- ${(0, scripts_1.mailScopeScript)(ref, folderName, createIfMissing)}
63
- $folder = $scope
64
- $folderCreated = $scopeCreated
52
+ ${(0, scripts_1.mailScopeScript)(request.folder, request.folderLabel, request.createIfMissing)}
65
53
  $moved = 0
66
54
  $failed = @()
67
- foreach ($id in @(${(0, run_1.psList)(entryIds)})) {
55
+ foreach ($id in ${(0, run_1.psArray)(request.entryIds)}) {
56
+ $subject = ''
68
57
  try {
69
58
  $it = $ns.GetItemFromID($id, $store.StoreID)
70
- [void]$it.Move($folder)
59
+ try { $subject = [string]$it.Subject } catch {}
60
+ [void]$it.Move($scope)
71
61
  $moved++
72
62
  } catch {
73
- $failed += [PSCustomObject]@{ entryId = $id; error = $_.Exception.Message }
63
+ $failed += [PSCustomObject]@{ entryId = $id; subject = $subject; error = $_.Exception.Message }
74
64
  }
75
65
  }
76
- ConvertTo-Json @{ folderPath = $folder.FolderPath; folderCreated = $folderCreated; moved = $moved; failed = @($failed) } -Depth 3
77
- `;
78
- const parsed = (0, json_1.parseObject)(await (0, run_1.runPowerShell)(script, 300000));
66
+ ConvertTo-Json -Depth 3 -InputObject ([PSCustomObject]@{
67
+ folderPath = [string]$scope.FolderPath
68
+ folderCreated = $scopeCreated
69
+ moved = $moved
70
+ failed = @($failed)
71
+ })
72
+ `, 'scan');
73
+ const e = (0, json_1.record)(output);
79
74
  return {
80
- folderPath: (0, json_1.str)(parsed.folderPath),
81
- folderCreated: Boolean(parsed.folderCreated),
82
- moved: (0, json_1.num)(parsed.moved),
83
- failed: (0, json_1.toArray)(parsed.failed).map(f => {
84
- const e = (0, json_1.record)(f);
85
- return { entryId: (0, json_1.str)(e.entryId), error: (0, json_1.str)(e.error) };
86
- }),
75
+ folderPath: (0, json_1.str)(e.folderPath),
76
+ folderCreated: (0, json_1.bool)(e.folderCreated),
77
+ moved: (0, json_1.num)(e.moved),
78
+ failed: (0, json_1.itemFailures)(e.failed),
87
79
  };
88
80
  }
89
81
  //# sourceMappingURL=folders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"folders.js","source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a,EAAE,IAAA,WAAI,EAAC,CAAC,CAAC,aAAa,CAAC;QACpC,KAAK,EAAE,IAAA,UAAG,EAAC,CAAC,CAAC,KAAK,CAAC;QACnB,MAAM,EAAE,IAAA,mBAAY,EAAC,CAAC,CAAC,MAAM,CAAC;KACjC,CAAC;AACN,CAAC","sourcesContent":["// Listing the folders under an Inbox, and filing mail into one.\nimport { psArray, psInt, runPowerShellJson } from './run';\nimport { accountScript, DELIVERY_STORE_PS, mailScopeScript } from './scripts';\nimport { bool, itemFailures, num, record, str, toArray } from '../shared/json';\nimport { FolderId } from '../mail';\nimport type { ListFoldersRequest, MoveRequest } from '../backend';\nimport type { InboxFolderInfo, MoveEmailsResult } from '../types';\n\n/** The folders under an account's Inbox, depth-first. */\nexport async function listInboxFolders(request: ListFoldersRequest): Promise<InboxFolderInfo[]> {\n const output = await runPowerShellJson(`${accountScript(request.account)}\n${DELIVERY_STORE_PS}\n$inbox = $store.GetDefaultFolder(${psInt(FolderId.Inbox)})\n$maxDepth = ${psInt(request.maxDepth)}\n$rows = New-Object System.Collections.ArrayList\nfunction Add-Folders($folder, [int]$level) {\n foreach ($f in $folder.Folders) {\n $itemCount = 0\n try { $itemCount = [int]$f.Items.Count } catch {}\n [void]$rows.Add([PSCustomObject]@{\n name = [string]$f.Name\n folderPath = [string]$f.FolderPath\n itemCount = $itemCount\n depth = $level\n })\n if ($level -lt $maxDepth) { Add-Folders $f ($level + 1) }\n }\n}\nAdd-Folders $inbox 1\nConvertTo-Json -Depth 3 -InputObject @($rows)\n`, 'standard');\n return toArray(output).map(row => {\n const e = record(row);\n return {\n name: str(e.name),\n folderPath: str(e.folderPath),\n itemCount: num(e.itemCount),\n depth: num(e.depth) || 1,\n };\n });\n}\n\n/**\n * File emails into a folder of the account: one under the Inbox, or a\n * well-known one by name. Moving to Deleted Items is how mail is deleted\n * recoverably. Moving rewrites each item's entry id, so the ids passed in are\n * dead afterwards.\n */\nexport async function moveOutlookEmails(request: MoveRequest): Promise<MoveEmailsResult> {\n const output = await runPowerShellJson(`${accountScript(request.account)}\n${DELIVERY_STORE_PS}\n${mailScopeScript(request.folder, request.folderLabel, request.createIfMissing)}\n$moved = 0\n$failed = @()\nforeach ($id in ${psArray(request.entryIds)}) {\n $subject = ''\n try {\n $it = $ns.GetItemFromID($id, $store.StoreID)\n try { $subject = [string]$it.Subject } catch {}\n [void]$it.Move($scope)\n $moved++\n } catch {\n $failed += [PSCustomObject]@{ entryId = $id; subject = $subject; error = $_.Exception.Message }\n }\n}\nConvertTo-Json -Depth 3 -InputObject ([PSCustomObject]@{\n folderPath = [string]$scope.FolderPath\n folderCreated = $scopeCreated\n moved = $moved\n failed = @($failed)\n})\n`, 'scan');\n const e = record(output);\n return {\n folderPath: str(e.folderPath),\n folderCreated: bool(e.folderCreated),\n moved: num(e.moved),\n failed: itemFailures(e.failed),\n };\n}\n"]}
@@ -1,27 +1,2 @@
1
- import type { CapabilityMap, OutlookBridge } from '../types';
2
- /**
3
- * The whole contract in one object — and the compile-time proof that this
4
- * module answers all of it.
5
- *
6
- * Typed as `OutlookBridge` rather than inferred: without that a signature could
7
- * drift from the macOS one and only surface as a union in the published .d.ts,
8
- * which is exactly how it drifted before.
9
- */
10
- declare const bridge: OutlookBridge;
11
- export { bridge };
12
- export * from './accounts';
13
- export * from './send';
14
- export * from './drafts';
15
- export * from './read';
16
- export * from './folders';
17
- export * from './cleanup';
18
- export * from './bounces';
19
- export * from './attachments';
20
- export * from './signatures';
21
- export * from './templates';
22
- export { accountScript, mailScopeScript } from './scripts';
23
- /**
24
- * Windows drives the full COM object model, so every operation is available —
25
- * this is the reference the macOS map is measured against.
26
- */
27
- export declare const capabilities: CapabilityMap;
1
+ import type { Backend } from '../backend';
2
+ export declare const windowsBackend: Backend;
@@ -1,54 +1,26 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.capabilities = exports.mailScopeScript = exports.accountScript = exports.bridge = void 0;
18
- // The Windows implementation: Outlook driven through PowerShell + COM.
19
- //
20
- // Split by feature rather than kept as one file — every operation here is
21
- // "generate a script, run it, coerce the result", and the interesting part of
22
- // each is the script, which is only readable next to the rules it encodes.
23
- // `scripts.ts` holds the fragments more than one feature emits; `run.ts` owns
24
- // the run itself and the escaping.
3
+ exports.windowsBackend = void 0;
4
+ // The Windows backend: Outlook driven through PowerShell and its COM object model.
25
5
  //
26
- // This is the reference implementation: everything in the platform contract
27
- // works here, which is what the macOS capability map is measured against.
6
+ // Split by feature, since every operation is "generate a script, run it, read
7
+ // its output" and the interesting part of each is the script, which reads best
8
+ // beside the rules it encodes. `run.ts` owns running and escaping; `scripts.ts`
9
+ // holds the fragments several features emit.
28
10
  const accounts_1 = require("./accounts");
29
11
  const send_1 = require("./send");
30
- const drafts_1 = require("./drafts");
31
12
  const read_1 = require("./read");
32
13
  const folders_1 = require("./folders");
14
+ const drafts_1 = require("./drafts");
33
15
  const cleanup_1 = require("./cleanup");
34
- const bounces_1 = require("./bounces");
35
16
  const attachments_1 = require("./attachments");
17
+ const bounces_1 = require("./bounces");
36
18
  const signatures_1 = require("./signatures");
37
19
  const templates_1 = require("./templates");
38
- const capabilities_1 = require("../shared/capabilities");
39
- /**
40
- * The whole contract in one object — and the compile-time proof that this
41
- * module answers all of it.
42
- *
43
- * Typed as `OutlookBridge` rather than inferred: without that a signature could
44
- * drift from the macOS one and only surface as a union in the published .d.ts,
45
- * which is exactly how it drifted before.
46
- */
47
- const bridge = {
20
+ exports.windowsBackend = {
48
21
  getOutlookAccounts: accounts_1.getOutlookAccounts,
49
22
  sendOutlookEmail: send_1.sendOutlookEmail,
50
23
  replyOutlookEmail: send_1.replyOutlookEmail,
51
- sendAllDrafts: drafts_1.sendAllDrafts,
52
24
  readInboxEmails: read_1.readInboxEmails,
53
25
  searchInboxByFilter: read_1.searchInboxByFilter,
54
26
  readSelectedEmail: read_1.readSelectedEmail,
@@ -57,12 +29,11 @@ const bridge = {
57
29
  listInboxFolders: folders_1.listInboxFolders,
58
30
  moveOutlookEmails: folders_1.moveOutlookEmails,
59
31
  listOutlookDrafts: drafts_1.listOutlookDrafts,
60
- deleteOutlookDrafts: drafts_1.deleteOutlookDrafts,
61
32
  sendDrafts: drafts_1.sendDrafts,
33
+ sendAllDrafts: drafts_1.sendAllDrafts,
34
+ deleteOutlookDrafts: drafts_1.deleteOutlookDrafts,
62
35
  deleteOutlookEmails: cleanup_1.deleteOutlookEmails,
63
36
  purgeDeletedItems: cleanup_1.purgeDeletedItems,
64
- saveEmailAttachment: attachments_1.saveEmailAttachment,
65
- saveEmailAttachmentDetailed: attachments_1.saveEmailAttachmentDetailed,
66
37
  saveEmailAttachments: attachments_1.saveEmailAttachments,
67
38
  cleanUndeliverableEmails: bounces_1.cleanUndeliverableEmails,
68
39
  collectBouncedRecipients: bounces_1.collectBouncedRecipients,
@@ -73,30 +44,4 @@ const bridge = {
73
44
  saveTemplateEmail: templates_1.saveTemplateEmail,
74
45
  editEmailTemplate: templates_1.editEmailTemplate,
75
46
  };
76
- exports.bridge = bridge;
77
- // Re-exported one module at a time rather than by name: every feature module
78
- // here exports exactly its bridge functions and nothing else, so the name list
79
- // this replaces was a copy of the `bridge` literal above with no way to drift
80
- // from it usefully.
81
- __exportStar(require("./accounts"), exports);
82
- __exportStar(require("./send"), exports);
83
- __exportStar(require("./drafts"), exports);
84
- __exportStar(require("./read"), exports);
85
- __exportStar(require("./folders"), exports);
86
- __exportStar(require("./cleanup"), exports);
87
- __exportStar(require("./bounces"), exports);
88
- __exportStar(require("./attachments"), exports);
89
- __exportStar(require("./signatures"), exports);
90
- __exportStar(require("./templates"), exports);
91
- // The folder-scope emitter, exported so the generated script can be checked
92
- // without an Outlook session — a syntax error in it would otherwise only ever
93
- // surface as a failed live run.
94
- var scripts_1 = require("./scripts");
95
- Object.defineProperty(exports, "accountScript", { enumerable: true, get: function () { return scripts_1.accountScript; } });
96
- Object.defineProperty(exports, "mailScopeScript", { enumerable: true, get: function () { return scripts_1.mailScopeScript; } });
97
- /**
98
- * Windows drives the full COM object model, so every operation is available —
99
- * this is the reference the macOS map is measured against.
100
- */
101
- exports.capabilities = (0, capabilities_1.capabilityMap)(bridge);
102
47
  //# sourceMappingURL=index.js.map
@@ -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,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,u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ACrD,uCAAwG;AACxG,6CAA+E;AAC/E,2CAAuF;AAG1E,QAAA,cAAc,GAAY;IACnC,kBAAkB,EAAlB,6BAAkB;IAClB,gBAAgB,EAAhB,uBAAgB;IAChB,iBAAiB,EAAjB,wBAAiB;IACjB,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,UAAU,EAAV,mBAAU;IACV,aAAa,EAAb,sBAAa;IACb,mBAAmB,EAAnB,4BAAmB;IACnB,mBAAmB,EAAnB,6BAAmB;IACnB,iBAAiB,EAAjB,2BAAiB;IACjB,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","sourcesContent":["// The Windows backend: Outlook driven through PowerShell and its COM object model.\n//\n// Split by feature, since every operation is \"generate a script, run it, read\n// its output\" and the interesting part of each is the script, which reads best\n// beside the rules it encodes. `run.ts` owns running and escaping; `scripts.ts`\n// holds the fragments several features emit.\nimport { getOutlookAccounts } from './accounts';\nimport { replyOutlookEmail, sendOutlookEmail } from './send';\nimport { openOutlookEmail, readEmailBody, readInboxEmails, readSelectedEmail, searchInboxByFilter } from './read';\nimport { listInboxFolders, moveOutlookEmails } from './folders';\nimport { deleteOutlookDrafts, listOutlookDrafts, sendAllDrafts, sendDrafts } from './drafts';\nimport { deleteOutlookEmails, purgeDeletedItems } from './cleanup';\nimport { saveEmailAttachments } from './attachments';\nimport { cleanUndeliverableEmails, collectBouncedRecipients, readSentRecipientGroups } from './bounces';\nimport { listOutlookSignatures, readOutlookSignatureHtml } from './signatures';\nimport { editEmailTemplate, readTemplateEmails, saveTemplateEmail } from './templates';\nimport type { Backend } from '../backend';\n\nexport const windowsBackend: Backend = {\n getOutlookAccounts,\n sendOutlookEmail,\n replyOutlookEmail,\n readInboxEmails,\n searchInboxByFilter,\n readSelectedEmail,\n readEmailBody,\n openOutlookEmail,\n listInboxFolders,\n moveOutlookEmails,\n listOutlookDrafts,\n sendDrafts,\n sendAllDrafts,\n deleteOutlookDrafts,\n deleteOutlookEmails,\n purgeDeletedItems,\n saveEmailAttachments,\n cleanUndeliverableEmails,\n collectBouncedRecipients,\n readSentRecipientGroups,\n listOutlookSignatures,\n readOutlookSignatureHtml,\n readTemplateEmails,\n saveTemplateEmail,\n editEmailTemplate,\n};\n"]}
@@ -1,69 +1,33 @@
1
- import type { EmailBodyResult, InboxEmail, InboxSearchFilter, InboxSearchMatch, SelectedEmail } from '../types';
1
+ import type { RawEmail, ReadInboxRequest, SearchRequest } from '../backend';
2
+ import type { EmailLocator, InboxEmail, InboxSearchMatch, SelectedEmail } from '../types';
3
+ /** Recent mail from the Inbox root or one folder, newest first. */
4
+ export declare function readInboxEmails(request: ReadInboxRequest): Promise<InboxEmail[]>;
2
5
  /**
3
- * Read recent emails from the Outlook inbox for the given account.
4
- * No subject filtering — returns everything within the date window, up to the limit.
5
- * Does NOT download attachments; returns attachment names only.
6
+ * One email's full plain-text body, by id.
6
7
  *
7
- * `folder` scopes the read to one folder under the Inbox instead of the Inbox
8
- * root. Without it, mail already filed away (Inbox\\Invoices) is unreachable —
9
- * which is the normal state of any mailbox its owner keeps tidy. Segments are
10
- * matched as direct children; a bare name that isn't a direct child falls back to
11
- * the same recursive by-name search moveOutlookEmails uses, so one folder string
12
- * works in both. Only the named folder is read — its own subfolders are not.
8
+ * `Body`, not `HTMLBody`: Outlook's own plain-text rendering is what every other
9
+ * reader here consumes, and markup costs an order of magnitude more for the same
10
+ * sentences. The tradeoff is that an HTML table's rows flatten.
13
11
  */
14
- export declare function readInboxEmails(emailAccount: string, daysBack?: number, limit?: number, folder?: string): Promise<InboxEmail[]>;
12
+ export declare function readEmailBody(email: EmailLocator): Promise<RawEmail>;
15
13
  /**
16
- * Read one email's full plain-text body by EntryID.
17
- *
18
- * Uses `MailItem.Body`, not `HTMLBody`: Outlook's own plain-text rendering is
19
- * what every other reader here consumes, and the markup costs an order of
20
- * magnitude more for the same sentences. The tradeoff is that HTML tables
21
- * flatten, so figures broken out in a table lose their row/column pairing — read
22
- * those from the attachment where there is one.
23
- *
24
- * Exists because `readInboxEmails` caps its preview at 600 chars, and a reply
25
- * whose first 600 chars read as complete can still carry a material detail below
26
- * the cut. Nothing detects that from the preview alone.
27
- *
28
- * `includeQuoted` is off by default — see splitQuotedOriginal for why the
29
- * quoted thread is a hazard to a caller reading figures out of a reply.
30
- * `quotedLength` is reported either way so a caller can tell it exists and ask again.
31
- */
32
- export declare function readEmailBody(entryId: string, storeId?: string, maxChars?: number, includeQuoted?: boolean): Promise<EmailBodyResult>;
33
- /**
34
- * Walk every folder under the Inbox (recursively) for one account and return
35
- * the emails matching `filter` — full body included, attachments listed by
36
- * name but not saved.
37
- *
38
- * Built for a scan that doesn't know in advance which subfolder holds what
39
- * it's after; `readInboxEmails` covers the cheaper "one known folder" case.
40
- *
41
- * `daysBack` bounds the scan to items received within that many days — what a
42
- * daily batch run wants, since a subject filter alone walks the whole Inbox
43
- * tree and returns every match ever received. 0 keeps that unbounded
44
- * behavior, and is only sane paired with `filter.subjectLike` so Restrict can
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.
49
- */
50
- export declare function searchInboxByFilter(emailAccount: string, filter?: InboxSearchFilter, daysBack?: number): Promise<InboxSearchMatch[]>;
51
- /**
52
- * Read the email currently selected (or open) in Outlook — full body,
53
- * attachments listed by name but not saved.
14
+ * Walk every folder under the Inbox for the mail matching the request.
15
+ *
16
+ * The window is enforced twice — a date Restrict per folder, then a per-item
17
+ * check — because Restrict is not reliable across stores, and a scan that
18
+ * silently widens on some mailboxes is the failure this guards against.
19
+ * `subjectLike` also drives a server-side prefilter, purely as an optimization:
20
+ * every subject is re-checked, so a store that can't run the query (IMAP stores
21
+ * accept it and match nothing) returns the same set, only slower.
54
22
  */
23
+ export declare function searchInboxByFilter(request: SearchRequest): Promise<InboxSearchMatch[]>;
24
+ /** The email currently selected — or open — in Outlook. */
55
25
  export declare function readSelectedEmail(): Promise<SelectedEmail>;
56
26
  /**
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.
27
+ * Open an email in Outlook.
63
28
  *
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.
29
+ * Entry ids are rewritten when an item MOVES between folders, so an id recorded
30
+ * before its mail was filed can stop resolving. That fails as NOT_FOUND rather
31
+ * than guessing — the caller is the one who knows what the email was.
68
32
  */
69
- export declare function openOutlookEmail(entryId: string, storeId?: string): Promise<void>;
33
+ export declare function openOutlookEmail(email: EmailLocator): Promise<void>;