@dawnlit/outlook-bridge 1.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 (117) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +253 -0
  3. package/dist/OutlookService.d.ts +43 -0
  4. package/dist/OutlookService.js +137 -0
  5. package/dist/OutlookService.js.map +1 -0
  6. package/dist/errors.d.ts +112 -0
  7. package/dist/errors.js +140 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.js +71 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/mac/accounts.d.ts +5 -0
  13. package/dist/mac/accounts.js +17 -0
  14. package/dist/mac/accounts.js.map +1 -0
  15. package/dist/mac/attachments.d.ts +28 -0
  16. package/dist/mac/attachments.js +120 -0
  17. package/dist/mac/attachments.js.map +1 -0
  18. package/dist/mac/bounces.d.ts +32 -0
  19. package/dist/mac/bounces.js +285 -0
  20. package/dist/mac/bounces.js.map +1 -0
  21. package/dist/mac/cleanup.d.ts +29 -0
  22. package/dist/mac/cleanup.js +219 -0
  23. package/dist/mac/cleanup.js.map +1 -0
  24. package/dist/mac/drafts.d.ts +27 -0
  25. package/dist/mac/drafts.js +214 -0
  26. package/dist/mac/drafts.js.map +1 -0
  27. package/dist/mac/folders.d.ts +28 -0
  28. package/dist/mac/folders.js +127 -0
  29. package/dist/mac/folders.js.map +1 -0
  30. package/dist/mac/index.d.ts +22 -0
  31. package/dist/mac/index.js +119 -0
  32. package/dist/mac/index.js.map +1 -0
  33. package/dist/mac/read.d.ts +46 -0
  34. package/dist/mac/read.js +406 -0
  35. package/dist/mac/read.js.map +1 -0
  36. package/dist/mac/run.d.ts +64 -0
  37. package/dist/mac/run.js +250 -0
  38. package/dist/mac/run.js.map +1 -0
  39. package/dist/mac/scripts.d.ts +137 -0
  40. package/dist/mac/scripts.js +337 -0
  41. package/dist/mac/scripts.js.map +1 -0
  42. package/dist/mac/send.d.ts +23 -0
  43. package/dist/mac/send.js +135 -0
  44. package/dist/mac/send.js.map +1 -0
  45. package/dist/mac/signatures.d.ts +4 -0
  46. package/dist/mac/signatures.js +36 -0
  47. package/dist/mac/signatures.js.map +1 -0
  48. package/dist/mac/templates.d.ts +34 -0
  49. package/dist/mac/templates.js +266 -0
  50. package/dist/mac/templates.js.map +1 -0
  51. package/dist/mail.d.ts +72 -0
  52. package/dist/mail.js +131 -0
  53. package/dist/mail.js.map +1 -0
  54. package/dist/outlookTemplateSections.d.ts +62 -0
  55. package/dist/outlookTemplateSections.js +313 -0
  56. package/dist/outlookTemplateSections.js.map +1 -0
  57. package/dist/runtime.d.ts +76 -0
  58. package/dist/runtime.js +123 -0
  59. package/dist/runtime.js.map +1 -0
  60. package/dist/shared/attachmentMatch.d.ts +32 -0
  61. package/dist/shared/attachmentMatch.js +50 -0
  62. package/dist/shared/attachmentMatch.js.map +1 -0
  63. package/dist/shared/bounceRules.d.ts +33 -0
  64. package/dist/shared/bounceRules.js +104 -0
  65. package/dist/shared/bounceRules.js.map +1 -0
  66. package/dist/shared/capabilities.d.ts +3 -0
  67. package/dist/shared/capabilities.js +9 -0
  68. package/dist/shared/capabilities.js.map +1 -0
  69. package/dist/shared/json.d.ts +11 -0
  70. package/dist/shared/json.js +45 -0
  71. package/dist/shared/json.js.map +1 -0
  72. package/dist/shared/replyBody.d.ts +49 -0
  73. package/dist/shared/replyBody.js +113 -0
  74. package/dist/shared/replyBody.js.map +1 -0
  75. package/dist/types.d.ts +365 -0
  76. package/dist/types.js +13 -0
  77. package/dist/types.js.map +1 -0
  78. package/dist/windows/accounts.d.ts +2 -0
  79. package/dist/windows/accounts.js +22 -0
  80. package/dist/windows/accounts.js.map +1 -0
  81. package/dist/windows/attachments.d.ts +28 -0
  82. package/dist/windows/attachments.js +141 -0
  83. package/dist/windows/attachments.js.map +1 -0
  84. package/dist/windows/bounces.d.ts +34 -0
  85. package/dist/windows/bounces.js +267 -0
  86. package/dist/windows/bounces.js.map +1 -0
  87. package/dist/windows/cleanup.d.ts +29 -0
  88. package/dist/windows/cleanup.js +165 -0
  89. package/dist/windows/cleanup.js.map +1 -0
  90. package/dist/windows/drafts.d.ts +29 -0
  91. package/dist/windows/drafts.js +253 -0
  92. package/dist/windows/drafts.js.map +1 -0
  93. package/dist/windows/folders.d.ts +16 -0
  94. package/dist/windows/folders.js +88 -0
  95. package/dist/windows/folders.js.map +1 -0
  96. package/dist/windows/index.d.ts +27 -0
  97. package/dist/windows/index.js +100 -0
  98. package/dist/windows/index.js.map +1 -0
  99. package/dist/windows/read.d.ts +54 -0
  100. package/dist/windows/read.js +372 -0
  101. package/dist/windows/read.js.map +1 -0
  102. package/dist/windows/run.d.ts +54 -0
  103. package/dist/windows/run.js +161 -0
  104. package/dist/windows/run.js.map +1 -0
  105. package/dist/windows/scripts.d.ts +56 -0
  106. package/dist/windows/scripts.js +163 -0
  107. package/dist/windows/scripts.js.map +1 -0
  108. package/dist/windows/send.d.ts +11 -0
  109. package/dist/windows/send.js +114 -0
  110. package/dist/windows/send.js.map +1 -0
  111. package/dist/windows/signatures.d.ts +14 -0
  112. package/dist/windows/signatures.js +69 -0
  113. package/dist/windows/signatures.js.map +1 -0
  114. package/dist/windows/templates.d.ts +25 -0
  115. package/dist/windows/templates.js +246 -0
  116. package/dist/windows/templates.js.map +1 -0
  117. package/package.json +50 -0
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listOutlookDrafts = listOutlookDrafts;
4
+ exports.sendAllDrafts = sendAllDrafts;
5
+ exports.deleteOutlookDrafts = deleteOutlookDrafts;
6
+ // Drafts: which ones belong to an account, and sending, listing or deleting them.
7
+ //
8
+ // Where Windows has to scan two Drafts folders and prove each item's
9
+ // SendUsingAccount, macOS asks the account for its own Drafts folder directly —
10
+ // `drafts of targetAcct` is already account-scoped, so a draft found there
11
+ // belongs to this account by construction. That is the same rule the Windows
12
+ // scan reaches by a longer route, not a weaker one.
13
+ const run_1 = require("./run");
14
+ const scripts_1 = require("./scripts");
15
+ /** The Drafts folder path this account's drafts are reported under. */
16
+ function draftsPath(emailAccount) {
17
+ return (0, scripts_1.macFolderPath)(emailAccount, 'Drafts', []);
18
+ }
19
+ /**
20
+ * List the mail drafts belonging to `emailAccount`, newest first.
21
+ *
22
+ * Bodies are previewed, never returned whole — a templated reply body runs to
23
+ * tens of thousands of characters and a folder's worth would blow the cap.
24
+ */
25
+ async function listOutlookDrafts(emailAccount, limit = 100, previewChars = 300) {
26
+ const cap = Math.max(1, Math.floor(limit));
27
+ const preview = Math.max(1, Math.floor(previewChars));
28
+ const script = `tell application "Microsoft Outlook"
29
+ ${(0, scripts_1.accountLookupSnippet)(emailAccount)}
30
+ set draftsFolder to drafts of targetAcct
31
+ set out to ""
32
+ repeat with theMsg in (messages of draftsFolder)
33
+ set subj to ""
34
+ try
35
+ set subj to (subject of theMsg) as string
36
+ end try
37
+ set toNames to {}
38
+ set toAddrs to {}
39
+ try
40
+ repeat with r in (every to recipient of theMsg)
41
+ try
42
+ set ea to email address of r
43
+ set oneAddr to ""
44
+ set oneName to ""
45
+ try
46
+ set oneAddr to (address of ea) as string
47
+ end try
48
+ try
49
+ set oneName to (name of ea) as string
50
+ end try
51
+ if oneName is "" then set oneName to oneAddr
52
+ if oneName is not "" then set end of toNames to oneName
53
+ if oneAddr is not "" then set end of toAddrs to oneAddr
54
+ end try
55
+ end repeat
56
+ end try
57
+ set bodyText to ""
58
+ try
59
+ set bodyText to (plain text content of theMsg) as string
60
+ end try
61
+ if (length of bodyText) > ${preview} then set bodyText to text 1 thru ${preview} of bodyText
62
+ set attCount to 0
63
+ try
64
+ set attCount to count of attachments of theMsg
65
+ end try
66
+ set modAt to ""
67
+ try
68
+ set modAt to my isoDate(modification date of theMsg)
69
+ end try
70
+ set out to out & ${(0, run_1.asRow)([
71
+ '(id of theMsg as string)',
72
+ 'subj',
73
+ 'my joinList(toNames, ", ")',
74
+ 'my sanitizeList(toAddrs)',
75
+ 'bodyText',
76
+ '(attCount as string)',
77
+ 'modAt',
78
+ ])}
79
+ end repeat
80
+ return out
81
+ end tell`;
82
+ // One string for every row, rather than rebuilt per draft.
83
+ const folderPath = draftsPath(emailAccount);
84
+ const drafts = (0, run_1.splitRecords)(await (0, run_1.runOsaScript)(script, 120000)).map(record => {
85
+ const parts = (0, run_1.splitFields)(record);
86
+ return {
87
+ entryId: (0, run_1.field)(parts, 0),
88
+ subject: (0, run_1.field)(parts, 1),
89
+ to: (0, run_1.field)(parts, 2),
90
+ toEmails: (0, run_1.splitList)((0, run_1.field)(parts, 3)),
91
+ bodyPreview: (0, run_1.field)(parts, 4).replace(/\s+/g, ' ').trim(),
92
+ hasAttachments: (0, run_1.intField)(parts, 5) > 0,
93
+ lastModified: (0, run_1.field)(parts, 6),
94
+ folderPath,
95
+ };
96
+ });
97
+ // 'yyyy-MM-dd HH:mm' is lexicographically ordered, so a string compare sorts it.
98
+ drafts.sort((a, b) => b.lastModified.localeCompare(a.lastModified));
99
+ return {
100
+ account: emailAccount,
101
+ foldersScanned: [folderPath],
102
+ count: drafts.length,
103
+ truncated: drafts.length > cap,
104
+ drafts: drafts.slice(0, cap),
105
+ };
106
+ }
107
+ /**
108
+ * Send the mail drafts that belong to `emailAccount`.
109
+ *
110
+ * The ids are snapshotted before the first send: sending moves an item out of
111
+ * Drafts, and mutating the collection mid-enumeration would skip every other one
112
+ * — the same trap the Windows implementation avoids by snapshotting item refs.
113
+ */
114
+ async function sendAllDrafts(emailAccount) {
115
+ const script = `tell application "Microsoft Outlook"
116
+ ${(0, scripts_1.accountLookupSnippet)(emailAccount)}
117
+ set draftsFolder to drafts of targetAcct
118
+ set wanted to id of every message of draftsFolder
119
+ set sentCount to 0
120
+ set out to ""
121
+ repeat with theId in wanted
122
+ set subj to ""
123
+ try
124
+ set theMsg to missing value
125
+ try
126
+ set theMsg to message id theId
127
+ end try
128
+ if theMsg is missing value then error "draft is no longer in the Drafts folder"
129
+ try
130
+ set subj to (subject of theMsg) as string
131
+ end try
132
+ send theMsg
133
+ set sentCount to sentCount + 1
134
+ on error errText
135
+ set out to out & ${(0, run_1.asRow)(['subj', 'errText'])}
136
+ end try
137
+ end repeat
138
+ return ${(0, run_1.asRow)(['(sentCount as string)'])} & out
139
+ end tell`;
140
+ const records = (0, run_1.splitRecords)(await (0, run_1.runOsaScript)(script, 300000));
141
+ return {
142
+ sent: (0, run_1.intField)((0, run_1.splitFields)(records[0] || ''), 0),
143
+ failed: records.slice(1).map(record => {
144
+ const parts = (0, run_1.splitFields)(record);
145
+ return { subject: (0, run_1.field)(parts, 0), error: (0, run_1.field)(parts, 1) };
146
+ }),
147
+ };
148
+ }
149
+ /**
150
+ * Delete mail drafts by message id. `delete` files the item in Deleted Items
151
+ * rather than destroying it, so a mistaken call stays recoverable from there —
152
+ * matching the Windows contract.
153
+ *
154
+ * Every id must resolve to a message sitting in THIS account's Drafts folder
155
+ * before anything is deleted; an id pointing at ordinary mail, or at another
156
+ * account's draft, is refused and reported. Without that gate this would be a
157
+ * general-purpose "delete any email by id" tool, which is not what it is for.
158
+ */
159
+ async function deleteOutlookDrafts(emailAccount, entryIds) {
160
+ if (entryIds.length === 0)
161
+ return { deleted: 0, failed: [] };
162
+ const { valid, invalid } = (0, scripts_1.partitionMessageIds)(entryIds);
163
+ if (valid.length === 0)
164
+ return { deleted: 0, failed: invalid };
165
+ const script = `tell application "Microsoft Outlook"
166
+ ${(0, scripts_1.accountLookupSnippet)(emailAccount)}
167
+ set draftsFolder to drafts of targetAcct
168
+ set draftsName to (name of draftsFolder) as string
169
+ set draftIds to id of every message of draftsFolder
170
+ set deletedCount to 0
171
+ set out to ""
172
+ repeat with theId in {${valid.join(', ')}}
173
+ try
174
+ set theMsg to missing value
175
+ try
176
+ set theMsg to message id theId
177
+ end try
178
+ if theMsg is missing value then error "no such item in this account's Drafts folder"
179
+ -- Prove it is in THIS account's Drafts before deleting: the folder it
180
+ -- currently sits in, and the account it is bound to, must both match.
181
+ set inFolder to ""
182
+ try
183
+ set inFolder to (name of (folder of theMsg)) as string
184
+ end try
185
+ if inFolder is not draftsName then error "item is not in this account's Drafts folder - refusing to delete"
186
+ if draftIds does not contain (id of theMsg) then error "item is not in this account's Drafts folder - refusing to delete"
187
+ set boundTo to ""
188
+ try
189
+ set boundTo to (email address of (account of theMsg)) as string
190
+ end try
191
+ if boundTo is not "" and boundTo is not (email address of targetAcct) then
192
+ error "draft is not bound to this account - refusing to delete"
193
+ end if
194
+ delete theMsg
195
+ set deletedCount to deletedCount + 1
196
+ on error errText
197
+ set out to out & ${(0, run_1.asRow)(['(theId as string)', 'errText'])}
198
+ end try
199
+ end repeat
200
+ return ${(0, run_1.asRow)(['(deletedCount as string)'])} & out
201
+ end tell`;
202
+ const records = (0, run_1.splitRecords)(await (0, run_1.runOsaScript)(script, 300000));
203
+ return {
204
+ deleted: (0, run_1.intField)((0, run_1.splitFields)(records[0] || ''), 0),
205
+ failed: [
206
+ ...invalid,
207
+ ...records.slice(1).map(record => {
208
+ const parts = (0, run_1.splitFields)(record);
209
+ return { entryId: (0, run_1.field)(parts, 0), error: (0, run_1.field)(parts, 1) };
210
+ }),
211
+ ],
212
+ };
213
+ }
214
+ //# sourceMappingURL=drafts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drafts.js","sourceRoot":"","sources":["../../src/mac/drafts.ts"],"names":[],"mappings":";;AAsBA,8CAsFC;AASD,sCAmCC;AAYD,kDAwDC;AA5ND,kFAAkF;AAClF,EAAE;AACF,qEAAqE;AACrE,gFAAgF;AAChF,2EAA2E;AAC3E,6EAA6E;AAC7E,oDAAoD;AACpD,+BAAoG;AACpG,uCAAqF;AAGrF,uEAAuE;AACvE,SAAS,UAAU,CAAC,YAAoB;IACpC,OAAO,IAAA,uBAAa,EAAC,YAAY,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACnC,YAAoB,EACpB,KAAK,GA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;gBAClC,OAAO,EAAE,OAAO,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;YAChE,CAAC,CAAC;SACL;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { InboxFolderInfo, MoveEmailsResult } from '../types';
2
+ /**
3
+ * List the folders under an account's Inbox with their item counts.
4
+ *
5
+ * The recursive walk joins path segments with the LIST separator rather than a
6
+ * backslash: a literal backslash would have to survive a JS template literal and
7
+ * then an AppleScript string literal, and the `folderPath` shape is assembled in
8
+ * TypeScript anyway (see macFolderPath).
9
+ */
10
+ export declare function listInboxFolders(emailAccount: string, maxDepth?: number): Promise<InboxFolderInfo[]>;
11
+ /**
12
+ * Move emails (by message id) into any folder of the account — a filing folder
13
+ * under the Inbox, or a well-known folder by name (see WELL_KNOWN_FOLDERS).
14
+ *
15
+ * **Moving to "Deleted Items" is how mail gets deleted reversibly**, which is why
16
+ * this takes well-known roots at all: it means the destructive path and the filing
17
+ * path are one tool, and the destructive one is undoable from the folder it lands in.
18
+ *
19
+ * `createIfMissing` builds the WHOLE missing chain, so a nested destination
20
+ * ("Clients\\Acme\\2026") is one call rather than a manual mkdir first.
21
+ * NOTE: moving changes a message's id — the passed ids are dead afterwards.
22
+ *
23
+ * Outlook for Mac's `move` reports success even where it silently does nothing,
24
+ * so the destination's message count is compared before and after. A run where
25
+ * every move "succeeded" and yet the folder never grew fails loudly instead of
26
+ * reporting mail that was never filed.
27
+ */
28
+ export declare function moveOutlookEmails(emailAccount: string, entryIds: string[], folderName: string, createIfMissing?: boolean): Promise<MoveEmailsResult>;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listInboxFolders = listInboxFolders;
4
+ exports.moveOutlookEmails = moveOutlookEmails;
5
+ // Listing the folders under an Inbox, and filing mail into one.
6
+ const run_1 = require("./run");
7
+ const scripts_1 = require("./scripts");
8
+ const mail_1 = require("../mail");
9
+ /**
10
+ * List the folders under an account's Inbox with their item counts.
11
+ *
12
+ * The recursive walk joins path segments with the LIST separator rather than a
13
+ * backslash: a literal backslash would have to survive a JS template literal and
14
+ * then an AppleScript string literal, and the `folderPath` shape is assembled in
15
+ * TypeScript anyway (see macFolderPath).
16
+ */
17
+ async function listInboxFolders(emailAccount, maxDepth = 2) {
18
+ const depth = (0, mail_1.clamp)(maxDepth, 1, 4);
19
+ const script = `on walkFolders(theFolder, level, maxLevel, prefix)
20
+ set out to ""
21
+ tell application "Microsoft Outlook"
22
+ set subs to mail folders of theFolder
23
+ end tell
24
+ repeat with f in subs
25
+ set nm to ""
26
+ set cnt to 0
27
+ tell application "Microsoft Outlook"
28
+ try
29
+ set nm to (name of f) as string
30
+ end try
31
+ try
32
+ set cnt to (count of messages of f)
33
+ end try
34
+ end tell
35
+ set thisPath to prefix & nm
36
+ set out to out & ${(0, run_1.asRow)(['nm', 'thisPath', '(cnt as string)', '(level as string)'])}
37
+ if level < maxLevel then
38
+ set out to out & (my walkFolders(f, level + 1, maxLevel, thisPath & ${run_1.AS_LIST_SEP}))
39
+ end if
40
+ end repeat
41
+ return out
42
+ end walkFolders
43
+
44
+ tell application "Microsoft Outlook"
45
+ ${(0, scripts_1.accountLookupSnippet)(emailAccount)}
46
+ set inb to inbox of targetAcct
47
+ end tell
48
+ return my walkFolders(inb, 1, ${depth}, "")`;
49
+ return (0, run_1.splitRecords)(await (0, run_1.runOsaScript)(script, 120000)).map(record => {
50
+ const parts = (0, run_1.splitFields)(record);
51
+ const segments = (0, run_1.splitList)((0, run_1.field)(parts, 1));
52
+ return {
53
+ name: (0, run_1.field)(parts, 0),
54
+ folderPath: (0, scripts_1.macFolderPath)(emailAccount, 'Inbox', segments),
55
+ itemCount: (0, run_1.intField)(parts, 2),
56
+ depth: (0, run_1.intField)(parts, 3, 1),
57
+ };
58
+ });
59
+ }
60
+ /**
61
+ * Move emails (by message id) into any folder of the account — a filing folder
62
+ * under the Inbox, or a well-known folder by name (see WELL_KNOWN_FOLDERS).
63
+ *
64
+ * **Moving to "Deleted Items" is how mail gets deleted reversibly**, which is why
65
+ * this takes well-known roots at all: it means the destructive path and the filing
66
+ * path are one tool, and the destructive one is undoable from the folder it lands in.
67
+ *
68
+ * `createIfMissing` builds the WHOLE missing chain, so a nested destination
69
+ * ("Clients\\Acme\\2026") is one call rather than a manual mkdir first.
70
+ * NOTE: moving changes a message's id — the passed ids are dead afterwards.
71
+ *
72
+ * Outlook for Mac's `move` reports success even where it silently does nothing,
73
+ * so the destination's message count is compared before and after. A run where
74
+ * every move "succeeded" and yet the folder never grew fails loudly instead of
75
+ * reporting mail that was never filed.
76
+ */
77
+ async function moveOutlookEmails(emailAccount, entryIds, folderName, createIfMissing = false) {
78
+ if (entryIds.length === 0) {
79
+ return { folderPath: '', folderCreated: false, moved: 0, failed: [] };
80
+ }
81
+ const ref = (0, mail_1.mailFolderRef)(folderName);
82
+ const { valid, invalid } = (0, scripts_1.partitionMessageIds)(entryIds);
83
+ const folderPath = (0, scripts_1.macFolderPath)(emailAccount, ref.rootLabel, ref.segments);
84
+ if (valid.length === 0) {
85
+ return { folderPath, folderCreated: false, moved: 0, failed: invalid };
86
+ }
87
+ const script = `tell application "Microsoft Outlook"
88
+ ${(0, scripts_1.accountLookupSnippet)(emailAccount)}
89
+ ${(0, scripts_1.mailScopeSnippet)(ref, folderName, createIfMissing)}
90
+ set countBefore to count of messages of scopeFolder
91
+ set movedCount to 0
92
+ set out to ""
93
+ repeat with theId in {${valid.join(', ')}}
94
+ try
95
+ set theMsg to missing value
96
+ try
97
+ set theMsg to message id theId
98
+ end try
99
+ if theMsg is missing value then error "no message with that id in this Outlook"
100
+ move theMsg to scopeFolder
101
+ set movedCount to movedCount + 1
102
+ on error errText
103
+ set out to out & ${(0, run_1.asRow)(['(theId as string)', 'errText'])}
104
+ end try
105
+ end repeat
106
+ set countAfter to count of messages of scopeFolder
107
+ if movedCount > 0 and countAfter is not greater than countBefore then
108
+ error "Outlook reported " & (movedCount as string) & " move(s) but '" & (name of scopeFolder) & "' did not grow - nothing was filed."
109
+ end if
110
+ return ${(0, run_1.asRow)(['(movedCount as string)', '(scopeCreated as string)'])} & out
111
+ end tell`;
112
+ const records = (0, run_1.splitRecords)(await (0, run_1.runOsaScript)(script, 300000));
113
+ const summary = (0, run_1.splitFields)(records[0] || '');
114
+ return {
115
+ folderPath,
116
+ folderCreated: (0, run_1.boolField)(summary, 1),
117
+ moved: (0, run_1.intField)(summary, 0),
118
+ failed: [
119
+ ...invalid,
120
+ ...records.slice(1).map(record => {
121
+ const parts = (0, run_1.splitFields)(record);
122
+ return { entryId: (0, run_1.field)(parts, 0), error: (0, run_1.field)(parts, 1) };
123
+ }),
124
+ ],
125
+ };
126
+ }
127
+ //# sourceMappingURL=folders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folders.js","sourceRoot":"","sources":["../../src/mac/folders.ts"],"names":[],"mappings":";;AAwBA,4CA8CC;AAmBD,8CAuDC;AAhJD,gEAAgE;AAChE,+BAUe;AACf,uCAAwG;AACxG,kCAA+C;AAG/C;;;;;;;GAOG;AACI,KAAK,UAAU,gBAAgB,CAClC,YAAoB,EACpB,QAAQ,GAAG,CAAC;IAEZ,MAAM,KAAK,GAAG,IAAA,YAAK,EAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;2BAiBQ,IAAA,WAAK,EAAC,CAAC,IAAI,EAAE,UAAU,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;;kFAEV,iBAAW;;;;;;;EAO3F,IAAA,8BAAoB,EAAC,YAAY,CAAC;;;gCAGJ,KAAK,OAAO,CAAC;IAEzC,OAAO,IAAA,kBAAY,EAAC,MAAM,IAAA,kBAAY,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAA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AC;IAC3E,CAAC;IACD,MAAM,MAAM,GAAG;EACjB,IAAA,8BAAoB,EAAC,YAAY,CAAC;EAClC,IAAA,0BAAgB,EAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC;;;;4BAIxB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;+BAUb,IAAA,WAAK,EAAC,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;;;;;;;aAOzD,IAAA,WAAK,EAAC,CAAC,wBAAwB,EAAE,0BAA0B,CAAC,CAAC;SACjE,CAAC;IAEN,MAAM,OAAO,GAAG,IAAA,kBAAY,EAAC,MAAM,IAAA,kBAAY,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,IAAA,iBAAW,EAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,OAAO;QACH,UAAU;QACV,aAAa,EAAE,IAAA,eAAS,EAAC,OAAO,EAAE,CAAC,CAAC;QACpC,KAAK,EAAE,IAAA,cAAQ,EAAC,OAAO,EAAE,CAAC,CAAC;QAC3B,MAAM,EAAE;YACJ,GAAG,OAAO;YACV,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAC7B,MAAM,KAAK,GAAG,IAAA,iBAAW,EAAC,MAAM,CAAC,CAAC;gBAClC,OAAO,EAAE,OAAO,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;YAChE,CAAC,CAAC;SACL;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,22 @@
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: a signature that drifts from
7
+ * the Windows one has to fail here, in the package, rather than surface as a
8
+ * per-platform union in the consumer's editor.
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 declare const capabilities: CapabilityMap;
@@ -0,0 +1,119 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.capabilities = exports.bridge = void 0;
18
+ // The macOS implementation: Outlook driven through AppleScript (osascript).
19
+ //
20
+ // Scope note: this targets **legacy** Outlook for Mac (`defaults read
21
+ // com.microsoft.Outlook IsRunningNewOutlook` = 0), which implements enough of the
22
+ // AppleScript dictionary to enumerate accounts, read mailboxes, reply, file and
23
+ // delete mail. "New Outlook" implements only a slice of it: accounts don't
24
+ // enumerate, the inbox reports 0 messages, and mutations like `delete` silently
25
+ // no-op. Under New Outlook the account lookup finds nothing and every function
26
+ // here fails loudly with "Account '…' not found" rather than quietly doing the
27
+ // wrong thing.
28
+ //
29
+ // Three dictionary traps are worth knowing, and each is handled where it bites:
30
+ // - `move`/`delete`/`close` report success even when they do nothing, so every
31
+ // mutation confirms with a count.
32
+ // - A new outgoing message lands in Temporary Items — `open` only displays it,
33
+ // so a windowless draft has to be moved into Drafts explicitly.
34
+ // - A bad dictionary term fails the WHOLE script at compile time rather than at
35
+ // the offending line, which is why the root terms in scripts.ts are the
36
+ // verified ones rather than the ones the Windows ids suggest.
37
+ const accounts_1 = require("./accounts");
38
+ const send_1 = require("./send");
39
+ const drafts_1 = require("./drafts");
40
+ const read_1 = require("./read");
41
+ const folders_1 = require("./folders");
42
+ const cleanup_1 = require("./cleanup");
43
+ const bounces_1 = require("./bounces");
44
+ const attachments_1 = require("./attachments");
45
+ const signatures_1 = require("./signatures");
46
+ const templates_1 = require("./templates");
47
+ const capabilities_1 = require("../shared/capabilities");
48
+ /**
49
+ * The whole contract in one object — and the compile-time proof that this
50
+ * module answers all of it.
51
+ *
52
+ * Typed as `OutlookBridge` rather than inferred: a signature that drifts from
53
+ * the Windows one has to fail here, in the package, rather than surface as a
54
+ * per-platform union in the consumer's editor.
55
+ */
56
+ const bridge = {
57
+ getOutlookAccounts: accounts_1.getOutlookAccounts,
58
+ sendOutlookEmail: send_1.sendOutlookEmail,
59
+ replyOutlookEmail: send_1.replyOutlookEmail,
60
+ sendAllDrafts: drafts_1.sendAllDrafts,
61
+ readInboxEmails: read_1.readInboxEmails,
62
+ searchInboxByFilter: read_1.searchInboxByFilter,
63
+ readSelectedEmail: read_1.readSelectedEmail,
64
+ readEmailBody: read_1.readEmailBody,
65
+ openOutlookEmail: read_1.openOutlookEmail,
66
+ listInboxFolders: folders_1.listInboxFolders,
67
+ moveOutlookEmails: folders_1.moveOutlookEmails,
68
+ listOutlookDrafts: drafts_1.listOutlookDrafts,
69
+ deleteOutlookDrafts: drafts_1.deleteOutlookDrafts,
70
+ deleteOutlookEmails: cleanup_1.deleteOutlookEmails,
71
+ purgeDeletedItems: cleanup_1.purgeDeletedItems,
72
+ saveEmailAttachment: attachments_1.saveEmailAttachment,
73
+ saveEmailAttachmentDetailed: attachments_1.saveEmailAttachmentDetailed,
74
+ saveEmailAttachments: attachments_1.saveEmailAttachments,
75
+ cleanUndeliverableEmails: bounces_1.cleanUndeliverableEmails,
76
+ collectBouncedRecipients: bounces_1.collectBouncedRecipients,
77
+ readSentRecipientGroups: bounces_1.readSentRecipientGroups,
78
+ listOutlookSignatures: signatures_1.listOutlookSignatures,
79
+ readOutlookSignatureHtml: signatures_1.readOutlookSignatureHtml,
80
+ readTemplateEmails: templates_1.readTemplateEmails,
81
+ saveTemplateEmail: templates_1.saveTemplateEmail,
82
+ editEmailTemplate: templates_1.editEmailTemplate,
83
+ };
84
+ exports.bridge = bridge;
85
+ // Re-exported one module at a time rather than by name: every feature module
86
+ // here exports exactly its bridge functions and nothing else, so the name list
87
+ // this replaces was a copy of the `bridge` literal above with no way to drift
88
+ // from it usefully.
89
+ __exportStar(require("./accounts"), exports);
90
+ __exportStar(require("./send"), exports);
91
+ __exportStar(require("./drafts"), exports);
92
+ __exportStar(require("./read"), exports);
93
+ __exportStar(require("./folders"), exports);
94
+ __exportStar(require("./cleanup"), exports);
95
+ __exportStar(require("./bounces"), exports);
96
+ __exportStar(require("./attachments"), exports);
97
+ __exportStar(require("./signatures"), exports);
98
+ __exportStar(require("./templates"), exports);
99
+ /**
100
+ * What is ported to macOS.
101
+ *
102
+ * The whole contract is, now — the gaps this map existed to announce (replies,
103
+ * drafts, attachments, deletion, templates, bounce handling and the Inbox-tree
104
+ * search) are implemented against the AppleScript dictionary rather than
105
+ * throwing NOT_IMPLEMENTED, so `NOT_PORTED` is empty and stays the place to
106
+ * name one if that ever stops being true.
107
+ *
108
+ * Two differences survive that no capability flag can express, and a caller
109
+ * moving between platforms has to know them:
110
+ * - **Ids are not portable.** macOS message ids are small integers, Windows
111
+ * EntryIDs are long MAPI strings; each platform rejects the other's. `storeId`
112
+ * has no macOS equivalent and is accepted-and-ignored throughout.
113
+ * - **`searchInboxByFilter` filters here, not in Outlook.** There is no
114
+ * AppleScript counterpart to COM's server-side `Items.Restrict`, so a
115
+ * `daysBack` of 0 over a large mailbox tree costs considerably more here.
116
+ */
117
+ const NOT_PORTED = [];
118
+ exports.capabilities = (0, capabilities_1.capabilityMap)(bridge, NOT_PORTED);
119
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mac/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4EAA4E;AAC5E,EAAE;AACF,sEAAsE;AACtE,kFAAkF;AAClF,gFAAgF;AAChF,2EAA2E;AAC3E,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,eAAe;AACf,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,qCAAqC;AACrC,gFAAgF;AAChF,mEAAmE;AACnE,iFAAiF;AACjF,2EAA2E;AAC3E,iEAAiE;AACjE,yCAAgD;AAChD,iCAA6D;AAC7D,qCAAiF;AACjF,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,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;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,GAAgC,EAAE,CAAC;AAEtC,QAAA,YAAY,GAAkB,IAAA,4BAAa,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { EmailBodyResult, InboxEmail, InboxSearchFilter, InboxSearchMatch, SelectedEmail } from '../types';
2
+ /**
3
+ * Read recent messages for the given account, newest first.
4
+ *
5
+ * `entryId` here is Outlook for Mac's small integer message id (e.g. "779"), not
6
+ * the MAPI EntryID string Windows returns. The two are not interchangeable, so
7
+ * don't persist one and look it up on the other platform.
8
+ */
9
+ export declare function readInboxEmails(emailAccount: string, daysBack?: number, limit?: number, folder?: string): Promise<InboxEmail[]>;
10
+ /**
11
+ * Read one email's full plain-text body by message id.
12
+ *
13
+ * `storeId` is accepted for signature parity and ignored: macOS has no StoreID,
14
+ * and `message id N` resolves against the application rather than one folder, so
15
+ * the message is found wherever it currently sits — including a subfolder.
16
+ *
17
+ * Uses `plain text content`, matching the Windows reader's use of `.Body`: the
18
+ * same tradeoff applies, so an HTML table's rows flatten and tabular figures are
19
+ * better read from an attachment.
20
+ */
21
+ export declare function readEmailBody(entryId: string, _storeId?: string, maxChars?: number, includeQuoted?: boolean): Promise<EmailBodyResult>;
22
+ /**
23
+ * Walk every folder under the Inbox (recursively) for one account and return the
24
+ * emails matching `filter` — full body included, attachments listed by name but
25
+ * not saved.
26
+ *
27
+ * The filtering happens here rather than in Outlook: `Items.Restrict` is a COM
28
+ * facility with no AppleScript counterpart, so the folder walk indexes each
29
+ * folder in two bulk reads and the subject/date tests run on the index. The
30
+ * observable contract is the same; the cost profile is not, and a `daysBack` of
31
+ * 0 over a large mailbox tree is correspondingly heavier here.
32
+ *
33
+ * `subjectPattern` is applied case-insensitively regardless of the RegExp's own
34
+ * flags, matching PowerShell's `-match`.
35
+ */
36
+ export declare function searchInboxByFilter(emailAccount: string, filter?: InboxSearchFilter, daysBack?: number): Promise<InboxSearchMatch[]>;
37
+ /**
38
+ * Read the email currently selected (or open) in Outlook — full body,
39
+ * attachments listed by name but not saved.
40
+ *
41
+ * `current messages` covers both cases the Windows reader handles separately
42
+ * (an explorer selection and an open item), so there is no second lookup here.
43
+ */
44
+ export declare function readSelectedEmail(): Promise<SelectedEmail>;
45
+ /** Open an email in Outlook by its message id, and bring Outlook forward. */
46
+ export declare function openOutlookEmail(entryId: string): Promise<void>;