@dawnlit/outlook-bridge 1.1.0 → 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.
- package/README.md +150 -183
- package/dist/backend.d.ts +151 -0
- package/dist/backend.js +3 -0
- package/dist/backend.js.map +1 -0
- package/dist/bridge.d.ts +56 -0
- package/dist/bridge.js +507 -0
- package/dist/bridge.js.map +1 -0
- package/dist/errors.d.ts +81 -43
- package/dist/errors.js +98 -52
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +25 -52
- package/dist/index.js.map +1 -1
- package/dist/mac/accounts.d.ts +7 -2
- package/dist/mac/accounts.js +23 -6
- package/dist/mac/accounts.js.map +1 -1
- package/dist/mac/attachments.d.ts +5 -25
- package/dist/mac/attachments.js +40 -99
- package/dist/mac/attachments.js.map +1 -1
- package/dist/mac/bounces.d.ts +12 -27
- package/dist/mac/bounces.js +95 -112
- package/dist/mac/bounces.js.map +1 -1
- package/dist/mac/cleanup.d.ts +11 -25
- package/dist/mac/cleanup.js +50 -76
- package/dist/mac/cleanup.js.map +1 -1
- package/dist/mac/drafts.d.ts +13 -34
- package/dist/mac/drafts.js +95 -169
- package/dist/mac/drafts.js.map +1 -1
- package/dist/mac/folders.d.ts +10 -21
- package/dist/mac/folders.js +33 -47
- package/dist/mac/folders.js.map +1 -1
- package/dist/mac/index.d.ts +2 -22
- package/dist/mac/index.js +19 -81
- package/dist/mac/index.js.map +1 -1
- package/dist/mac/profile.d.ts +13 -0
- package/dist/mac/profile.js +149 -0
- package/dist/mac/profile.js.map +1 -0
- package/dist/mac/read.d.ts +18 -36
- package/dist/mac/read.js +154 -208
- package/dist/mac/read.js.map +1 -1
- package/dist/mac/run.d.ts +35 -39
- package/dist/mac/run.js +97 -102
- package/dist/mac/run.js.map +1 -1
- package/dist/mac/scripts.d.ts +78 -86
- package/dist/mac/scripts.js +125 -115
- package/dist/mac/scripts.js.map +1 -1
- package/dist/mac/send.d.ts +10 -20
- package/dist/mac/send.js +64 -86
- package/dist/mac/send.js.map +1 -1
- package/dist/mac/signatures.d.ts +2 -2
- package/dist/mac/signatures.js +9 -11
- package/dist/mac/signatures.js.map +1 -1
- package/dist/mac/templates.d.ts +14 -26
- package/dist/mac/templates.js +75 -113
- package/dist/mac/templates.js.map +1 -1
- package/dist/mail.d.ts +77 -45
- package/dist/mail.js +166 -73
- package/dist/mail.js.map +1 -1
- package/dist/runtime.d.ts +76 -43
- package/dist/runtime.js +103 -48
- package/dist/runtime.js.map +1 -1
- package/dist/shared/args.d.ts +48 -0
- package/dist/shared/args.js +216 -0
- package/dist/shared/args.js.map +1 -0
- package/dist/shared/attachmentMatch.d.ts +28 -16
- package/dist/shared/attachmentMatch.js +60 -22
- package/dist/shared/attachmentMatch.js.map +1 -1
- package/dist/shared/bounceReport.d.ts +11 -0
- package/dist/shared/bounceReport.js +45 -0
- package/dist/shared/bounceReport.js.map +1 -0
- package/dist/shared/bounceRules.d.ts +38 -10
- package/dist/shared/bounceRules.js +50 -32
- package/dist/shared/bounceRules.js.map +1 -1
- package/dist/shared/exec.d.ts +21 -0
- package/dist/shared/exec.js +47 -0
- package/dist/shared/exec.js.map +1 -0
- package/dist/shared/json.d.ts +12 -6
- package/dist/shared/json.js +29 -23
- package/dist/shared/json.js.map +1 -1
- package/dist/shared/locate.d.ts +39 -0
- package/dist/shared/locate.js +129 -0
- package/dist/shared/locate.js.map +1 -0
- package/dist/shared/replyBody.d.ts +42 -32
- package/dist/shared/replyBody.js +84 -71
- package/dist/shared/replyBody.js.map +1 -1
- package/dist/templateBody.d.ts +63 -0
- package/dist/{outlookTemplateSections.js → templateBody.js} +72 -72
- package/dist/templateBody.js.map +1 -0
- package/dist/types.d.ts +360 -165
- package/dist/types.js +8 -9
- package/dist/types.js.map +1 -1
- package/dist/windows/accounts.d.ts +10 -1
- package/dist/windows/accounts.js +25 -13
- package/dist/windows/accounts.js.map +1 -1
- package/dist/windows/attachments.d.ts +9 -24
- package/dist/windows/attachments.js +94 -119
- package/dist/windows/attachments.js.map +1 -1
- package/dist/windows/bounces.d.ts +13 -26
- package/dist/windows/bounces.js +169 -200
- package/dist/windows/bounces.js.map +1 -1
- package/dist/windows/cleanup.d.ts +19 -23
- package/dist/windows/cleanup.js +93 -111
- package/dist/windows/cleanup.js.map +1 -1
- package/dist/windows/drafts.d.ts +16 -35
- package/dist/windows/drafts.js +167 -253
- package/dist/windows/drafts.js.map +1 -1
- package/dist/windows/folders.d.ts +8 -13
- package/dist/windows/folders.js +45 -52
- package/dist/windows/folders.js.map +1 -1
- package/dist/windows/index.d.ts +2 -27
- package/dist/windows/index.js +11 -65
- package/dist/windows/index.js.map +1 -1
- package/dist/windows/read.d.ts +24 -45
- package/dist/windows/read.js +266 -279
- package/dist/windows/read.js.map +1 -1
- package/dist/windows/run.d.ts +39 -39
- package/dist/windows/run.js +151 -111
- package/dist/windows/run.js.map +1 -1
- package/dist/windows/scripts.d.ts +71 -38
- package/dist/windows/scripts.js +123 -71
- package/dist/windows/scripts.js.map +1 -1
- package/dist/windows/send.d.ts +6 -11
- package/dist/windows/send.js +70 -79
- package/dist/windows/send.js.map +1 -1
- package/dist/windows/signatures.d.ts +4 -10
- package/dist/windows/signatures.js +30 -37
- package/dist/windows/signatures.js.map +1 -1
- package/dist/windows/templates.d.ts +12 -18
- package/dist/windows/templates.js +126 -151
- package/dist/windows/templates.js.map +1 -1
- package/package.json +5 -4
- package/dist/OutlookService.d.ts +0 -43
- package/dist/OutlookService.js +0 -137
- package/dist/OutlookService.js.map +0 -1
- package/dist/outlookTemplateSections.d.ts +0 -62
- package/dist/outlookTemplateSections.js.map +0 -1
- package/dist/shared/capabilities.d.ts +0 -3
- package/dist/shared/capabilities.js +0 -9
- package/dist/shared/capabilities.js.map +0 -1
package/dist/mac/cleanup.js
CHANGED
|
@@ -6,24 +6,22 @@ exports.purgeDeletedItems = purgeDeletedItems;
|
|
|
6
6
|
const run_1 = require("./run");
|
|
7
7
|
const scripts_1 = require("./scripts");
|
|
8
8
|
const mail_1 = require("../mail");
|
|
9
|
+
const OUTCOME_STATUSES = ['deleted', 'would-delete', 'refused', 'failed'];
|
|
9
10
|
/**
|
|
10
|
-
* Walk a folder's `container` chain to the top
|
|
11
|
-
*
|
|
11
|
+
* Walk a folder's `container` chain to the top as the list `chainNames`,
|
|
12
|
+
* nearest first. Requires `theFolder`.
|
|
12
13
|
*
|
|
13
|
-
* This is what
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* of one name, so comparing that name is exact rather than a guess.
|
|
14
|
+
* This is what extends the Inbox/Sent Items refusal to their SUBFOLDERS. The
|
|
15
|
+
* chain's last element is the folder directly under the account, and an account
|
|
16
|
+
* can't hold two top-level folders of one name, so comparing that name is exact.
|
|
17
17
|
*/
|
|
18
18
|
function folderChainSnippet(indent) {
|
|
19
19
|
return `${indent}set chainNames to {}
|
|
20
20
|
${indent}set cur to theFolder
|
|
21
21
|
${indent}set guard to 0
|
|
22
22
|
${indent}repeat while cur is not missing value and guard < 25
|
|
23
|
-
${indent} -- The account's
|
|
24
|
-
${indent} -- that yields the STRING "missing value" —
|
|
25
|
-
${indent} -- check and became the chain's root, so nothing was ever recognised as
|
|
26
|
-
${indent} -- living under the Inbox. Test before coercing.
|
|
23
|
+
${indent} -- The account's root folder has a name of missing value, and coercing
|
|
24
|
+
${indent} -- that yields the STRING "missing value" — so test before coercing.
|
|
27
25
|
${indent} set rawName to missing value
|
|
28
26
|
${indent} try
|
|
29
27
|
${indent} set rawName to name of cur
|
|
@@ -41,27 +39,13 @@ ${indent} set guard to guard + 1
|
|
|
41
39
|
${indent}end repeat`;
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
|
-
* Delete mail by message id from anywhere in the account
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* ⚠️ This is the one tool here that can reach received mail. Three things hold
|
|
49
|
-
* the line, exactly as on Windows:
|
|
50
|
-
*
|
|
51
|
-
* - **Inbox and Sent Items are refused by default, INCLUDING their subfolders** —
|
|
52
|
-
* a filed subfolder is still received mail. `allowProtected` lifts that, and is
|
|
53
|
-
* the caller explicitly taking responsibility.
|
|
54
|
-
* - **`dryRun` resolves and reports without deleting**, so the exact subjects and
|
|
55
|
-
* folders can be shown to the user before anything happens. Use it first.
|
|
56
|
-
* - **Every outcome echoes the subject and folderPath** of the item actually
|
|
57
|
-
* resolved, so a wrong id is visible after the fact rather than silent.
|
|
42
|
+
* Delete mail by message id from anywhere in the account, into Deleted Items.
|
|
43
|
+
* Inbox and Sent Items (and their subfolders) are refused unless
|
|
44
|
+
* `allowProtected`; `dryRun` reports without deleting; every outcome names the
|
|
45
|
+
* subject and folder of the item that actually resolved.
|
|
58
46
|
*/
|
|
59
|
-
async function deleteOutlookEmails(
|
|
60
|
-
const {
|
|
61
|
-
if (entryIds.length === 0) {
|
|
62
|
-
return { dryRun, deleted: 0, refused: 0, failed: 0, items: [] };
|
|
63
|
-
}
|
|
64
|
-
const { valid, invalid } = (0, scripts_1.partitionMessageIds)(entryIds);
|
|
47
|
+
async function deleteOutlookEmails(request) {
|
|
48
|
+
const { valid, invalid } = (0, scripts_1.partitionMessageIds)(request.entryIds);
|
|
65
49
|
const items = invalid.map(bad => ({
|
|
66
50
|
entryId: bad.entryId,
|
|
67
51
|
subject: '',
|
|
@@ -70,12 +54,15 @@ async function deleteOutlookEmails(emailAccount, entryIds, options = {}) {
|
|
|
70
54
|
reason: bad.error,
|
|
71
55
|
}));
|
|
72
56
|
if (valid.length > 0) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
57
|
+
const acct = await (0, scripts_1.resolveMacAccount)(request.account);
|
|
58
|
+
const raw = await (0, run_1.runOsaScript)(`tell application "Microsoft Outlook"
|
|
59
|
+
${(0, scripts_1.accountLookupSnippet)(acct)}
|
|
60
|
+
${(0, scripts_1.rootFolderSnippet)(acct, 'inbox', 'inboxFolder')}
|
|
61
|
+
${(0, scripts_1.rootFolderSnippet)(acct, 'sent items', 'sentFolder')}
|
|
62
|
+
set inboxName to (name of inboxFolder) as string
|
|
63
|
+
set sentName to (name of sentFolder) as string
|
|
77
64
|
set out to ""
|
|
78
|
-
repeat with theId in
|
|
65
|
+
repeat with theId in ${(0, run_1.asIdList)(valid)}
|
|
79
66
|
set subj to ""
|
|
80
67
|
set pathText to ""
|
|
81
68
|
try
|
|
@@ -96,15 +83,9 @@ ${folderChainSnippet(' ')}
|
|
|
96
83
|
set pathText to my sanitizeList(my reverseList(chainNames))
|
|
97
84
|
set rootName to item (count of chainNames) of chainNames
|
|
98
85
|
set isProtected to (rootName is inboxName) or (rootName is sentName)
|
|
99
|
-
if isProtected and not ${allowProtected} then
|
|
100
|
-
set out to out & ${(0, run_1.asRow)([
|
|
101
|
-
|
|
102
|
-
'subj',
|
|
103
|
-
'pathText',
|
|
104
|
-
'"refused"',
|
|
105
|
-
`"${(0, run_1.asEscape)(mail_1.PROTECTED_MAIL_REASON)}"`,
|
|
106
|
-
])}
|
|
107
|
-
else if ${dryRun} then
|
|
86
|
+
if isProtected and not ${(0, run_1.asBool)(request.allowProtected)} then
|
|
87
|
+
set out to out & ${(0, run_1.asRow)(['(theId as string)', 'subj', 'pathText', '"refused"', (0, run_1.asString)(mail_1.PROTECTED_MAIL_REASON)])}
|
|
88
|
+
else if ${(0, run_1.asBool)(request.dryRun)} then
|
|
108
89
|
set out to out & ${(0, run_1.asRow)(['(theId as string)', 'subj', 'pathText', '"would-delete"', '""'])}
|
|
109
90
|
else
|
|
110
91
|
delete theMsg
|
|
@@ -123,23 +104,21 @@ on reverseList(lst)
|
|
|
123
104
|
set end of out to item i of lst
|
|
124
105
|
end repeat
|
|
125
106
|
return out
|
|
126
|
-
end reverseList
|
|
127
|
-
for (const record of (0, run_1.splitRecords)(
|
|
107
|
+
end reverseList`, 'scan');
|
|
108
|
+
for (const record of (0, run_1.splitRecords)(raw)) {
|
|
128
109
|
const parts = (0, run_1.splitFields)(record);
|
|
129
110
|
const segments = (0, run_1.splitList)((0, run_1.field)(parts, 2));
|
|
130
111
|
items.push({
|
|
131
112
|
entryId: (0, run_1.field)(parts, 0),
|
|
132
113
|
subject: (0, run_1.field)(parts, 1).trim(),
|
|
133
|
-
folderPath: segments.length
|
|
134
|
-
|
|
135
|
-
: '',
|
|
136
|
-
status: ((0, run_1.field)(parts, 3) || 'failed'),
|
|
114
|
+
folderPath: segments.length ? (0, scripts_1.macFolderPath)(request.account, segments[0], segments.slice(1)) : '',
|
|
115
|
+
status: OUTCOME_STATUSES.find(s => s === (0, run_1.field)(parts, 3)) ?? 'failed',
|
|
137
116
|
reason: (0, run_1.field)(parts, 4),
|
|
138
117
|
});
|
|
139
118
|
}
|
|
140
119
|
}
|
|
141
120
|
return {
|
|
142
|
-
dryRun,
|
|
121
|
+
dryRun: request.dryRun,
|
|
143
122
|
deleted: items.filter(i => i.status === 'deleted').length,
|
|
144
123
|
refused: items.filter(i => i.status === 'refused').length,
|
|
145
124
|
failed: items.filter(i => i.status === 'failed').length,
|
|
@@ -147,51 +126,47 @@ end reverseList`;
|
|
|
147
126
|
};
|
|
148
127
|
}
|
|
149
128
|
/**
|
|
150
|
-
* Permanently remove items from the account's Deleted Items folder
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* destroy what the user already threw away.
|
|
154
|
-
*
|
|
155
|
-
* `olderThanDays` keeps recent items (0 = purge everything). The folder is
|
|
156
|
-
* indexed first and destroyed by id afterwards, so deleting can't shift the
|
|
157
|
-
* collection out from under the walk.
|
|
129
|
+
* Permanently remove items from the account's Deleted Items. The folder is
|
|
130
|
+
* indexed first and items destroyed by id afterwards, so deleting can't shift
|
|
131
|
+
* the collection out from under the walk.
|
|
158
132
|
*/
|
|
159
|
-
async function purgeDeletedItems(
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
${(0, scripts_1.accountLookupSnippet)(
|
|
164
|
-
|
|
133
|
+
async function purgeDeletedItems(request) {
|
|
134
|
+
const folderPath = (0, scripts_1.macFolderPath)(request.account, 'Deleted Items', []);
|
|
135
|
+
const acct = await (0, scripts_1.resolveMacAccount)(request.account);
|
|
136
|
+
const index = await (0, run_1.runOsaScript)(`tell application "Microsoft Outlook"
|
|
137
|
+
${(0, scripts_1.accountLookupSnippet)(acct)}
|
|
138
|
+
${(0, scripts_1.rootFolderSnippet)(acct, 'deleted items', 'trashFolder')}
|
|
165
139
|
set idList to id of every message of trashFolder
|
|
166
140
|
try
|
|
167
141
|
set timeList to time received of every message of trashFolder
|
|
168
142
|
on error
|
|
169
143
|
set timeList to {}
|
|
170
144
|
end try
|
|
171
|
-
set
|
|
145
|
+
set olderThanDays to ${(0, run_1.asInt)(request.olderThanDays)}
|
|
146
|
+
set cutoff to (current date) - (olderThanDays * days)
|
|
172
147
|
set out to ""
|
|
173
148
|
repeat with i from 1 to (count of idList)
|
|
174
149
|
set stamp to missing value
|
|
175
150
|
if (count of timeList) is (count of idList) then set stamp to item i of timeList
|
|
176
151
|
set keepIt to false
|
|
177
|
-
if
|
|
152
|
+
if olderThanDays > 0 and stamp is not missing value and stamp is greater than cutoff then set keepIt to true
|
|
178
153
|
set out to out & ${(0, run_1.asRow)(['(item i of idList as string)', '(keepIt as string)'])}
|
|
179
154
|
end repeat
|
|
180
155
|
return out
|
|
181
|
-
end tell
|
|
182
|
-
const rows = (0, run_1.splitRecords)(
|
|
156
|
+
end tell`, 'scan');
|
|
157
|
+
const rows = (0, run_1.splitRecords)(index).map(record => {
|
|
183
158
|
const parts = (0, run_1.splitFields)(record);
|
|
184
159
|
return { id: (0, run_1.field)(parts, 0), keep: (0, run_1.boolField)(parts, 1) };
|
|
185
160
|
});
|
|
186
161
|
const doomed = rows.filter(row => !row.keep);
|
|
187
162
|
const kept = rows.length - doomed.length;
|
|
188
|
-
if (dryRun || doomed.length === 0) {
|
|
189
|
-
return { folderPath, dryRun, matched: doomed.length, purged: 0, kept, failed: 0 };
|
|
163
|
+
if (request.dryRun || doomed.length === 0) {
|
|
164
|
+
return { folderPath, dryRun: request.dryRun, matched: doomed.length, purged: 0, kept, failed: 0 };
|
|
190
165
|
}
|
|
191
|
-
const
|
|
166
|
+
const summary = (0, run_1.summaryFields)(await (0, run_1.runOsaScript)(`tell application "Microsoft Outlook"
|
|
192
167
|
set purgedCount to 0
|
|
193
168
|
set failedCount to 0
|
|
194
|
-
repeat with theId in
|
|
169
|
+
repeat with theId in ${(0, run_1.asIdList)(doomed.map(row => row.id))}
|
|
195
170
|
try
|
|
196
171
|
set theMsg to missing value
|
|
197
172
|
try
|
|
@@ -205,11 +180,10 @@ end tell`;
|
|
|
205
180
|
end try
|
|
206
181
|
end repeat
|
|
207
182
|
return ${(0, run_1.asRow)(['(purgedCount as string)', '(failedCount as string)'])}
|
|
208
|
-
end tell
|
|
209
|
-
const summary = (0, run_1.summaryFields)(await (0, run_1.runOsaScript)(purgeScript, 600000));
|
|
183
|
+
end tell`, 'purge'));
|
|
210
184
|
return {
|
|
211
185
|
folderPath,
|
|
212
|
-
dryRun,
|
|
186
|
+
dryRun: request.dryRun,
|
|
213
187
|
matched: doomed.length,
|
|
214
188
|
purged: (0, run_1.intField)(summary, 0),
|
|
215
189
|
kept,
|
package/dist/mac/cleanup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../src/mac/cleanup.ts"],"names":[],"mappings":";;AAoEA,kDA8FC;AAYD,8CAkEC;AAhPD,wDAAwD;AACxD,+BAWe;AACf,uCAAqF;AACrF,kCAAgD;AAGhD;;;;;;;;GAQG;AACH,SAAS,kBAAkB,CAAC,MAAc;IACtC,OAAO,GAAG,MAAM;EAClB,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,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IAAA,eAAS,EAAC,KAAK,EAAE,CAAC,CAAC,EAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,IAAI,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxC,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAC,CAAC;IACpG,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,mBAAa,EAAC,MAAM,IAAA,kBAAY,EAAC;;;2BAG1B,IAAA,cAAQ,EAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;aAajD,IAAA,WAAK,EAAC,CAAC,yBAAyB,EAAE,yBAAyB,CAAC,CAAC;SACjE,EAAE,OAAO,CAAC,CAAC,CAAC;IACjB,OAAO;QACH,UAAU;QACV,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,MAAM,EAAE,IAAA,cAAQ,EAAC,OAAO,EAAE,CAAC,CAAC;QAC5B,IAAI;QACJ,MAAM,EAAE,IAAA,cAAQ,EAAC,OAAO,EAAE,CAAC,CAAC;KAC/B,CAAC;AACN,CAAC","sourcesContent":["// Deleting mail, and emptying what was already deleted.\nimport {\n asBool,\n asIdList,\n asInt,\n asRow,\n asString,\n boolField,\n field,\n intField,\n runOsaScript,\n splitFields,\n splitList,\n splitRecords,\n summaryFields\n} from './run';\nimport {\n accountLookupSnippet,\n macFolderPath,\n partitionMessageIds,\n resolveMacAccount,\n rootFolderSnippet\n} from './scripts';\nimport { PROTECTED_MAIL_REASON } from '../mail';\nimport type { DeleteEmailsRequest, PurgeRequest } from '../backend';\nimport type { DeleteMailOutcome, DeleteMailResult, PurgeDeletedItemsResult } from '../types';\n\nconst OUTCOME_STATUSES: readonly DeleteMailOutcome['status'][] = ['deleted', 'would-delete', 'refused', 'failed'];\n\n/**\n * Walk a folder's `container` chain to the top as the list `chainNames`,\n * nearest first. Requires `theFolder`.\n *\n * This is what extends the Inbox/Sent Items refusal to their SUBFOLDERS. The\n * chain's last element is the folder directly under the account, and an account\n * can't hold two top-level folders of one name, so comparing that name is exact.\n */\nfunction folderChainSnippet(indent: string): string {\n return `${indent}set chainNames to {}\n${indent}set cur to theFolder\n${indent}set guard to 0\n${indent}repeat while cur is not missing value and guard < 25\n${indent} -- The account's root folder has a name of missing value, and coercing\n${indent} -- that yields the STRING \"missing value\" — so test before coercing.\n${indent} set rawName to missing value\n${indent} try\n${indent} set rawName to name of cur\n${indent} end try\n${indent} if rawName is missing value then exit repeat\n${indent} set nm to rawName as string\n${indent} if nm is \"\" then exit repeat\n${indent} set end of chainNames to nm\n${indent} set nextUp to missing value\n${indent} try\n${indent} set nextUp to container of cur\n${indent} end try\n${indent} set cur to nextUp\n${indent} set guard to guard + 1\n${indent}end repeat`;\n}\n\n/**\n * Delete mail by message id from anywhere in the account, into Deleted Items.\n * Inbox and Sent Items (and their subfolders) are refused unless\n * `allowProtected`; `dryRun` reports without deleting; every outcome names the\n * subject and folder of the item that actually resolved.\n */\nexport async function deleteOutlookEmails(request: DeleteEmailsRequest): Promise<DeleteMailResult> {\n const {valid, invalid} = partitionMessageIds(request.entryIds);\n const items: DeleteMailOutcome[] = invalid.map(bad => ({\n entryId: bad.entryId,\n subject: '',\n folderPath: '',\n status: 'failed',\n reason: bad.error,\n }));\n if (valid.length > 0) {\n const acct = await resolveMacAccount(request.account);\n const raw = await runOsaScript(`tell application \"Microsoft Outlook\"\n${accountLookupSnippet(acct)}\n${rootFolderSnippet(acct, 'inbox', 'inboxFolder')}\n${rootFolderSnippet(acct, 'sent items', 'sentFolder')}\n set inboxName to (name of inboxFolder) as string\n set sentName to (name of sentFolder) as string\n set out to \"\"\n repeat with theId in ${asIdList(valid)}\n set subj to \"\"\n set pathText to \"\"\n try\n set theMsg to missing value\n try\n set theMsg to message id theId\n end try\n if theMsg is missing value then error \"no item with that message id in this Outlook\"\n try\n set subj to (subject of theMsg) as string\n end try\n set theFolder to missing value\n try\n set theFolder to folder of theMsg\n end try\n if theFolder is missing value then error \"item has no parent folder - refusing to delete\"\n${folderChainSnippet(' ')}\n set pathText to my sanitizeList(my reverseList(chainNames))\n set rootName to item (count of chainNames) of chainNames\n set isProtected to (rootName is inboxName) or (rootName is sentName)\n if isProtected and not ${asBool(request.allowProtected)} then\n set out to out & ${asRow(['(theId as string)', 'subj', 'pathText', '\"refused\"', asString(PROTECTED_MAIL_REASON)])}\n else if ${asBool(request.dryRun)} then\n set out to out & ${asRow(['(theId as string)', 'subj', 'pathText', '\"would-delete\"', '\"\"'])}\n else\n delete theMsg\n set out to out & ${asRow(['(theId as string)', 'subj', 'pathText', '\"deleted\"', '\"\"'])}\n end if\n on error errText\n set out to out & ${asRow(['(theId as string)', 'subj', 'pathText', '\"failed\"', 'errText'])}\n end try\n end repeat\n return out\nend tell\n\non reverseList(lst)\n set out to {}\n repeat with i from (count of lst) to 1 by -1\n set end of out to item i of lst\n end repeat\n return out\nend reverseList`, 'scan');\n\n for (const record of splitRecords(raw)) {\n const parts = splitFields(record);\n const segments = splitList(field(parts, 2));\n items.push({\n entryId: field(parts, 0),\n subject: field(parts, 1).trim(),\n folderPath: segments.length ? macFolderPath(request.account, segments[0], segments.slice(1)) : '',\n status: OUTCOME_STATUSES.find(s => s === field(parts, 3)) ?? 'failed',\n reason: field(parts, 4),\n });\n }\n }\n return {\n dryRun: request.dryRun,\n deleted: items.filter(i => i.status === 'deleted').length,\n refused: items.filter(i => i.status === 'refused').length,\n failed: items.filter(i => i.status === 'failed').length,\n items,\n };\n}\n\n/**\n * Permanently remove items from the account's Deleted Items. The folder is\n * indexed first and items destroyed by id afterwards, so deleting can't shift\n * the collection out from under the walk.\n */\nexport async function purgeDeletedItems(request: PurgeRequest): Promise<PurgeDeletedItemsResult> {\n const folderPath = macFolderPath(request.account, 'Deleted Items', []);\n const acct = await resolveMacAccount(request.account);\n const index = await runOsaScript(`tell application \"Microsoft Outlook\"\n${accountLookupSnippet(acct)}\n${rootFolderSnippet(acct, 'deleted items', 'trashFolder')}\n set idList to id of every message of trashFolder\n try\n set timeList to time received of every message of trashFolder\n on error\n set timeList to {}\n end try\n set olderThanDays to ${asInt(request.olderThanDays)}\n set cutoff to (current date) - (olderThanDays * days)\n set out to \"\"\n repeat with i from 1 to (count of idList)\n set stamp to missing value\n if (count of timeList) is (count of idList) then set stamp to item i of timeList\n set keepIt to false\n if olderThanDays > 0 and stamp is not missing value and stamp is greater than cutoff then set keepIt to true\n set out to out & ${asRow(['(item i of idList as string)', '(keepIt as string)'])}\n end repeat\n return out\nend tell`, 'scan');\n\n const rows = splitRecords(index).map(record => {\n const parts = splitFields(record);\n return {id: field(parts, 0), keep: boolField(parts, 1)};\n });\n const doomed = rows.filter(row => !row.keep);\n const kept = rows.length - doomed.length;\n if (request.dryRun || doomed.length === 0) {\n return {folderPath, dryRun: request.dryRun, matched: doomed.length, purged: 0, kept, failed: 0};\n }\n\n const summary = summaryFields(await runOsaScript(`tell application \"Microsoft Outlook\"\n set purgedCount to 0\n set failedCount to 0\n repeat with theId in ${asIdList(doomed.map(row => row.id))}\n try\n set theMsg to missing value\n try\n set theMsg to message id theId\n end try\n if theMsg is missing value then error \"gone\"\n permanently delete theMsg\n set purgedCount to purgedCount + 1\n on error\n set failedCount to failedCount + 1\n end try\n end repeat\n return ${asRow(['(purgedCount as string)', '(failedCount as string)'])}\nend tell`, 'purge'));\n return {\n folderPath,\n dryRun: request.dryRun,\n matched: doomed.length,\n purged: intField(summary, 0),\n kept,\n failed: intField(summary, 1),\n };\n}\n"]}
|
package/dist/mac/drafts.d.ts
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountRequest, EntryIdsRequest, ListDraftsRequest } from '../backend';
|
|
2
|
+
import type { DeleteDraftsResult, ListDraftsResult, SendDraftsResult } from '../types';
|
|
3
|
+
/** The account's drafts, newest first. Bodies are previewed, never returned whole. */
|
|
4
|
+
export declare function listOutlookDrafts(request: ListDraftsRequest): Promise<ListDraftsResult>;
|
|
5
|
+
/** Send the named drafts. */
|
|
6
|
+
export declare function sendDrafts(request: EntryIdsRequest): Promise<SendDraftsResult>;
|
|
2
7
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Bodies are previewed, never returned whole — a templated reply body runs to
|
|
6
|
-
* tens of thousands of characters and a folder's worth would blow the cap.
|
|
8
|
+
* Delete the named drafts. `delete` files an item in Deleted Items, so a
|
|
9
|
+
* mistaken call stays recoverable.
|
|
7
10
|
*/
|
|
8
|
-
export declare function
|
|
11
|
+
export declare function deleteOutlookDrafts(request: EntryIdsRequest): Promise<DeleteDraftsResult>;
|
|
9
12
|
/**
|
|
10
|
-
* Send the
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Drafts, and mutating the collection mid-enumeration would skip every other one
|
|
14
|
-
* — the same trap the Windows implementation avoids by snapshotting item refs.
|
|
13
|
+
* Send every draft belonging to the account. The ids are snapshotted before the
|
|
14
|
+
* first send: sending moves an item out of Drafts, and mutating the collection
|
|
15
|
+
* mid-enumeration would skip every other one.
|
|
15
16
|
*/
|
|
16
|
-
export declare function sendAllDrafts(
|
|
17
|
-
/**
|
|
18
|
-
* Delete mail drafts by message id. `delete` files the item in Deleted Items
|
|
19
|
-
* rather than destroying it, so a mistaken call stays recoverable from there —
|
|
20
|
-
* matching the Windows contract.
|
|
21
|
-
*
|
|
22
|
-
* Every id must resolve to a message sitting in THIS account's Drafts folder
|
|
23
|
-
* before anything is deleted; an id pointing at ordinary mail, or at another
|
|
24
|
-
* account's draft, is refused and reported. Without that gate this would be a
|
|
25
|
-
* general-purpose "delete any email by id" tool, which is not what it is for.
|
|
26
|
-
*/
|
|
27
|
-
export declare function deleteOutlookDrafts(emailAccount: string, entryIds: string[]): Promise<DeleteDraftsResult>;
|
|
28
|
-
/**
|
|
29
|
-
* Send a chosen subset of `emailAccount`'s drafts by message id — e.g. after
|
|
30
|
-
* `listOutlookDrafts` and a user review pass — instead of `sendAllDrafts`'s
|
|
31
|
-
* account-wide sweep.
|
|
32
|
-
*
|
|
33
|
-
* Same ownership gate as `deleteOutlookDrafts`: every id must resolve to a
|
|
34
|
-
* message sitting in THIS account's Drafts folder before anything is sent. An
|
|
35
|
-
* id pointing at ordinary mail, or at another account's draft, is refused and
|
|
36
|
-
* reported rather than sent.
|
|
37
|
-
*/
|
|
38
|
-
export declare function sendDrafts(emailAccount: string, entryIds: string[]): Promise<SendDraftsResult>;
|
|
17
|
+
export declare function sendAllDrafts(request: AccountRequest): Promise<SendDraftsResult>;
|