@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.
- package/LICENSE +190 -0
- package/README.md +253 -0
- package/dist/OutlookService.d.ts +43 -0
- package/dist/OutlookService.js +137 -0
- package/dist/OutlookService.js.map +1 -0
- package/dist/errors.d.ts +112 -0
- package/dist/errors.js +140 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/mac/accounts.d.ts +5 -0
- package/dist/mac/accounts.js +17 -0
- package/dist/mac/accounts.js.map +1 -0
- package/dist/mac/attachments.d.ts +28 -0
- package/dist/mac/attachments.js +120 -0
- package/dist/mac/attachments.js.map +1 -0
- package/dist/mac/bounces.d.ts +32 -0
- package/dist/mac/bounces.js +285 -0
- package/dist/mac/bounces.js.map +1 -0
- package/dist/mac/cleanup.d.ts +29 -0
- package/dist/mac/cleanup.js +219 -0
- package/dist/mac/cleanup.js.map +1 -0
- package/dist/mac/drafts.d.ts +27 -0
- package/dist/mac/drafts.js +214 -0
- package/dist/mac/drafts.js.map +1 -0
- package/dist/mac/folders.d.ts +28 -0
- package/dist/mac/folders.js +127 -0
- package/dist/mac/folders.js.map +1 -0
- package/dist/mac/index.d.ts +22 -0
- package/dist/mac/index.js +119 -0
- package/dist/mac/index.js.map +1 -0
- package/dist/mac/read.d.ts +46 -0
- package/dist/mac/read.js +406 -0
- package/dist/mac/read.js.map +1 -0
- package/dist/mac/run.d.ts +64 -0
- package/dist/mac/run.js +250 -0
- package/dist/mac/run.js.map +1 -0
- package/dist/mac/scripts.d.ts +137 -0
- package/dist/mac/scripts.js +337 -0
- package/dist/mac/scripts.js.map +1 -0
- package/dist/mac/send.d.ts +23 -0
- package/dist/mac/send.js +135 -0
- package/dist/mac/send.js.map +1 -0
- package/dist/mac/signatures.d.ts +4 -0
- package/dist/mac/signatures.js +36 -0
- package/dist/mac/signatures.js.map +1 -0
- package/dist/mac/templates.d.ts +34 -0
- package/dist/mac/templates.js +266 -0
- package/dist/mac/templates.js.map +1 -0
- package/dist/mail.d.ts +72 -0
- package/dist/mail.js +131 -0
- package/dist/mail.js.map +1 -0
- package/dist/outlookTemplateSections.d.ts +62 -0
- package/dist/outlookTemplateSections.js +313 -0
- package/dist/outlookTemplateSections.js.map +1 -0
- package/dist/runtime.d.ts +76 -0
- package/dist/runtime.js +123 -0
- package/dist/runtime.js.map +1 -0
- package/dist/shared/attachmentMatch.d.ts +32 -0
- package/dist/shared/attachmentMatch.js +50 -0
- package/dist/shared/attachmentMatch.js.map +1 -0
- package/dist/shared/bounceRules.d.ts +33 -0
- package/dist/shared/bounceRules.js +104 -0
- package/dist/shared/bounceRules.js.map +1 -0
- package/dist/shared/capabilities.d.ts +3 -0
- package/dist/shared/capabilities.js +9 -0
- package/dist/shared/capabilities.js.map +1 -0
- package/dist/shared/json.d.ts +11 -0
- package/dist/shared/json.js +45 -0
- package/dist/shared/json.js.map +1 -0
- package/dist/shared/replyBody.d.ts +49 -0
- package/dist/shared/replyBody.js +113 -0
- package/dist/shared/replyBody.js.map +1 -0
- package/dist/types.d.ts +365 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/windows/accounts.d.ts +2 -0
- package/dist/windows/accounts.js +22 -0
- package/dist/windows/accounts.js.map +1 -0
- package/dist/windows/attachments.d.ts +28 -0
- package/dist/windows/attachments.js +141 -0
- package/dist/windows/attachments.js.map +1 -0
- package/dist/windows/bounces.d.ts +34 -0
- package/dist/windows/bounces.js +267 -0
- package/dist/windows/bounces.js.map +1 -0
- package/dist/windows/cleanup.d.ts +29 -0
- package/dist/windows/cleanup.js +165 -0
- package/dist/windows/cleanup.js.map +1 -0
- package/dist/windows/drafts.d.ts +29 -0
- package/dist/windows/drafts.js +253 -0
- package/dist/windows/drafts.js.map +1 -0
- package/dist/windows/folders.d.ts +16 -0
- package/dist/windows/folders.js +88 -0
- package/dist/windows/folders.js.map +1 -0
- package/dist/windows/index.d.ts +27 -0
- package/dist/windows/index.js +100 -0
- package/dist/windows/index.js.map +1 -0
- package/dist/windows/read.d.ts +54 -0
- package/dist/windows/read.js +372 -0
- package/dist/windows/read.js.map +1 -0
- package/dist/windows/run.d.ts +54 -0
- package/dist/windows/run.js +161 -0
- package/dist/windows/run.js.map +1 -0
- package/dist/windows/scripts.d.ts +56 -0
- package/dist/windows/scripts.js +163 -0
- package/dist/windows/scripts.js.map +1 -0
- package/dist/windows/send.d.ts +11 -0
- package/dist/windows/send.js +114 -0
- package/dist/windows/send.js.map +1 -0
- package/dist/windows/signatures.d.ts +14 -0
- package/dist/windows/signatures.js +69 -0
- package/dist/windows/signatures.js.map +1 -0
- package/dist/windows/templates.d.ts +25 -0
- package/dist/windows/templates.js +246 -0
- package/dist/windows/templates.js.map +1 -0
- package/package.json +50 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable discriminants. These are the API; the messages beside them are not.
|
|
3
|
+
*
|
|
4
|
+
* - `UNSUPPORTED_PLATFORM` — no Outlook automation exists on this OS at all.
|
|
5
|
+
* - `NOT_IMPLEMENTED` — the platform could do this, but the port isn't written.
|
|
6
|
+
* Distinct from UNSUPPORTED_PLATFORM on purpose: this one is a gap that may
|
|
7
|
+
* close in a later release, so a caller may reasonably feature-detect and
|
|
8
|
+
* degrade rather than refuse outright.
|
|
9
|
+
* - `ACCOUNT_NOT_FOUND` — no configured account matches that SMTP address.
|
|
10
|
+
* - `NOT_FOUND` — a named folder, template, signature or item didn't resolve.
|
|
11
|
+
* - `INVALID_REQUEST` — the arguments can't produce a call; nothing was attempted.
|
|
12
|
+
* - `SCRIPT_FAILED` — the interpreter ran and reported failure.
|
|
13
|
+
* - `TIMEOUT` — the run exceeded its budget and was killed.
|
|
14
|
+
* - `ABORTED` — the caller's AbortSignal fired.
|
|
15
|
+
*/
|
|
16
|
+
export type OutlookErrorCode = 'UNSUPPORTED_PLATFORM' | 'NOT_IMPLEMENTED' | 'ACCOUNT_NOT_FOUND' | 'NOT_FOUND' | 'INVALID_REQUEST' | 'SCRIPT_FAILED' | 'TIMEOUT' | 'ABORTED';
|
|
17
|
+
/** Base class for every error this package raises deliberately. */
|
|
18
|
+
export declare class OutlookError extends Error {
|
|
19
|
+
readonly code: OutlookErrorCode;
|
|
20
|
+
/** The underlying failure, when there was one. */
|
|
21
|
+
readonly cause?: unknown;
|
|
22
|
+
constructor(code: OutlookErrorCode, message: string, options?: {
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** This OS has no Outlook automation backend. */
|
|
27
|
+
export declare class UnsupportedPlatformError extends OutlookError {
|
|
28
|
+
/** The platform that was asked, i.e. `process.platform` at the time. */
|
|
29
|
+
readonly platform: string;
|
|
30
|
+
constructor(platform: string, detail?: string);
|
|
31
|
+
}
|
|
32
|
+
/** The platform supports this, but the port isn't written yet. */
|
|
33
|
+
export declare class NotImplementedError extends OutlookError {
|
|
34
|
+
/** The bridge function that isn't ported. */
|
|
35
|
+
readonly operation: string;
|
|
36
|
+
readonly platform: string;
|
|
37
|
+
constructor(operation: string, platform: string);
|
|
38
|
+
}
|
|
39
|
+
/** No configured Outlook account matches the requested address. */
|
|
40
|
+
export declare class AccountNotFoundError extends OutlookError {
|
|
41
|
+
readonly account: string;
|
|
42
|
+
constructor(account: string);
|
|
43
|
+
}
|
|
44
|
+
/** A named folder, template, signature or item didn't resolve. */
|
|
45
|
+
export declare class NotFoundError extends OutlookError {
|
|
46
|
+
/** What kind of thing was looked up — 'folder', 'template', 'signature', 'email'. */
|
|
47
|
+
readonly kind: string;
|
|
48
|
+
constructor(kind: string, message: string);
|
|
49
|
+
}
|
|
50
|
+
/** The arguments can't produce a call; nothing was attempted. */
|
|
51
|
+
export declare class InvalidRequestError extends OutlookError {
|
|
52
|
+
constructor(message: string);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The interpreter ran and failed.
|
|
56
|
+
*
|
|
57
|
+
* Carries the generated script verbatim. That is the single most useful thing
|
|
58
|
+
* when one of these fires and it is otherwise unreachable — the `debug` hook
|
|
59
|
+
* only fires if the consumer wired one up ahead of time, whereas this arrives
|
|
60
|
+
* attached to the failure itself.
|
|
61
|
+
*/
|
|
62
|
+
export declare class ScriptError extends OutlookError {
|
|
63
|
+
readonly runner: 'powershell' | 'osascript';
|
|
64
|
+
readonly script: string;
|
|
65
|
+
readonly stderr: string;
|
|
66
|
+
readonly durationMs: number;
|
|
67
|
+
constructor(init: {
|
|
68
|
+
runner: 'powershell' | 'osascript';
|
|
69
|
+
script: string;
|
|
70
|
+
stderr: string;
|
|
71
|
+
durationMs: number;
|
|
72
|
+
cause?: unknown;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** The run exceeded its budget and was killed. */
|
|
76
|
+
export declare class TimeoutError extends OutlookError {
|
|
77
|
+
readonly runner: 'powershell' | 'osascript';
|
|
78
|
+
readonly timeoutMs: number;
|
|
79
|
+
readonly script: string;
|
|
80
|
+
constructor(init: {
|
|
81
|
+
runner: 'powershell' | 'osascript';
|
|
82
|
+
timeoutMs: number;
|
|
83
|
+
script: string;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** The caller's AbortSignal fired. */
|
|
87
|
+
export declare class AbortedError extends OutlookError {
|
|
88
|
+
readonly runner: 'powershell' | 'osascript';
|
|
89
|
+
constructor(runner: 'powershell' | 'osascript', reason?: unknown);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Upgrade a raw interpreter failure to the most specific error we can prove.
|
|
93
|
+
*
|
|
94
|
+
* Order matters. Abort and timeout both kill the child with SIGTERM, so they are
|
|
95
|
+
* indistinguishable from the exit status alone — the signal's own state is what
|
|
96
|
+
* separates them, and it is checked first. Only then is stderr worth reading:
|
|
97
|
+
* a killed process may have printed a partial, misleading message before dying.
|
|
98
|
+
*/
|
|
99
|
+
export declare function classifyRunFailure(init: {
|
|
100
|
+
runner: 'powershell' | 'osascript';
|
|
101
|
+
script: string;
|
|
102
|
+
stderr: string;
|
|
103
|
+
durationMs: number;
|
|
104
|
+
/** The error `execFile` handed back, when the failure came from the child. */
|
|
105
|
+
nodeError?: (Error & {
|
|
106
|
+
killed?: boolean;
|
|
107
|
+
code?: string | number | null;
|
|
108
|
+
}) | null;
|
|
109
|
+
/** The budget in force, for the TIMEOUT message. */
|
|
110
|
+
timeoutMs?: number;
|
|
111
|
+
signal?: AbortSignal;
|
|
112
|
+
}): OutlookError;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The package's error taxonomy.
|
|
3
|
+
//
|
|
4
|
+
// Every failure used to be a bare `new Error(string)`, which left a consumer
|
|
5
|
+
// only one way to tell "this machine can't do that" from "that account doesn't
|
|
6
|
+
// exist" from "the script blew up": matching on the message text. Message text
|
|
7
|
+
// is not an API — rewording one sentence here would silently break a caller's
|
|
8
|
+
// branch — so the distinctions a caller actually acts on carry a stable `code`.
|
|
9
|
+
//
|
|
10
|
+
// Every error this package throws on purpose is an `OutlookError`. A caller that
|
|
11
|
+
// wants one branch for "expected failure" and another for "bug" can switch on
|
|
12
|
+
// `err instanceof OutlookError` alone.
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.AbortedError = exports.TimeoutError = exports.ScriptError = exports.InvalidRequestError = exports.NotFoundError = exports.AccountNotFoundError = exports.NotImplementedError = exports.UnsupportedPlatformError = exports.OutlookError = void 0;
|
|
15
|
+
exports.classifyRunFailure = classifyRunFailure;
|
|
16
|
+
/** Base class for every error this package raises deliberately. */
|
|
17
|
+
class OutlookError extends Error {
|
|
18
|
+
constructor(code, message, options) {
|
|
19
|
+
// Declared as a field rather than passed to `super`: the ES2022 `cause`
|
|
20
|
+
// constructor option isn't in this package's ES2020 target.
|
|
21
|
+
super(message);
|
|
22
|
+
if (options && 'cause' in options)
|
|
23
|
+
this.cause = options.cause;
|
|
24
|
+
this.code = code;
|
|
25
|
+
// `name` is what shows up in an unhandled-rejection dump, so make it the
|
|
26
|
+
// subclass rather than a uniform "Error".
|
|
27
|
+
this.name = new.target.name;
|
|
28
|
+
// Restores the prototype chain when the package is consumed as compiled
|
|
29
|
+
// ES2020 output — without it `instanceof` fails for a subclass.
|
|
30
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.OutlookError = OutlookError;
|
|
34
|
+
/** This OS has no Outlook automation backend. */
|
|
35
|
+
class UnsupportedPlatformError extends OutlookError {
|
|
36
|
+
constructor(platform, detail = 'Outlook automation is only supported on Windows and macOS.') {
|
|
37
|
+
super('UNSUPPORTED_PLATFORM', `${detail} (running on '${platform}')`);
|
|
38
|
+
this.platform = platform;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.UnsupportedPlatformError = UnsupportedPlatformError;
|
|
42
|
+
/** The platform supports this, but the port isn't written yet. */
|
|
43
|
+
class NotImplementedError extends OutlookError {
|
|
44
|
+
constructor(operation, platform) {
|
|
45
|
+
super('NOT_IMPLEMENTED', `'${operation}' is not implemented for Outlook on ${platform} yet.`);
|
|
46
|
+
this.operation = operation;
|
|
47
|
+
this.platform = platform;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.NotImplementedError = NotImplementedError;
|
|
51
|
+
/** No configured Outlook account matches the requested address. */
|
|
52
|
+
class AccountNotFoundError extends OutlookError {
|
|
53
|
+
constructor(account) {
|
|
54
|
+
super('ACCOUNT_NOT_FOUND', `Outlook account '${account}' not found.`);
|
|
55
|
+
this.account = account;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.AccountNotFoundError = AccountNotFoundError;
|
|
59
|
+
/** A named folder, template, signature or item didn't resolve. */
|
|
60
|
+
class NotFoundError extends OutlookError {
|
|
61
|
+
constructor(kind, message) {
|
|
62
|
+
super('NOT_FOUND', message);
|
|
63
|
+
this.kind = kind;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.NotFoundError = NotFoundError;
|
|
67
|
+
/** The arguments can't produce a call; nothing was attempted. */
|
|
68
|
+
class InvalidRequestError extends OutlookError {
|
|
69
|
+
constructor(message) {
|
|
70
|
+
super('INVALID_REQUEST', message);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.InvalidRequestError = InvalidRequestError;
|
|
74
|
+
/**
|
|
75
|
+
* The interpreter ran and failed.
|
|
76
|
+
*
|
|
77
|
+
* Carries the generated script verbatim. That is the single most useful thing
|
|
78
|
+
* when one of these fires and it is otherwise unreachable — the `debug` hook
|
|
79
|
+
* only fires if the consumer wired one up ahead of time, whereas this arrives
|
|
80
|
+
* attached to the failure itself.
|
|
81
|
+
*/
|
|
82
|
+
class ScriptError extends OutlookError {
|
|
83
|
+
constructor(init) {
|
|
84
|
+
super('SCRIPT_FAILED', init.stderr || `${init.runner} failed with no output.`, { cause: init.cause });
|
|
85
|
+
this.runner = init.runner;
|
|
86
|
+
this.script = init.script;
|
|
87
|
+
this.stderr = init.stderr;
|
|
88
|
+
this.durationMs = init.durationMs;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.ScriptError = ScriptError;
|
|
92
|
+
/** The run exceeded its budget and was killed. */
|
|
93
|
+
class TimeoutError extends OutlookError {
|
|
94
|
+
constructor(init) {
|
|
95
|
+
super('TIMEOUT', `${init.runner} run exceeded its ${init.timeoutMs}ms budget and was killed.`);
|
|
96
|
+
this.runner = init.runner;
|
|
97
|
+
this.timeoutMs = init.timeoutMs;
|
|
98
|
+
this.script = init.script;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.TimeoutError = TimeoutError;
|
|
102
|
+
/** The caller's AbortSignal fired. */
|
|
103
|
+
class AbortedError extends OutlookError {
|
|
104
|
+
constructor(runner, reason) {
|
|
105
|
+
super('ABORTED', `${runner} run was aborted by the caller.`, { cause: reason });
|
|
106
|
+
this.runner = runner;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.AbortedError = AbortedError;
|
|
110
|
+
/**
|
|
111
|
+
* Both platform scripts signal a bad sending account by `throw`ing a string the
|
|
112
|
+
* interpreter then prints. Recognising it here is what turns the most common
|
|
113
|
+
* operational mistake — a typo'd or freshly-removed account — into a code a
|
|
114
|
+
* caller can branch on, instead of a SCRIPT_FAILED they'd have to grep.
|
|
115
|
+
*
|
|
116
|
+
* Deliberately narrow: it only matches the sentence our own scripts emit.
|
|
117
|
+
*/
|
|
118
|
+
const ACCOUNT_NOT_FOUND_RE = /Account '([^']*)' not found/i;
|
|
119
|
+
/**
|
|
120
|
+
* Upgrade a raw interpreter failure to the most specific error we can prove.
|
|
121
|
+
*
|
|
122
|
+
* Order matters. Abort and timeout both kill the child with SIGTERM, so they are
|
|
123
|
+
* indistinguishable from the exit status alone — the signal's own state is what
|
|
124
|
+
* separates them, and it is checked first. Only then is stderr worth reading:
|
|
125
|
+
* a killed process may have printed a partial, misleading message before dying.
|
|
126
|
+
*/
|
|
127
|
+
function classifyRunFailure(init) {
|
|
128
|
+
const { runner, script, stderr, durationMs, nodeError, timeoutMs, signal } = init;
|
|
129
|
+
if (signal?.aborted || nodeError?.name === 'AbortError' || nodeError?.code === 'ABORT_ERR') {
|
|
130
|
+
return new AbortedError(runner, signal?.reason);
|
|
131
|
+
}
|
|
132
|
+
if (nodeError?.killed && timeoutMs) {
|
|
133
|
+
return new TimeoutError({ runner, timeoutMs, script });
|
|
134
|
+
}
|
|
135
|
+
const match = ACCOUNT_NOT_FOUND_RE.exec(stderr);
|
|
136
|
+
if (match)
|
|
137
|
+
return new AccountNotFoundError(match[1]);
|
|
138
|
+
return new ScriptError({ runner, script, stderr, durationMs, cause: nodeError ?? undefined });
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","s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EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;AAClG,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { getOutlookAccounts, sendOutlookEmail, replyOutlookEmail, sendAllDrafts, readInboxEmails, searchInboxByFilter, readSelectedEmail, readEmailBody, openOutlookEmail, listInboxFolders, moveOutlookEmails, listOutlookDrafts, deleteOutlookDrafts, deleteOutlookEmails, purgeDeletedItems, saveEmailAttachment, saveEmailAttachmentDetailed, saveEmailAttachments, cleanUndeliverableEmails, collectBouncedRecipients, readSentRecipientGroups, listOutlookSignatures, readOutlookSignatureHtml, readTemplateEmails, saveTemplateEmail, editEmailTemplate, } from './OutlookService';
|
|
2
|
+
export { createOutlookBridge, capabilities, supports } from './OutlookService';
|
|
3
|
+
export type { OutlookBridgeInstance } from './OutlookService';
|
|
4
|
+
export { configure, getConfig } from './runtime';
|
|
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 type { OutlookBridge, BridgeCapability, CapabilityMap, SendEmailParams, ReplyEmailParams, ReplyEmailResult, DraftSendFailure, SendAllDraftsResult, OutlookDraft, ListDraftsResult, DeleteDraftsResult, DeleteMailOptions, DeleteMailOutcome, DeleteMailResult, PurgeDeletedItemsResult, UndeliverableEmail, CleanUndeliverableResult, SentRecipientGroup, InboxEmail, InboxSearchFilter, InboxSearchMatch, SelectedEmail, EmailBodyResult, MailFolderRef, InboxFolderInfo, MoveEmailsResult, SavedAttachment, TemplateEmail, TemplateFolderResult, SaveTemplateResult, } from './types';
|
|
10
|
+
export { findTemplateMarkers, replaceToken, removeTokenLine, findTokens, findUnfilledTokens, composeTemplateBody, } from './outlookTemplateSections';
|
|
11
|
+
export type { TemplateMarkers, ComposeOptions } from './outlookTemplateSections';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.composeTemplateBody = exports.findUnfilledTokens = exports.findTokens = exports.removeTokenLine = exports.replaceToken = exports.findTemplateMarkers = exports.WELL_KNOWN_FOLDERS = exports.splitQuotedOriginal = exports.mailFolderRef = exports.AbortedError = exports.TimeoutError = exports.ScriptError = exports.InvalidRequestError = exports.NotFoundError = exports.AccountNotFoundError = exports.NotImplementedError = exports.UnsupportedPlatformError = exports.OutlookError = exports.getConfig = exports.configure = exports.supports = exports.capabilities = exports.createOutlookBridge = exports.editEmailTemplate = exports.saveTemplateEmail = exports.readTemplateEmails = exports.readOutlookSignatureHtml = exports.listOutlookSignatures = exports.readSentRecipientGroups = exports.collectBouncedRecipients = exports.cleanUndeliverableEmails = exports.saveEmailAttachments = exports.saveEmailAttachmentDetailed = exports.saveEmailAttachment = exports.purgeDeletedItems = exports.deleteOutlookEmails = exports.deleteOutlookDrafts = exports.listOutlookDrafts = exports.moveOutlookEmails = exports.listInboxFolders = exports.openOutlookEmail = exports.readEmailBody = exports.readSelectedEmail = exports.searchInboxByFilter = exports.readInboxEmails = exports.sendAllDrafts = exports.replyOutlookEmail = exports.sendOutlookEmail = exports.getOutlookAccounts = void 0;
|
|
4
|
+
// Public API surface. Deliberately explicit (rather than `export *`) so the
|
|
5
|
+
// package only ever exposes what it means to support; `package.json`'s `exports`
|
|
6
|
+
// map closes the deep-import path that would otherwise reach around this.
|
|
7
|
+
var OutlookService_1 = require("./OutlookService");
|
|
8
|
+
Object.defineProperty(exports, "getOutlookAccounts", { enumerable: true, get: function () { return OutlookService_1.getOutlookAccounts; } });
|
|
9
|
+
Object.defineProperty(exports, "sendOutlookEmail", { enumerable: true, get: function () { return OutlookService_1.sendOutlookEmail; } });
|
|
10
|
+
Object.defineProperty(exports, "replyOutlookEmail", { enumerable: true, get: function () { return OutlookService_1.replyOutlookEmail; } });
|
|
11
|
+
Object.defineProperty(exports, "sendAllDrafts", { enumerable: true, get: function () { return OutlookService_1.sendAllDrafts; } });
|
|
12
|
+
Object.defineProperty(exports, "readInboxEmails", { enumerable: true, get: function () { return OutlookService_1.readInboxEmails; } });
|
|
13
|
+
Object.defineProperty(exports, "searchInboxByFilter", { enumerable: true, get: function () { return OutlookService_1.searchInboxByFilter; } });
|
|
14
|
+
Object.defineProperty(exports, "readSelectedEmail", { enumerable: true, get: function () { return OutlookService_1.readSelectedEmail; } });
|
|
15
|
+
Object.defineProperty(exports, "readEmailBody", { enumerable: true, get: function () { return OutlookService_1.readEmailBody; } });
|
|
16
|
+
Object.defineProperty(exports, "openOutlookEmail", { enumerable: true, get: function () { return OutlookService_1.openOutlookEmail; } });
|
|
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, "deleteOutlookEmails", { enumerable: true, get: function () { return OutlookService_1.deleteOutlookEmails; } });
|
|
22
|
+
Object.defineProperty(exports, "purgeDeletedItems", { enumerable: true, get: function () { return OutlookService_1.purgeDeletedItems; } });
|
|
23
|
+
Object.defineProperty(exports, "saveEmailAttachment", { enumerable: true, get: function () { return OutlookService_1.saveEmailAttachment; } });
|
|
24
|
+
Object.defineProperty(exports, "saveEmailAttachmentDetailed", { enumerable: true, get: function () { return OutlookService_1.saveEmailAttachmentDetailed; } });
|
|
25
|
+
Object.defineProperty(exports, "saveEmailAttachments", { enumerable: true, get: function () { return OutlookService_1.saveEmailAttachments; } });
|
|
26
|
+
Object.defineProperty(exports, "cleanUndeliverableEmails", { enumerable: true, get: function () { return OutlookService_1.cleanUndeliverableEmails; } });
|
|
27
|
+
Object.defineProperty(exports, "collectBouncedRecipients", { enumerable: true, get: function () { return OutlookService_1.collectBouncedRecipients; } });
|
|
28
|
+
Object.defineProperty(exports, "readSentRecipientGroups", { enumerable: true, get: function () { return OutlookService_1.readSentRecipientGroups; } });
|
|
29
|
+
Object.defineProperty(exports, "listOutlookSignatures", { enumerable: true, get: function () { return OutlookService_1.listOutlookSignatures; } });
|
|
30
|
+
Object.defineProperty(exports, "readOutlookSignatureHtml", { enumerable: true, get: function () { return OutlookService_1.readOutlookSignatureHtml; } });
|
|
31
|
+
Object.defineProperty(exports, "readTemplateEmails", { enumerable: true, get: function () { return OutlookService_1.readTemplateEmails; } });
|
|
32
|
+
Object.defineProperty(exports, "saveTemplateEmail", { enumerable: true, get: function () { return OutlookService_1.saveTemplateEmail; } });
|
|
33
|
+
Object.defineProperty(exports, "editEmailTemplate", { enumerable: true, get: function () { return OutlookService_1.editEmailTemplate; } });
|
|
34
|
+
// A bridge with its own settings, isolated from every other caller in the
|
|
35
|
+
// process — and capability discovery, so a consumer can ask what works here
|
|
36
|
+
// instead of finding out by calling.
|
|
37
|
+
var OutlookService_2 = require("./OutlookService");
|
|
38
|
+
Object.defineProperty(exports, "createOutlookBridge", { enumerable: true, get: function () { return OutlookService_2.createOutlookBridge; } });
|
|
39
|
+
Object.defineProperty(exports, "capabilities", { enumerable: true, get: function () { return OutlookService_2.capabilities; } });
|
|
40
|
+
Object.defineProperty(exports, "supports", { enumerable: true, get: function () { return OutlookService_2.supports; } });
|
|
41
|
+
// Process-wide settings: run timeouts, the stdout cap, cancellation, where
|
|
42
|
+
// scratch files and saved attachments go, and a hook that hands you every
|
|
43
|
+
// generated script. Prefer createOutlookBridge in shared processes.
|
|
44
|
+
var runtime_1 = require("./runtime");
|
|
45
|
+
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return runtime_1.configure; } });
|
|
46
|
+
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return runtime_1.getConfig; } });
|
|
47
|
+
// Failures carry a stable `code`; the messages beside them are not an API.
|
|
48
|
+
var errors_1 = require("./errors");
|
|
49
|
+
Object.defineProperty(exports, "OutlookError", { enumerable: true, get: function () { return errors_1.OutlookError; } });
|
|
50
|
+
Object.defineProperty(exports, "UnsupportedPlatformError", { enumerable: true, get: function () { return errors_1.UnsupportedPlatformError; } });
|
|
51
|
+
Object.defineProperty(exports, "NotImplementedError", { enumerable: true, get: function () { return errors_1.NotImplementedError; } });
|
|
52
|
+
Object.defineProperty(exports, "AccountNotFoundError", { enumerable: true, get: function () { return errors_1.AccountNotFoundError; } });
|
|
53
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_1.NotFoundError; } });
|
|
54
|
+
Object.defineProperty(exports, "InvalidRequestError", { enumerable: true, get: function () { return errors_1.InvalidRequestError; } });
|
|
55
|
+
Object.defineProperty(exports, "ScriptError", { enumerable: true, get: function () { return errors_1.ScriptError; } });
|
|
56
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
|
|
57
|
+
Object.defineProperty(exports, "AbortedError", { enumerable: true, get: function () { return errors_1.AbortedError; } });
|
|
58
|
+
// Platform-neutral helpers, usable without an Outlook session — and the two
|
|
59
|
+
// pieces of parsing a caller most often needs to reproduce.
|
|
60
|
+
var mail_1 = require("./mail");
|
|
61
|
+
Object.defineProperty(exports, "mailFolderRef", { enumerable: true, get: function () { return mail_1.mailFolderRef; } });
|
|
62
|
+
Object.defineProperty(exports, "splitQuotedOriginal", { enumerable: true, get: function () { return mail_1.splitQuotedOriginal; } });
|
|
63
|
+
Object.defineProperty(exports, "WELL_KNOWN_FOLDERS", { enumerable: true, get: function () { return mail_1.WELL_KNOWN_FOLDERS; } });
|
|
64
|
+
var outlookTemplateSections_1 = require("./outlookTemplateSections");
|
|
65
|
+
Object.defineProperty(exports, "findTemplateMarkers", { enumerable: true, get: function () { return outlookTemplateSections_1.findTemplateMarkers; } });
|
|
66
|
+
Object.defineProperty(exports, "replaceToken", { enumerable: true, get: function () { return outlookTemplateSections_1.replaceToken; } });
|
|
67
|
+
Object.defineProperty(exports, "removeTokenLine", { enumerable: true, get: function () { return outlookTemplateSections_1.removeTokenLine; } });
|
|
68
|
+
Object.defineProperty(exports, "findTokens", { enumerable: true, get: function () { return outlookTemplateSections_1.findTokens; } });
|
|
69
|
+
Object.defineProperty(exports, "findUnfilledTokens", { enumerable: true, get: function () { return outlookTemplateSections_1.findUnfilledTokens; } });
|
|
70
|
+
Object.defineProperty(exports, "composeTemplateBody", { enumerable: true, get: function () { return outlookTemplateSections_1.composeTemplateBody; } });
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC5E,iFAAiF;AACjF,0EAA0E;AAC1E,mDA2B0B;AA1BtB,oHAAA,kBAAkB,OAAA;AAClB,kHAAA,gBAAgB,OAAA;AAChB,mHAAA,iBAAiB,OAAA;AACjB,+GAAA,aAAa,OAAA;AACb,iHAAA,eAAe,OAAA;AACf,qHAAA,mBAAmB,OAAA;AACnB,mHAAA,iBAAiB,OAAA;AACjB,+GAAA,aAAa,OAAA;AACb,kHAAA,gBAAgB,OAAA;AAChB,kHAAA,gBAAgB,OAAA;AAChB,mHAAA,iBAAiB,OAAA;AACjB,mHAAA,iBAAiB,OAAA;AACjB,qHAAA,mBAAmB,OAAA;AACnB,qHAAA,mBAAmB,OAAA;AACnB,mHAAA,iBAAiB,OAAA;AACjB,qHAA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ts = getOutlookAccounts;
|
|
4
|
+
const run_1 = require("./run");
|
|
5
|
+
const scripts_1 = require("./scripts");
|
|
6
|
+
/**
|
|
7
|
+
* SMTP addresses of Outlook accounts. Empty under New Outlook (not exposed).
|
|
8
|
+
* Used by the UI's account picker.
|
|
9
|
+
*/
|
|
10
|
+
async function getOutlookAccounts() {
|
|
11
|
+
const script = `${scripts_1.LIST_ACCOUNTS_SNIPPET}
|
|
12
|
+
set AppleScript's text item delimiters to linefeed
|
|
13
|
+
return acctList as string`;
|
|
14
|
+
const raw = await (0, run_1.runOsaScript)(script, 15000);
|
|
15
|
+
return raw.split('\n').map(s => s.trim()).filter(Boolean);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/mac/accounts.ts"],"names":[],"mappings":";;AAOA,gDAMC;AAbD,+BAAqC;AACrC,uCAAkD;AAElD;;;GAGG;AACI,KAAK,UAAU,kBAAkB;IACpC,MAAM,MAAM,GAAG,GAAG,+BAAqB;;0BAEjB,CAAC;IACvB,MAAM,GAAG,GAAG,MAAM,IAAA,kBAAY,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9C,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SavedAttachment } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Save an email attachment by message id and filename, returning the saved path
|
|
4
|
+
* together with the resolved email's subject/sender so the caller can confirm the
|
|
5
|
+
* file came from the email it intended.
|
|
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.
|
|
15
|
+
*/
|
|
16
|
+
export declare function saveEmailAttachmentDetailed(entryId: string, fileName: string, _storeId?: string, destDir?: string): Promise<SavedAttachment>;
|
|
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[]>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.saveEmailAttachmentDetailed = saveEmailAttachmentDetailed;
|
|
7
|
+
exports.saveEmailAttachment = saveEmailAttachment;
|
|
8
|
+
exports.saveEmailAttachments = saveEmailAttachments;
|
|
9
|
+
// Saving attachments off an email, one at a time or in a batch.
|
|
10
|
+
//
|
|
11
|
+
// Two runs rather than one: the first reads the email's identity and attachment
|
|
12
|
+
// names, the matching happens in TypeScript against shared/attachmentMatch, and
|
|
13
|
+
// only then does the second run save what matched. That keeps one definition of
|
|
14
|
+
// "does this filename match" and one wording for the error, shared with Windows.
|
|
15
|
+
const run_1 = require("./run");
|
|
16
|
+
const scripts_1 = require("./scripts");
|
|
17
|
+
const attachmentMatch_1 = require("../shared/attachmentMatch");
|
|
18
|
+
const runtime_1 = require("../runtime");
|
|
19
|
+
const errors_1 = require("../errors");
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
/** Read the email's identity and the names of the attachments it carries. */
|
|
22
|
+
async function resolveEmail(id) {
|
|
23
|
+
const script = `tell application "Microsoft Outlook"
|
|
24
|
+
${(0, scripts_1.messageLookupSnippet)(id)}
|
|
25
|
+
${(0, scripts_1.messageDetailSnippet)()}
|
|
26
|
+
return ${(0, run_1.asRow)((0, scripts_1.messageDetailFields)())}
|
|
27
|
+
end tell`;
|
|
28
|
+
const parts = (0, run_1.summaryFields)(await (0, run_1.runOsaScript)(script, 30000));
|
|
29
|
+
return {
|
|
30
|
+
subject: (0, run_1.field)(parts, scripts_1.MessageDetail.subject),
|
|
31
|
+
senderName: (0, run_1.field)(parts, scripts_1.MessageDetail.senderName),
|
|
32
|
+
senderEmail: (0, run_1.field)(parts, scripts_1.MessageDetail.senderEmail),
|
|
33
|
+
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
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Match one requested filename to an attachment index, or throw the shared
|
|
39
|
+
* "not found" error naming the email that actually resolved.
|
|
40
|
+
*/
|
|
41
|
+
function requireAttachmentIndex(email, fileName) {
|
|
42
|
+
const index = (0, attachmentMatch_1.findAttachmentIndex)(email.attachmentNames, fileName);
|
|
43
|
+
if (index === -1) {
|
|
44
|
+
throw new errors_1.NotFoundError('attachment', (0, attachmentMatch_1.attachmentNotFoundMessage)({
|
|
45
|
+
fileName,
|
|
46
|
+
senderEmail: email.senderEmail,
|
|
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] };
|
|
109
|
+
});
|
|
110
|
+
const outDir = (0, runtime_1.resolveDestDir)(destDir);
|
|
111
|
+
await saveByIndex(id, picks, outDir);
|
|
112
|
+
return picks.map(pick => ({
|
|
113
|
+
path: path_1.default.join(outDir, pick.name),
|
|
114
|
+
subject: email.subject,
|
|
115
|
+
senderName: email.senderName,
|
|
116
|
+
senderEmail: email.senderEmail,
|
|
117
|
+
receivedTime: email.receivedTime,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../src/mac/attachments.ts"],"names":[],"mappings":";;;;;AA6FA,kEAWC;AAGD,kDAOC;AAWD,oDAwBC;AArJD,gEAAgE;AAChE,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,+BAAuF;AACvF,uCAMmB;AACnB,+DAA2F;AAC3F,wCAA4C;AAC5C,sCAA0C;AAC1C,gDAAwB;AAWxB,6EAA6E;AAC7E,KAAK,UAAU,YAAY,CAAC,EAAU;IAClC,MAAM,MAAM,GAAG;EACjB,IAAA,8BAAoB,EAAC,EAAE,CAAC;EACxB,IAAA,8BAAoB,GAAE;aACX,IAAA,WAAK,EAAC,IAAA,6BAAmB,GAAE,CAAC;SAChC,CAAC;IACN,MAAM,KAAK,GAAG,IAAA,mBAAa,EAAC,MAAM,IAAA,kBAAY,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC/D,OAAO;QACH,OAAO,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,uBAAa,CAAC,OAAO,CAAC;QAC5C,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;QACtD,eAAe,EAAE,IAAA,eAAS,EAAC,IAAA,WAAK,EAAC,KAAK,EAAE,uBAAa,CAAC,eAAe,CAAC,CAAC;KAC1E,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,SAAS,sBAAsB,CAAC,KAAoB,EAAE,QAAgB;IAClE,MAAM,KAAK,GAAG,IAAA,qCAAmB,EAAC,KAAK,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IACnE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EAAE,KAAK,CAAC,YAAY;KACnC,CAAC,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CleanUndeliverableResult, SentRecipientGroup } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Scan an account's inbox for bounce-back / non-delivery messages — mail-daemon
|
|
4
|
+
* and postmaster rejections, and "Message blocked"-style failure notices — and,
|
|
5
|
+
* unless previewing, move each to Deleted Items (recoverable).
|
|
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.
|
|
13
|
+
*/
|
|
14
|
+
export declare function cleanUndeliverableEmails(emailAccount: string, daysBack?: number, dryRun?: boolean): Promise<CleanUndeliverableResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Read-only scan of an account's Inbox (and, when scanDeleted, its Deleted Items)
|
|
17
|
+
* for bounce messages, returning just the deduped set of failed recipient
|
|
18
|
+
* addresses. Uses the same conservative classifier as cleanUndeliverableEmails.
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
export declare function collectBouncedRecipients(emailAccount: string, daysBack?: number, scanDeleted?: boolean): Promise<string[]>;
|
|
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[]>;
|