@dawnlit/outlook-bridge 1.1.1 → 2.1.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 +152 -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 +79 -43
- package/dist/errors.js +93 -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 +96 -117
- package/dist/mac/bounces.js.map +1 -1
- package/dist/mac/cleanup.d.ts +11 -25
- package/dist/mac/cleanup.js +44 -107
- package/dist/mac/cleanup.js.map +1 -1
- package/dist/mac/drafts.d.ts +15 -34
- package/dist/mac/drafts.js +113 -186
- package/dist/mac/drafts.js.map +1 -1
- package/dist/mac/folders.d.ts +12 -21
- package/dist/mac/folders.js +44 -59
- 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 +21 -37
- package/dist/mac/read.js +198 -216
- package/dist/mac/read.js.map +1 -1
- package/dist/mac/run.d.ts +51 -38
- package/dist/mac/run.js +138 -103
- package/dist/mac/run.js.map +1 -1
- package/dist/mac/scripts.d.ts +90 -91
- package/dist/mac/scripts.js +167 -126
- package/dist/mac/scripts.js.map +1 -1
- package/dist/mac/send.d.ts +10 -20
- package/dist/mac/send.js +99 -89
- 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 +79 -120
- package/dist/mac/templates.js.map +1 -1
- package/dist/mail.d.ts +80 -46
- package/dist/mail.js +179 -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 +26 -20
- package/dist/shared/attachmentMatch.js +60 -23
- 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 +17 -6
- package/dist/shared/json.js +35 -24
- package/dist/shared/json.js.map +1 -1
- package/dist/shared/locate.d.ts +31 -0
- package/dist/shared/locate.js +128 -0
- package/dist/shared/locate.js.map +1 -0
- package/dist/shared/replyBody.d.ts +31 -36
- package/dist/shared/replyBody.js +83 -72
- package/dist/shared/replyBody.js.map +1 -1
- package/dist/shared/templateLimits.d.ts +14 -0
- package/dist/shared/templateLimits.js +21 -0
- package/dist/shared/templateLimits.js.map +1 -0
- package/dist/templateBody.d.ts +69 -0
- package/dist/{outlookTemplateSections.js → templateBody.js} +80 -73
- package/dist/templateBody.js.map +1 -0
- package/dist/types.d.ts +381 -168
- package/dist/types.js +8 -9
- package/dist/types.js.map +1 -1
- package/dist/windows/accounts.d.ts +7 -12
- package/dist/windows/accounts.js +19 -34
- 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 +168 -200
- package/dist/windows/bounces.js.map +1 -1
- package/dist/windows/cleanup.d.ts +23 -23
- package/dist/windows/cleanup.js +99 -113
- package/dist/windows/cleanup.js.map +1 -1
- package/dist/windows/drafts.d.ts +16 -35
- package/dist/windows/drafts.js +156 -253
- package/dist/windows/drafts.js.map +1 -1
- package/dist/windows/folders.d.ts +8 -13
- package/dist/windows/folders.js +44 -52
- package/dist/windows/folders.js.map +1 -1
- package/dist/windows/index.d.ts +2 -27
- package/dist/windows/index.js +11 -66
- package/dist/windows/index.js.map +1 -1
- package/dist/windows/read.d.ts +24 -60
- package/dist/windows/read.js +265 -306
- package/dist/windows/read.js.map +1 -1
- package/dist/windows/run.d.ts +38 -40
- package/dist/windows/run.js +151 -112
- package/dist/windows/run.js.map +1 -1
- package/dist/windows/scripts.d.ts +65 -55
- package/dist/windows/scripts.js +109 -85
- package/dist/windows/scripts.js.map +1 -1
- package/dist/windows/send.d.ts +9 -9
- package/dist/windows/send.js +76 -88
- 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 +117 -150
- 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/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { createOutlookBridge, capabilities, supports } from './
|
|
3
|
-
export type { OutlookBridgeInstance } from './
|
|
4
|
-
export { configure
|
|
1
|
+
export declare const getOutlookAccounts: () => Promise<string[]>, sendOutlookEmail: (params: import("./types").SendEmailParams) => Promise<import("./types").SendEmailResult>, replyOutlookEmail: (params: import("./types").ReplyEmailParams) => Promise<import("./types").ReplyEmailResult>, readInboxEmails: (emailAccount: string, options?: import("./types").ReadInboxOptions) => Promise<import("./types").InboxEmail[]>, searchInboxByFilter: (emailAccount: string, filter?: import("./types").InboxSearchFilter) => Promise<import("./types").InboxSearchMatch[]>, readSelectedEmail: () => Promise<import("./types").SelectedEmail>, readEmailBody: (email: import("./types").EmailRef, options?: import("./types").ReadEmailBodyOptions) => Promise<import("./types").EmailBodyResult>, openOutlookEmail: (email: import("./types").EmailRef) => Promise<void>, locateEmail: (description: import("./types").EmailDescription, options?: import("./types").LocateEmailOptions) => Promise<import("./types").InboxSearchMatch | null>, listInboxFolders: (emailAccount: string, options?: import("./types").ListFoldersOptions) => Promise<import("./types").InboxFolderInfo[]>, moveOutlookEmails: (emailAccount: string, entryIds: readonly string[], folder: string, options?: import("./types").MoveEmailsOptions) => Promise<import("./types").MoveEmailsResult>, listOutlookDrafts: (emailAccount: string, options?: import("./types").ListDraftsOptions) => Promise<import("./types").ListDraftsResult>, sendDrafts: (emailAccount: string, entryIds: readonly string[]) => Promise<import("./types").SendDraftsResult>, sendAllDrafts: (emailAccount: string) => Promise<import("./types").SendDraftsResult>, deleteOutlookDrafts: (emailAccount: string, entryIds: readonly string[]) => Promise<import("./types").DeleteDraftsResult>, deleteOutlookEmails: (emailAccount: string, entryIds: readonly string[], options?: import("./types").DeleteMailOptions) => Promise<import("./types").DeleteMailResult>, purgeDeletedItems: (emailAccount: string, options?: import("./types").PurgeDeletedItemsOptions) => Promise<import("./types").PurgeDeletedItemsResult>, saveEmailAttachment: (email: import("./types").EmailRef, fileName: string, options?: import("./types").SaveAttachmentOptions) => Promise<import("./types").SavedAttachment>, saveEmailAttachments: (email: import("./types").EmailRef, fileNames: readonly string[], options?: import("./types").SaveAttachmentOptions) => Promise<import("./types").SavedAttachment[]>, cleanUndeliverableEmails: (emailAccount: string, options?: import("./types").CleanUndeliverableOptions) => Promise<import("./types").CleanUndeliverableResult>, collectBouncedRecipients: (emailAccount: string, options?: import("./types").CollectBouncedRecipientsOptions) => Promise<string[]>, readSentRecipientGroups: (emailAccount: string, options?: import("./types").SentRecipientGroupsOptions) => Promise<import("./types").SentRecipientGroup[]>, readBounceReport: (emailAccount: string, options?: import("./types").BounceReportOptions) => Promise<import("./types").BounceReport>, listOutlookSignatures: () => Promise<string[]>, readOutlookSignatureHtml: (name: string) => Promise<string>, readTemplateEmails: (emailAccount: string, options?: import("./types").ReadTemplatesOptions) => Promise<import("./types").TemplateFolderResult>, saveTemplateEmail: (emailAccount: string, template: import("./types").SaveTemplateParams) => Promise<import("./types").SaveTemplateResult>, editEmailTemplate: (label: string, currentHtml: string) => Promise<string>;
|
|
2
|
+
export { createOutlookBridge, capabilities, supports } from './bridge';
|
|
3
|
+
export type { OutlookBridgeInstance } from './bridge';
|
|
4
|
+
export { configure } from './runtime';
|
|
5
5
|
export type { BridgeOptions, BridgeDebugEvent, ResolvedConfig } from './runtime';
|
|
6
|
-
export { OutlookError, UnsupportedPlatformError, NotImplementedError, AccountNotFoundError, NotFoundError, InvalidRequestError, ScriptError, TimeoutError, AbortedError, } from './errors';
|
|
7
|
-
export type { OutlookErrorCode } from './errors';
|
|
8
|
-
export { mailFolderRef, splitQuotedOriginal, WELL_KNOWN_FOLDERS } from './mail';
|
|
9
|
-
export
|
|
10
|
-
export {
|
|
11
|
-
export type {
|
|
6
|
+
export { OutlookError, UnsupportedPlatformError, NotImplementedError, AccountNotFoundError, NotFoundError, InvalidRequestError, ScriptError, OutputTooLargeError, TimeoutError, AbortedError, } from './errors';
|
|
7
|
+
export type { OutlookErrorCode, NotFoundKind, ScriptRunner } from './errors';
|
|
8
|
+
export { hasReplyPrefix, mailFolderRef, splitQuotedOriginal, threadSubject, WELL_KNOWN_FOLDERS } from './mail';
|
|
9
|
+
export { composeTemplateBody, findTemplateMarkers, findTokens, findUnfilledTokens, removeTokenLine, replaceToken, } from './templateBody';
|
|
10
|
+
export type { ComposeOptions, TemplateMarkers } from './templateBody';
|
|
11
|
+
export type { OutlookBridge, BridgeCapability, CapabilityMap, EmailLocator, EmailRef, Recipients, SendEmailParams, SendEmailResult, ReplyEmailParams, ReplyEmailResult, ItemFailure, ReadInboxOptions, InboxEmail, InboxSearchFilter, InboxSearchMatch, EmailDescription, LocateEmailOptions, SelectedEmail, ReadEmailBodyOptions, EmailBodyResult, MailFolderRef, ListFoldersOptions, InboxFolderInfo, MoveEmailsOptions, MoveEmailsResult, ListDraftsOptions, ListDraftsResult, OutlookDraft, SendDraftsResult, DeleteDraftsResult, DeleteMailOptions, DeleteMailOutcome, DeleteMailResult, PurgeDeletedItemsOptions, PurgeDeletedItemsResult, SaveAttachmentOptions, SavedAttachment, CleanUndeliverableOptions, CleanUndeliverableResult, UndeliverableEmail, CollectBouncedRecipientsOptions, SentRecipientGroupsOptions, SentRecipientGroup, BounceReportOptions, BounceReport, BouncedSend, ReadTemplatesOptions, TemplateEmail, TemplateFolderResult, SaveTemplateParams, SaveTemplateResult, } from './types';
|
package/dist/index.js
CHANGED
|
@@ -1,50 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
Object.defineProperty(exports, "
|
|
16
|
-
|
|
17
|
-
Object.defineProperty(exports, "listInboxFolders", { enumerable: true, get: function () { return OutlookService_1.listInboxFolders; } });
|
|
18
|
-
Object.defineProperty(exports, "moveOutlookEmails", { enumerable: true, get: function () { return OutlookService_1.moveOutlookEmails; } });
|
|
19
|
-
Object.defineProperty(exports, "listOutlookDrafts", { enumerable: true, get: function () { return OutlookService_1.listOutlookDrafts; } });
|
|
20
|
-
Object.defineProperty(exports, "deleteOutlookDrafts", { enumerable: true, get: function () { return OutlookService_1.deleteOutlookDrafts; } });
|
|
21
|
-
Object.defineProperty(exports, "sendDrafts", { enumerable: true, get: function () { return OutlookService_1.sendDrafts; } });
|
|
22
|
-
Object.defineProperty(exports, "deleteOutlookEmails", { enumerable: true, get: function () { return OutlookService_1.deleteOutlookEmails; } });
|
|
23
|
-
Object.defineProperty(exports, "purgeDeletedItems", { enumerable: true, get: function () { return OutlookService_1.purgeDeletedItems; } });
|
|
24
|
-
Object.defineProperty(exports, "saveEmailAttachment", { enumerable: true, get: function () { return OutlookService_1.saveEmailAttachment; } });
|
|
25
|
-
Object.defineProperty(exports, "saveEmailAttachmentDetailed", { enumerable: true, get: function () { return OutlookService_1.saveEmailAttachmentDetailed; } });
|
|
26
|
-
Object.defineProperty(exports, "saveEmailAttachments", { enumerable: true, get: function () { return OutlookService_1.saveEmailAttachments; } });
|
|
27
|
-
Object.defineProperty(exports, "cleanUndeliverableEmails", { enumerable: true, get: function () { return OutlookService_1.cleanUndeliverableEmails; } });
|
|
28
|
-
Object.defineProperty(exports, "collectBouncedRecipients", { enumerable: true, get: function () { return OutlookService_1.collectBouncedRecipients; } });
|
|
29
|
-
Object.defineProperty(exports, "readSentRecipientGroups", { enumerable: true, get: function () { return OutlookService_1.readSentRecipientGroups; } });
|
|
30
|
-
Object.defineProperty(exports, "listOutlookSignatures", { enumerable: true, get: function () { return OutlookService_1.listOutlookSignatures; } });
|
|
31
|
-
Object.defineProperty(exports, "readOutlookSignatureHtml", { enumerable: true, get: function () { return OutlookService_1.readOutlookSignatureHtml; } });
|
|
32
|
-
Object.defineProperty(exports, "readTemplateEmails", { enumerable: true, get: function () { return OutlookService_1.readTemplateEmails; } });
|
|
33
|
-
Object.defineProperty(exports, "saveTemplateEmail", { enumerable: true, get: function () { return OutlookService_1.saveTemplateEmail; } });
|
|
34
|
-
Object.defineProperty(exports, "editEmailTemplate", { enumerable: true, get: function () { return OutlookService_1.editEmailTemplate; } });
|
|
35
|
-
// A bridge with its own settings, isolated from every other caller in the
|
|
36
|
-
// process — and capability discovery, so a consumer can ask what works here
|
|
37
|
-
// instead of finding out by calling.
|
|
38
|
-
var OutlookService_2 = require("./OutlookService");
|
|
39
|
-
Object.defineProperty(exports, "createOutlookBridge", { enumerable: true, get: function () { return OutlookService_2.createOutlookBridge; } });
|
|
40
|
-
Object.defineProperty(exports, "capabilities", { enumerable: true, get: function () { return OutlookService_2.capabilities; } });
|
|
41
|
-
Object.defineProperty(exports, "supports", { enumerable: true, get: function () { return OutlookService_2.supports; } });
|
|
42
|
-
// Process-wide settings: run timeouts, the stdout cap, cancellation, where
|
|
43
|
-
// scratch files and saved attachments go, and a hook that hands you every
|
|
44
|
-
// generated script. Prefer createOutlookBridge in shared processes.
|
|
3
|
+
exports.findTokens = exports.findTemplateMarkers = exports.composeTemplateBody = exports.WELL_KNOWN_FOLDERS = exports.threadSubject = exports.splitQuotedOriginal = exports.mailFolderRef = exports.hasReplyPrefix = exports.AbortedError = exports.TimeoutError = exports.OutputTooLargeError = exports.ScriptError = exports.InvalidRequestError = exports.NotFoundError = exports.AccountNotFoundError = exports.NotImplementedError = exports.UnsupportedPlatformError = exports.OutlookError = exports.configure = exports.supports = exports.capabilities = exports.createOutlookBridge = exports.editEmailTemplate = exports.saveTemplateEmail = exports.readTemplateEmails = exports.readOutlookSignatureHtml = exports.listOutlookSignatures = exports.readBounceReport = exports.readSentRecipientGroups = exports.collectBouncedRecipients = exports.cleanUndeliverableEmails = exports.saveEmailAttachments = exports.saveEmailAttachment = exports.purgeDeletedItems = exports.deleteOutlookEmails = exports.deleteOutlookDrafts = exports.sendAllDrafts = exports.sendDrafts = exports.listOutlookDrafts = exports.moveOutlookEmails = exports.listInboxFolders = exports.locateEmail = exports.openOutlookEmail = exports.readEmailBody = exports.readSelectedEmail = exports.searchInboxByFilter = exports.readInboxEmails = exports.replyOutlookEmail = exports.sendOutlookEmail = exports.getOutlookAccounts = void 0;
|
|
4
|
+
exports.replaceToken = exports.removeTokenLine = exports.findUnfilledTokens = void 0;
|
|
5
|
+
// The public API. Listed explicitly rather than `export *`, so the package
|
|
6
|
+
// exposes only what it means to support; the `exports` map in package.json
|
|
7
|
+
// closes the deep-import path around it.
|
|
8
|
+
const bridge_1 = require("./bridge");
|
|
9
|
+
// Every operation as a plain function, running under the process-wide settings.
|
|
10
|
+
exports.getOutlookAccounts = bridge_1.defaultBridge.getOutlookAccounts, exports.sendOutlookEmail = bridge_1.defaultBridge.sendOutlookEmail, exports.replyOutlookEmail = bridge_1.defaultBridge.replyOutlookEmail, exports.readInboxEmails = bridge_1.defaultBridge.readInboxEmails, exports.searchInboxByFilter = bridge_1.defaultBridge.searchInboxByFilter, exports.readSelectedEmail = bridge_1.defaultBridge.readSelectedEmail, exports.readEmailBody = bridge_1.defaultBridge.readEmailBody, exports.openOutlookEmail = bridge_1.defaultBridge.openOutlookEmail, exports.locateEmail = bridge_1.defaultBridge.locateEmail, exports.listInboxFolders = bridge_1.defaultBridge.listInboxFolders, exports.moveOutlookEmails = bridge_1.defaultBridge.moveOutlookEmails, exports.listOutlookDrafts = bridge_1.defaultBridge.listOutlookDrafts, exports.sendDrafts = bridge_1.defaultBridge.sendDrafts, exports.sendAllDrafts = bridge_1.defaultBridge.sendAllDrafts, exports.deleteOutlookDrafts = bridge_1.defaultBridge.deleteOutlookDrafts, exports.deleteOutlookEmails = bridge_1.defaultBridge.deleteOutlookEmails, exports.purgeDeletedItems = bridge_1.defaultBridge.purgeDeletedItems, exports.saveEmailAttachment = bridge_1.defaultBridge.saveEmailAttachment, exports.saveEmailAttachments = bridge_1.defaultBridge.saveEmailAttachments, exports.cleanUndeliverableEmails = bridge_1.defaultBridge.cleanUndeliverableEmails, exports.collectBouncedRecipients = bridge_1.defaultBridge.collectBouncedRecipients, exports.readSentRecipientGroups = bridge_1.defaultBridge.readSentRecipientGroups, exports.readBounceReport = bridge_1.defaultBridge.readBounceReport, exports.listOutlookSignatures = bridge_1.defaultBridge.listOutlookSignatures, exports.readOutlookSignatureHtml = bridge_1.defaultBridge.readOutlookSignatureHtml, exports.readTemplateEmails = bridge_1.defaultBridge.readTemplateEmails, exports.saveTemplateEmail = bridge_1.defaultBridge.saveTemplateEmail, exports.editEmailTemplate = bridge_1.defaultBridge.editEmailTemplate;
|
|
11
|
+
// A bridge with its own settings, and asking what works on this machine.
|
|
12
|
+
var bridge_2 = require("./bridge");
|
|
13
|
+
Object.defineProperty(exports, "createOutlookBridge", { enumerable: true, get: function () { return bridge_2.createOutlookBridge; } });
|
|
14
|
+
Object.defineProperty(exports, "capabilities", { enumerable: true, get: function () { return bridge_2.capabilities; } });
|
|
15
|
+
Object.defineProperty(exports, "supports", { enumerable: true, get: function () { return bridge_2.supports; } });
|
|
16
|
+
// Process-wide settings.
|
|
45
17
|
var runtime_1 = require("./runtime");
|
|
46
18
|
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return runtime_1.configure; } });
|
|
47
|
-
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return runtime_1.getConfig; } });
|
|
48
19
|
// Failures carry a stable `code`; the messages beside them are not an API.
|
|
49
20
|
var errors_1 = require("./errors");
|
|
50
21
|
Object.defineProperty(exports, "OutlookError", { enumerable: true, get: function () { return errors_1.OutlookError; } });
|
|
@@ -54,19 +25,21 @@ Object.defineProperty(exports, "AccountNotFoundError", { enumerable: true, get:
|
|
|
54
25
|
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_1.NotFoundError; } });
|
|
55
26
|
Object.defineProperty(exports, "InvalidRequestError", { enumerable: true, get: function () { return errors_1.InvalidRequestError; } });
|
|
56
27
|
Object.defineProperty(exports, "ScriptError", { enumerable: true, get: function () { return errors_1.ScriptError; } });
|
|
28
|
+
Object.defineProperty(exports, "OutputTooLargeError", { enumerable: true, get: function () { return errors_1.OutputTooLargeError; } });
|
|
57
29
|
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
|
|
58
30
|
Object.defineProperty(exports, "AbortedError", { enumerable: true, get: function () { return errors_1.AbortedError; } });
|
|
59
|
-
// Platform-neutral helpers, usable without
|
|
60
|
-
// pieces of parsing a caller most often needs to reproduce.
|
|
31
|
+
// Platform-neutral helpers, usable without Outlook.
|
|
61
32
|
var mail_1 = require("./mail");
|
|
33
|
+
Object.defineProperty(exports, "hasReplyPrefix", { enumerable: true, get: function () { return mail_1.hasReplyPrefix; } });
|
|
62
34
|
Object.defineProperty(exports, "mailFolderRef", { enumerable: true, get: function () { return mail_1.mailFolderRef; } });
|
|
63
35
|
Object.defineProperty(exports, "splitQuotedOriginal", { enumerable: true, get: function () { return mail_1.splitQuotedOriginal; } });
|
|
36
|
+
Object.defineProperty(exports, "threadSubject", { enumerable: true, get: function () { return mail_1.threadSubject; } });
|
|
64
37
|
Object.defineProperty(exports, "WELL_KNOWN_FOLDERS", { enumerable: true, get: function () { return mail_1.WELL_KNOWN_FOLDERS; } });
|
|
65
|
-
var
|
|
66
|
-
Object.defineProperty(exports, "
|
|
67
|
-
Object.defineProperty(exports, "
|
|
68
|
-
Object.defineProperty(exports, "
|
|
69
|
-
Object.defineProperty(exports, "
|
|
70
|
-
Object.defineProperty(exports, "
|
|
71
|
-
Object.defineProperty(exports, "
|
|
38
|
+
var templateBody_1 = require("./templateBody");
|
|
39
|
+
Object.defineProperty(exports, "composeTemplateBody", { enumerable: true, get: function () { return templateBody_1.composeTemplateBody; } });
|
|
40
|
+
Object.defineProperty(exports, "findTemplateMarkers", { enumerable: true, get: function () { return templateBody_1.findTemplateMarkers; } });
|
|
41
|
+
Object.defineProperty(exports, "findTokens", { enumerable: true, get: function () { return templateBody_1.findTokens; } });
|
|
42
|
+
Object.defineProperty(exports, "findUnfilledTokens", { enumerable: true, get: function () { return templateBody_1.findUnfilledTokens; } });
|
|
43
|
+
Object.defineProperty(exports, "removeTokenLine", { enumerable: true, get: function () { return templateBody_1.removeTokenLine; } });
|
|
44
|
+
Object.defineProperty(exports, "replaceToken", { enumerable: true, get: function () { return templateBody_1.replaceToken; } });
|
|
72
45
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,yCAAyC;AACzC,qCAAyC;AAEzC,gFAAgF;AAE5E,0BAAkB,GA4BlB,sBAAa,qBA3Bb,wBAAgB,GA2BhB,sBAAa,mBA1Bb,yBAAiB,GA0BjB,sBAAa,oBAzBb,uBAAe,GAyBf,sBAAa,kBAxBb,2BAAmB,GAwBnB,sBAAa,sBAvBb,yBAAiB,GAuBjB,sBAAa,oBAtBb,qBAAa,GAsBb,sBAAa,gBArBb,wBAAgB,GAqBhB,sBAAa,mBApBb,mBAAW,GAoBX,sBAAa,cAnBb,wBAAgB,GAmBhB,sBAAa,mBAlBb,yBAAiB,GAkBjB,sBAAa,oBAjBb,yBAAiB,GAiBjB,sBAAa,oBAhBb,kBAAU,GAgBV,sBAAa,aAfb,qBAAa,GAeb,sBAAa,gBAdb,2BAAmB,GAcnB,sBAAa,sBAbb,2BAAmB,GAanB,sBAAa,sBAZb,yBAAiB,GAYjB,sBAAa,oBAXb,2BAAmB,GAWnB,sBAAa,sBAVb,4BAAoB,GAUpB,sBAAa,uBATb,gCAAwB,GASxB,sBAAa,2BARb,gCAAwB,GAQxB,sBAAa,2BAPb,+BAAuB,GAOvB,sBAAa,0BANb,wBAAgB,GAMhB,sBAAa,mBALb,6BAAqB,GAKrB,sBAAa,wBAJb,gCAAwB,GAIxB,sBAAa,2BAHb,0BAAkB,GAGlB,sBAAa,qBAFb,yBAAiB,GAEjB,sBAAa,oBADb,yBAAiB,GACjB,sBAAa,mBAAC;AAElB,yEAAyE;AACzE,mCAAuE;AAA9D,6GAAA,mBAAmB,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAGpD,yBAAyB;AACzB,qCAAsC;AAA7B,oGAAA,SAAS,OAAA;AAGlB,2EAA2E;AAC3E,mCAWkB;AAVd,sGAAA,YAAY,OAAA;AACZ,kHAAA,wBAAwB,OAAA;AACxB,6GAAA,mBAAmB,OAAA;AACnB,8GAAA,oBAAoB,OAAA;AACpB,uGAAA,aAAa,OAAA;AACb,6GAAA,mBAAmB,OAAA;AACnB,qGAAA,WAAW,OAAA;AACX,6GAAA,mBAAmB,OAAA;AACnB,sGAAA,YAAY,OAAA;AACZ,sGAAA,YAAY,OAAA;AAIhB,oDAAoD;AACpD,+BAA+G;AAAtG,sGAAA,cAAc,OAAA;AAAE,qGAAA,aAAa,OAAA;AAAE,2GAAA,mBAAmB,OAAA;AAAE,qGAAA,aAAa,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAC9F,+CAOwB;AANpB,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAAA;AACnB,0GAAA,UAAU,OAAA;AACV,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AACf,4GAAA,YAAY,OAAA","sourcesContent":["// The public API. Listed explicitly rather than `export *`, so the package\n// exposes only what it means to support; the `exports` map in package.json\n// closes the deep-import path around it.\nimport { defaultBridge } from './bridge';\n\n// Every operation as a plain function, running under the process-wide settings.\nexport const {\n getOutlookAccounts,\n sendOutlookEmail,\n replyOutlookEmail,\n readInboxEmails,\n searchInboxByFilter,\n readSelectedEmail,\n readEmailBody,\n openOutlookEmail,\n locateEmail,\n listInboxFolders,\n moveOutlookEmails,\n listOutlookDrafts,\n sendDrafts,\n sendAllDrafts,\n deleteOutlookDrafts,\n deleteOutlookEmails,\n purgeDeletedItems,\n saveEmailAttachment,\n saveEmailAttachments,\n cleanUndeliverableEmails,\n collectBouncedRecipients,\n readSentRecipientGroups,\n readBounceReport,\n listOutlookSignatures,\n readOutlookSignatureHtml,\n readTemplateEmails,\n saveTemplateEmail,\n editEmailTemplate,\n} = defaultBridge;\n\n// A bridge with its own settings, and asking what works on this machine.\nexport { createOutlookBridge, capabilities, supports } from './bridge';\nexport type { OutlookBridgeInstance } from './bridge';\n\n// Process-wide settings.\nexport { configure } from './runtime';\nexport type { BridgeOptions, BridgeDebugEvent, ResolvedConfig } from './runtime';\n\n// Failures carry a stable `code`; the messages beside them are not an API.\nexport {\n OutlookError,\n UnsupportedPlatformError,\n NotImplementedError,\n AccountNotFoundError,\n NotFoundError,\n InvalidRequestError,\n ScriptError,\n OutputTooLargeError,\n TimeoutError,\n AbortedError,\n} from './errors';\nexport type { OutlookErrorCode, NotFoundKind, ScriptRunner } from './errors';\n\n// Platform-neutral helpers, usable without Outlook.\nexport { hasReplyPrefix, mailFolderRef, splitQuotedOriginal, threadSubject, WELL_KNOWN_FOLDERS } from './mail';\nexport {\n composeTemplateBody,\n findTemplateMarkers,\n findTokens,\n findUnfilledTokens,\n removeTokenLine,\n replaceToken,\n} from './templateBody';\nexport type { ComposeOptions, TemplateMarkers } from './templateBody';\n\nexport type {\n OutlookBridge,\n BridgeCapability,\n CapabilityMap,\n EmailLocator,\n EmailRef,\n Recipients,\n SendEmailParams,\n SendEmailResult,\n ReplyEmailParams,\n ReplyEmailResult,\n ItemFailure,\n ReadInboxOptions,\n InboxEmail,\n InboxSearchFilter,\n InboxSearchMatch,\n EmailDescription,\n LocateEmailOptions,\n SelectedEmail,\n ReadEmailBodyOptions,\n EmailBodyResult,\n MailFolderRef,\n ListFoldersOptions,\n InboxFolderInfo,\n MoveEmailsOptions,\n MoveEmailsResult,\n ListDraftsOptions,\n ListDraftsResult,\n OutlookDraft,\n SendDraftsResult,\n DeleteDraftsResult,\n DeleteMailOptions,\n DeleteMailOutcome,\n DeleteMailResult,\n PurgeDeletedItemsOptions,\n PurgeDeletedItemsResult,\n SaveAttachmentOptions,\n SavedAttachment,\n CleanUndeliverableOptions,\n CleanUndeliverableResult,\n UndeliverableEmail,\n CollectBouncedRecipientsOptions,\n SentRecipientGroupsOptions,\n SentRecipientGroup,\n BounceReportOptions,\n BounceReport,\n BouncedSend,\n ReadTemplatesOptions,\n TemplateEmail,\n TemplateFolderResult,\n SaveTemplateParams,\n SaveTemplateResult,\n} from './types';\n"]}
|
package/dist/mac/accounts.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Every mailbox's SMTP address. Empty under New Outlook, which doesn't expose
|
|
3
|
+
* accounts to AppleScript.
|
|
4
|
+
*
|
|
5
|
+
* The dictionary's three account classes aren't the whole profile: a Microsoft
|
|
6
|
+
* 365 mailbox added by the modern sync engine belongs to none of them. So the
|
|
7
|
+
* profile database is asked as well and the answers merged — the script's
|
|
8
|
+
* first, since those are the accounts every operation supports fully.
|
|
4
9
|
*/
|
|
5
10
|
export declare function getOutlookAccounts(): Promise<string[]>;
|
package/dist/mac/accounts.js
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOutlookAccounts = getOutlookAccounts;
|
|
4
|
+
// The mailboxes Outlook for Mac can reach.
|
|
4
5
|
const run_1 = require("./run");
|
|
6
|
+
const profile_1 = require("./profile");
|
|
5
7
|
const scripts_1 = require("./scripts");
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* Every mailbox's SMTP address. Empty under New Outlook, which doesn't expose
|
|
10
|
+
* accounts to AppleScript.
|
|
11
|
+
*
|
|
12
|
+
* The dictionary's three account classes aren't the whole profile: a Microsoft
|
|
13
|
+
* 365 mailbox added by the modern sync engine belongs to none of them. So the
|
|
14
|
+
* profile database is asked as well and the answers merged — the script's
|
|
15
|
+
* first, since those are the accounts every operation supports fully.
|
|
9
16
|
*/
|
|
10
17
|
async function getOutlookAccounts() {
|
|
11
|
-
const
|
|
18
|
+
const [raw, profile] = await Promise.all([
|
|
19
|
+
(0, run_1.runOsaScript)(`${scripts_1.LIST_ACCOUNTS_SNIPPET}
|
|
12
20
|
set AppleScript's text item delimiters to linefeed
|
|
13
|
-
return acctList as string
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
return acctList as string`, 'quick'),
|
|
22
|
+
(0, profile_1.readProfileAccounts)(),
|
|
23
|
+
]);
|
|
24
|
+
const accounts = raw.split('\n').map(s => s.trim()).filter(Boolean);
|
|
25
|
+
const seen = new Set(accounts.map(a => a.toLowerCase()));
|
|
26
|
+
for (const { emailAccount } of profile) {
|
|
27
|
+
if (seen.has(emailAccount.toLowerCase()))
|
|
28
|
+
continue;
|
|
29
|
+
seen.add(emailAccount.toLowerCase());
|
|
30
|
+
accounts.push(emailAccount);
|
|
31
|
+
}
|
|
32
|
+
return accounts;
|
|
16
33
|
}
|
|
17
34
|
//# sourceMappingURL=accounts.js.map
|
package/dist/mac/accounts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/mac/accounts.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/mac/accounts.ts"],"names":[],"mappings":";;AAcA,gDAeC;AA7BD,2CAA2C;AAC3C,+BAAqC;AACrC,uCAAgD;AAChD,uCAAkD;AAElD;;;;;;;;GAQG;AACI,KAAK,UAAU,kBAAkB;IACpC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACrC,IAAA,kBAAY,EAAC,GAAG,+BAAqB;;0BAEnB,EAAE,OAAO,CAAC;QAC5B,IAAA,6BAAmB,GAAE;KACxB,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACzD,KAAK,MAAM,EAAE,YAAY,EAAE,IAAI,OAAO,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;YAAE,SAAS;QACnD,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;QACrC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC","sourcesContent":["// The mailboxes Outlook for Mac can reach.\nimport { runOsaScript } from './run';\nimport { readProfileAccounts } from './profile';\nimport { LIST_ACCOUNTS_SNIPPET } from './scripts';\n\n/**\n * Every mailbox's SMTP address. Empty under New Outlook, which doesn't expose\n * accounts to AppleScript.\n *\n * The dictionary's three account classes aren't the whole profile: a Microsoft\n * 365 mailbox added by the modern sync engine belongs to none of them. So the\n * profile database is asked as well and the answers merged — the script's\n * first, since those are the accounts every operation supports fully.\n */\nexport async function getOutlookAccounts(): Promise<string[]> {\n const [raw, profile] = await Promise.all([\n runOsaScript(`${LIST_ACCOUNTS_SNIPPET}\nset AppleScript's text item delimiters to linefeed\nreturn acctList as string`, 'quick'),\n readProfileAccounts(),\n ]);\n const accounts = raw.split('\\n').map(s => s.trim()).filter(Boolean);\n const seen = new Set(accounts.map(a => a.toLowerCase()));\n for (const { emailAccount } of profile) {\n if (seen.has(emailAccount.toLowerCase())) continue;\n seen.add(emailAccount.toLowerCase());\n accounts.push(emailAccount);\n }\n return accounts;\n}\n"]}
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
+
import type { SaveAttachmentsRequest } from '../backend';
|
|
1
2
|
import type { SavedAttachment } from '../types';
|
|
2
3
|
/**
|
|
3
|
-
* Save
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `destDir` is created if absent. Without one the file lands in a fresh directory
|
|
8
|
-
* of its own, because attachments keep the name the sender gave them: a single
|
|
9
|
-
* shared folder means two emails carrying "invoice.pdf" silently overwrite each
|
|
10
|
-
* other. Pass `destDir` whenever you want the files somewhere you control.
|
|
11
|
-
*
|
|
12
|
-
* When the attachment isn't found, throws an error that names the email actually
|
|
13
|
-
* resolved (from/subject/received) and the attachments it does carry — a message
|
|
14
|
-
* id can go stale, and a bare "not found" would point at the wrong problem.
|
|
4
|
+
* Save the named attachments of one email, in the order named. Every name is
|
|
5
|
+
* matched before anything is written, so a batch with one bad name fails
|
|
6
|
+
* without having saved half its files.
|
|
15
7
|
*/
|
|
16
|
-
export declare function
|
|
17
|
-
/** Save an attachment and return just the saved file path. */
|
|
18
|
-
export declare function saveEmailAttachment(entryId: string, fileName: string, storeId?: string, destDir?: string): Promise<string>;
|
|
19
|
-
/**
|
|
20
|
-
* Save several attachments from one email in a single pair of runs — what a
|
|
21
|
-
* caller working through searchInboxByFilter/readSelectedEmail results wants,
|
|
22
|
-
* rather than paying an osascript spawn per attachment. Destination, matching
|
|
23
|
-
* and the not-found error follow saveEmailAttachmentDetailed's rules exactly,
|
|
24
|
-
* applied per name; results come back in the same order as `fileNames`.
|
|
25
|
-
*
|
|
26
|
-
* `storeId` is accepted for signature parity and ignored: macOS has no StoreID.
|
|
27
|
-
*/
|
|
28
|
-
export declare function saveEmailAttachments(entryId: string, fileNames: string[], _storeId?: string, destDir?: string): Promise<SavedAttachment[]>;
|
|
8
|
+
export declare function saveEmailAttachments(request: SaveAttachmentsRequest): Promise<SavedAttachment[]>;
|
package/dist/mac/attachments.js
CHANGED
|
@@ -3,118 +3,59 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.saveEmailAttachmentDetailed = saveEmailAttachmentDetailed;
|
|
7
|
-
exports.saveEmailAttachment = saveEmailAttachment;
|
|
8
6
|
exports.saveEmailAttachments = saveEmailAttachments;
|
|
9
|
-
// Saving attachments off an email
|
|
7
|
+
// Saving attachments off an email.
|
|
10
8
|
//
|
|
11
|
-
// Two runs
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
9
|
+
// Two runs: the first reads the email's identity and attachment names, the
|
|
10
|
+
// matching and file naming happen in TypeScript against shared/attachmentMatch,
|
|
11
|
+
// and the second run saves what matched. That keeps one definition of "does this
|
|
12
|
+
// name match", one wording for the error, and one file-naming rule.
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
14
|
const run_1 = require("./run");
|
|
16
15
|
const scripts_1 = require("./scripts");
|
|
17
16
|
const attachmentMatch_1 = require("../shared/attachmentMatch");
|
|
18
|
-
const runtime_1 = require("../runtime");
|
|
19
17
|
const errors_1 = require("../errors");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Save the named attachments of one email, in the order named. Every name is
|
|
20
|
+
* matched before anything is written, so a batch with one bad name fails
|
|
21
|
+
* without having saved half its files.
|
|
22
|
+
*/
|
|
23
|
+
async function saveEmailAttachments(request) {
|
|
24
|
+
const id = (0, scripts_1.macMessageId)(request.email.entryId);
|
|
25
|
+
const parts = (0, run_1.summaryFields)(await (0, run_1.runOsaScript)(`tell application "Microsoft Outlook"
|
|
24
26
|
${(0, scripts_1.messageLookupSnippet)(id)}
|
|
25
27
|
${(0, scripts_1.messageDetailSnippet)()}
|
|
26
28
|
return ${(0, run_1.asRow)((0, scripts_1.messageDetailFields)())}
|
|
27
|
-
end tell
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
subject: (0, run_1.field)(parts, scripts_1.MessageDetail.subject),
|
|
29
|
+
end tell`, 'quick'));
|
|
30
|
+
const email = {
|
|
31
|
+
subject: (0, run_1.field)(parts, scripts_1.MessageDetail.subject).trim(),
|
|
31
32
|
senderName: (0, run_1.field)(parts, scripts_1.MessageDetail.senderName),
|
|
32
33
|
senderEmail: (0, run_1.field)(parts, scripts_1.MessageDetail.senderEmail),
|
|
33
34
|
receivedTime: (0, run_1.field)(parts, scripts_1.MessageDetail.receivedTime),
|
|
34
|
-
attachmentNames: (0, run_1.splitList)((0, run_1.field)(parts, scripts_1.MessageDetail.attachmentNames)),
|
|
35
35
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
subject: email.subject,
|
|
48
|
-
receivedTime: email.receivedTime,
|
|
49
|
-
present: email.attachmentNames.join(', ') || '(none)',
|
|
50
|
-
idLabel: 'message id',
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
return index;
|
|
54
|
-
}
|
|
55
|
-
/** Save the attachments at the given 1-based indices to `outDir`. */
|
|
56
|
-
async function saveByIndex(id, picks, outDir) {
|
|
57
|
-
const saveLines = picks.map(pick => ` save (item ${pick.index + 1} of attachments of theMsg) in POSIX file "${(0, run_1.asEscape)(path_1.default.join(outDir, pick.name))}"`);
|
|
58
|
-
const script = `
|
|
59
|
-
tell application "Microsoft Outlook"
|
|
60
|
-
${(0, scripts_1.messageLookupSnippet)(id)}
|
|
61
|
-
${saveLines.join('\n')}
|
|
62
|
-
end tell`;
|
|
63
|
-
await (0, run_1.runOsaScript)(script, 120000);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Save an email attachment by message id and filename, returning the saved path
|
|
67
|
-
* together with the resolved email's subject/sender so the caller can confirm the
|
|
68
|
-
* file came from the email it intended.
|
|
69
|
-
*
|
|
70
|
-
* `destDir` is created if absent. Without one the file lands in a fresh directory
|
|
71
|
-
* of its own, because attachments keep the name the sender gave them: a single
|
|
72
|
-
* shared folder means two emails carrying "invoice.pdf" silently overwrite each
|
|
73
|
-
* other. Pass `destDir` whenever you want the files somewhere you control.
|
|
74
|
-
*
|
|
75
|
-
* When the attachment isn't found, throws an error that names the email actually
|
|
76
|
-
* resolved (from/subject/received) and the attachments it does carry — a message
|
|
77
|
-
* id can go stale, and a bare "not found" would point at the wrong problem.
|
|
78
|
-
*/
|
|
79
|
-
async function saveEmailAttachmentDetailed(entryId, fileName, _storeId, destDir) {
|
|
80
|
-
const results = await saveEmailAttachments(entryId, [fileName], _storeId, destDir);
|
|
81
|
-
if (results.length === 0) {
|
|
82
|
-
throw new errors_1.NotFoundError('attachment', 'Failed to save attachment.');
|
|
83
|
-
}
|
|
84
|
-
return results[0];
|
|
85
|
-
}
|
|
86
|
-
/** Save an attachment and return just the saved file path. */
|
|
87
|
-
async function saveEmailAttachment(entryId, fileName, storeId, destDir) {
|
|
88
|
-
return (await saveEmailAttachmentDetailed(entryId, fileName, storeId, destDir)).path;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Save several attachments from one email in a single pair of runs — what a
|
|
92
|
-
* caller working through searchInboxByFilter/readSelectedEmail results wants,
|
|
93
|
-
* rather than paying an osascript spawn per attachment. Destination, matching
|
|
94
|
-
* and the not-found error follow saveEmailAttachmentDetailed's rules exactly,
|
|
95
|
-
* applied per name; results come back in the same order as `fileNames`.
|
|
96
|
-
*
|
|
97
|
-
* `storeId` is accepted for signature parity and ignored: macOS has no StoreID.
|
|
98
|
-
*/
|
|
99
|
-
async function saveEmailAttachments(entryId, fileNames, _storeId, destDir) {
|
|
100
|
-
if (fileNames.length === 0)
|
|
101
|
-
return [];
|
|
102
|
-
const id = (0, scripts_1.macMessageId)(entryId);
|
|
103
|
-
const email = await resolveEmail(id);
|
|
104
|
-
// Resolve every name BEFORE saving anything, so a batch with one bad name
|
|
105
|
-
// fails without having written half its files.
|
|
106
|
-
const picks = fileNames.map(fileName => {
|
|
107
|
-
const index = requireAttachmentIndex(email, fileName);
|
|
108
|
-
return { index, name: email.attachmentNames[index] };
|
|
36
|
+
const attachmentNames = (0, run_1.splitPositionalList)((0, run_1.field)(parts, scripts_1.MessageDetail.attachmentNames));
|
|
37
|
+
const picks = request.fileNames.map(fileName => {
|
|
38
|
+
const index = (0, attachmentMatch_1.findAttachmentIndex)(attachmentNames, fileName);
|
|
39
|
+
if (index === -1) {
|
|
40
|
+
throw new errors_1.NotFoundError('attachment', (0, attachmentMatch_1.attachmentNotFoundMessage)({
|
|
41
|
+
fileName,
|
|
42
|
+
...email,
|
|
43
|
+
present: attachmentNames.join(', ') || '(none)',
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
return { index, fileName: attachmentNames[index] };
|
|
109
47
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
48
|
+
// Paths are claimed as they are chosen, so two picks with one name don't collide.
|
|
49
|
+
const claimed = new Set();
|
|
50
|
+
const saves = picks.map(pick => {
|
|
51
|
+
const file = (0, attachmentMatch_1.uniqueSavePath)(request.destDir, (0, attachmentMatch_1.safeFileName)(pick.fileName), path => claimed.has(path) || fs_1.default.existsSync(path));
|
|
52
|
+
claimed.add(file);
|
|
53
|
+
return { ...pick, path: file };
|
|
54
|
+
});
|
|
55
|
+
await (0, run_1.runOsaScript)(`tell application "Microsoft Outlook"
|
|
56
|
+
${(0, scripts_1.messageLookupSnippet)(id)}
|
|
57
|
+
${saves.map(save => ` save (item ${(0, run_1.asInt)(save.index + 1)} of attachments of theMsg) in POSIX file ${(0, run_1.asString)(save.path)}`).join('\n')}
|
|
58
|
+
end tell`, 'standard');
|
|
59
|
+
return saves.map(save => ({ path: save.path, fileName: save.fileName, ...email }));
|
|
119
60
|
}
|
|
120
61
|
//# sourceMappingURL=attachments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../src/mac/attachments.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../src/mac/attachments.ts"],"names":[],"mappings":";;;;;AA8BA,oDAuCC;AArED,mCAAmC;AACnC,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;AAChF,iFAAiF;AACjF,oEAAoE;AACpE,4CAAoB;AACpB,+BAAwG;AACxG,uCAMmB;AACnB,+DAKmC;AACnC,sCAA0C;AAI1C;;;;GAIG;AACI,KAAK,UAAU,oBAAoB,CAAC,OAA+B;IACtE,MAAM,EAAE,GAAG,IAAA,sBAAY,EAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAA,mBAAa,EAAC,MAAM,IAAA,kBAAY,EAAC;EACjD,IAAA,8BAAoB,EAAC,EAAE,CAAC;EACxB,IAAA,8BAAoB,GAAE;aACX,IAAA,WAAK,EAAC,IAAA,6BAAmB,GAAE,CAAC;SAChC,EAAE,OAAO,CAAC,CAAC,CAAC;IACjB,MAAM,KAAK,GAAG;QACV,OAAO,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,uBAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE;QACnD,UAAU,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,uBAAa,CAAC,UAAU,CAAC;QAClD,WAAW,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,uBAAa,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,uBAAa,CAAC,YAAY,CAAC;KACzD,CAAC;IACF,MAAM,eAAe,GAAG,IAAA,yBAAmB,EAAC,IAAA,WAAK,EAAC,KAAK,EAAE,uBAAa,CAAC,eAAe,CAAC,CAAC,CAAC;IAEzF,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;QAC3C,MAAM,KAAK,GAAG,IAAA,qCAAmB,EAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAC7D,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,MAAM,IAAI,sBAAa,CAAC,YAAY,EAAE,IAAA,2CAAyB,EAAC;gBAC5D,QAAQ;gBACR,GAAG,KAAK;gBACR,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ;aAClD,CAAC,CAAC,CAAC;QACR,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,kFAAkF;IAClF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC3B,MAAM,IAAI,GAAG,IAAA,gCAAc,EAAC,OAAO,CAAC,OAAO,EAAE,IAAA,8BAAY,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5H,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,MAAM,IAAA,kBAAY,EAAC;EACrB,IAAA,8BAAoB,EAAC,EAAE,CAAC;EACxB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,kBAAkB,IAAA,WAAK,EAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,4CAA4C,IAAA,cAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/H,EAAE,UAAU,CAAC,CAAC;IACnB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC;AACvF,CAAC","sourcesContent":["// Saving attachments off an email.\n//\n// Two runs: the first reads the email's identity and attachment names, the\n// matching and file naming happen in TypeScript against shared/attachmentMatch,\n// and the second run saves what matched. That keeps one definition of \"does this\n// name match\", one wording for the error, and one file-naming rule.\nimport fs from 'fs';\nimport { asInt, asRow, asString, field, runOsaScript, splitPositionalList, summaryFields } from './run';\nimport {\n macMessageId,\n MessageDetail,\n messageDetailFields,\n messageDetailSnippet,\n messageLookupSnippet,\n} from './scripts';\nimport {\n attachmentNotFoundMessage,\n findAttachmentIndex,\n safeFileName,\n uniqueSavePath,\n} from '../shared/attachmentMatch';\nimport { NotFoundError } from '../errors';\nimport type { SaveAttachmentsRequest } from '../backend';\nimport type { SavedAttachment } from '../types';\n\n/**\n * Save the named attachments of one email, in the order named. Every name is\n * matched before anything is written, so a batch with one bad name fails\n * without having saved half its files.\n */\nexport async function saveEmailAttachments(request: SaveAttachmentsRequest): Promise<SavedAttachment[]> {\n const id = macMessageId(request.email.entryId);\n const parts = summaryFields(await runOsaScript(`tell application \"Microsoft Outlook\"\n${messageLookupSnippet(id)}\n${messageDetailSnippet()}\n return ${asRow(messageDetailFields())}\nend tell`, 'quick'));\n const email = {\n subject: field(parts, MessageDetail.subject).trim(),\n senderName: field(parts, MessageDetail.senderName),\n senderEmail: field(parts, MessageDetail.senderEmail),\n receivedTime: field(parts, MessageDetail.receivedTime),\n };\n const attachmentNames = splitPositionalList(field(parts, MessageDetail.attachmentNames));\n\n const picks = request.fileNames.map(fileName => {\n const index = findAttachmentIndex(attachmentNames, fileName);\n if (index === -1) {\n throw new NotFoundError('attachment', attachmentNotFoundMessage({\n fileName,\n ...email,\n present: attachmentNames.join(', ') || '(none)',\n }));\n }\n return { index, fileName: attachmentNames[index] };\n });\n\n // Paths are claimed as they are chosen, so two picks with one name don't collide.\n const claimed = new Set<string>();\n const saves = picks.map(pick => {\n const file = uniqueSavePath(request.destDir, safeFileName(pick.fileName), path => claimed.has(path) || fs.existsSync(path));\n claimed.add(file);\n return { ...pick, path: file };\n });\n await runOsaScript(`tell application \"Microsoft Outlook\"\n${messageLookupSnippet(id)}\n${saves.map(save => ` save (item ${asInt(save.index + 1)} of attachments of theMsg) in POSIX file ${asString(save.path)}`).join('\\n')}\nend tell`, 'standard');\n return saves.map(save => ({ path: save.path, fileName: save.fileName, ...email }));\n}\n"]}
|
package/dist/mac/bounces.d.ts
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
|
+
import type { CleanUndeliverableRequest, CollectBouncesRequest, SentGroupsRequest } from '../backend';
|
|
1
2
|
import type { CleanUndeliverableResult, SentRecipientGroup } from '../types';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Classification is deliberately conservative so ordinary mail that merely
|
|
8
|
-
* mentions "delivery" is never caught: an item matches only when its sender
|
|
9
|
-
* fingerprints as a mail-delivery daemon/postmaster or its subject contains a
|
|
10
|
-
* specific bounce phrase. macOS has no MessageClass, so the NDR-report signal
|
|
11
|
-
* Windows can also use is unavailable here — an Exchange NDR still matches on
|
|
12
|
-
* its "Undeliverable:" subject, which is what it carries.
|
|
4
|
+
* Find bounce-backs in the Inbox and, unless dry-running, move each to Deleted
|
|
5
|
+
* Items. The same three signals Windows uses apply, in the same order: a report
|
|
6
|
+
* that declares itself one in its headers, then the sender fingerprint, then the
|
|
7
|
+
* subject phrases.
|
|
13
8
|
*/
|
|
14
|
-
export declare function cleanUndeliverableEmails(
|
|
9
|
+
export declare function cleanUndeliverableEmails(request: CleanUndeliverableRequest): Promise<CleanUndeliverableResult>;
|
|
10
|
+
/** The deduplicated addresses bounce-backs report as failed. Never deletes anything. */
|
|
11
|
+
export declare function collectBouncedRecipients(request: CollectBouncesRequest): Promise<string[]>;
|
|
15
12
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* Deleted Items is included so this still works after cleanUndeliverableEmails has
|
|
21
|
-
* already filed the bounces there — the blacklist step doesn't depend on running
|
|
22
|
-
* before the cleanup. This never deletes anything.
|
|
13
|
+
* Sent Items within the window, each message with every address it went to,
|
|
14
|
+
* newest first. Indexed on `time sent` — outgoing mail's own stamp; indexing on
|
|
15
|
+
* `time received` yields an empty set that looks exactly like an empty folder.
|
|
23
16
|
*/
|
|
24
|
-
export declare function
|
|
25
|
-
/**
|
|
26
|
-
* Read the account's Sent Items within the window, returning each mail with the
|
|
27
|
-
* full SMTP address set it was sent to (To + CC + BCC), newest first. This is how
|
|
28
|
-
* the "was every address for this contact tried?" question gets answered: where a
|
|
29
|
-
* blast sends one email per organization addressed to all of its addresses, a sent
|
|
30
|
-
* message's recipient set IS that organization's full address set.
|
|
31
|
-
*/
|
|
32
|
-
export declare function readSentRecipientGroups(emailAccount: string, daysBack?: number, limit?: number): Promise<SentRecipientGroup[]>;
|
|
17
|
+
export declare function readSentRecipientGroups(request: SentGroupsRequest): Promise<SentRecipientGroup[]>;
|