@dawnlit/outlook-bridge 2.0.0 → 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.
Files changed (88) hide show
  1. package/README.md +6 -4
  2. package/dist/backend.d.ts +2 -2
  3. package/dist/backend.js.map +1 -1
  4. package/dist/bridge.js +3 -3
  5. package/dist/bridge.js.map +1 -1
  6. package/dist/errors.d.ts +0 -2
  7. package/dist/errors.js +1 -6
  8. package/dist/errors.js.map +1 -1
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/mac/accounts.js.map +1 -1
  12. package/dist/mac/attachments.js +1 -1
  13. package/dist/mac/attachments.js.map +1 -1
  14. package/dist/mac/bounces.js +8 -12
  15. package/dist/mac/bounces.js.map +1 -1
  16. package/dist/mac/cleanup.js +4 -41
  17. package/dist/mac/cleanup.js.map +1 -1
  18. package/dist/mac/drafts.d.ts +3 -1
  19. package/dist/mac/drafts.js +34 -33
  20. package/dist/mac/drafts.js.map +1 -1
  21. package/dist/mac/folders.d.ts +5 -3
  22. package/dist/mac/folders.js +18 -19
  23. package/dist/mac/folders.js.map +1 -1
  24. package/dist/mac/profile.js.map +1 -1
  25. package/dist/mac/read.d.ts +4 -0
  26. package/dist/mac/read.js +54 -16
  27. package/dist/mac/read.js.map +1 -1
  28. package/dist/mac/run.d.ts +19 -2
  29. package/dist/mac/run.js +42 -2
  30. package/dist/mac/run.js.map +1 -1
  31. package/dist/mac/scripts.d.ts +21 -14
  32. package/dist/mac/scripts.js +52 -21
  33. package/dist/mac/scripts.js.map +1 -1
  34. package/dist/mac/send.d.ts +3 -3
  35. package/dist/mac/send.js +44 -12
  36. package/dist/mac/send.js.map +1 -1
  37. package/dist/mac/templates.js +15 -18
  38. package/dist/mac/templates.js.map +1 -1
  39. package/dist/mail.d.ts +5 -3
  40. package/dist/mail.js +19 -6
  41. package/dist/mail.js.map +1 -1
  42. package/dist/runtime.js.map +1 -1
  43. package/dist/shared/args.js.map +1 -1
  44. package/dist/shared/attachmentMatch.d.ts +0 -6
  45. package/dist/shared/attachmentMatch.js +0 -1
  46. package/dist/shared/attachmentMatch.js.map +1 -1
  47. package/dist/shared/exec.js.map +1 -1
  48. package/dist/shared/json.d.ts +11 -6
  49. package/dist/shared/json.js +12 -7
  50. package/dist/shared/json.js.map +1 -1
  51. package/dist/shared/locate.d.ts +0 -8
  52. package/dist/shared/locate.js +0 -1
  53. package/dist/shared/locate.js.map +1 -1
  54. package/dist/shared/replyBody.d.ts +0 -15
  55. package/dist/shared/replyBody.js +0 -2
  56. package/dist/shared/replyBody.js.map +1 -1
  57. package/dist/shared/templateLimits.d.ts +14 -0
  58. package/dist/shared/templateLimits.js +21 -0
  59. package/dist/shared/templateLimits.js.map +1 -0
  60. package/dist/templateBody.d.ts +6 -0
  61. package/dist/templateBody.js +8 -1
  62. package/dist/templateBody.js.map +1 -1
  63. package/dist/types.d.ts +23 -3
  64. package/dist/types.js.map +1 -1
  65. package/dist/windows/bounces.js +4 -4
  66. package/dist/windows/bounces.js.map +1 -1
  67. package/dist/windows/cleanup.d.ts +5 -1
  68. package/dist/windows/cleanup.js +16 -11
  69. package/dist/windows/cleanup.js.map +1 -1
  70. package/dist/windows/drafts.d.ts +4 -4
  71. package/dist/windows/drafts.js +20 -31
  72. package/dist/windows/drafts.js.map +1 -1
  73. package/dist/windows/folders.js +1 -1
  74. package/dist/windows/folders.js.map +1 -1
  75. package/dist/windows/read.js +6 -2
  76. package/dist/windows/read.js.map +1 -1
  77. package/dist/windows/run.d.ts +0 -2
  78. package/dist/windows/run.js +1 -2
  79. package/dist/windows/run.js.map +1 -1
  80. package/dist/windows/scripts.d.ts +4 -4
  81. package/dist/windows/scripts.js +10 -10
  82. package/dist/windows/scripts.js.map +1 -1
  83. package/dist/windows/send.d.ts +8 -3
  84. package/dist/windows/send.js +10 -2
  85. package/dist/windows/send.js.map +1 -1
  86. package/dist/windows/templates.js +9 -15
  87. package/dist/windows/templates.js.map +1 -1
  88. package/package.json +2 -2
package/README.md CHANGED
@@ -50,7 +50,7 @@ same defaults and the same validation on both platforms.
50
50
  | Accounts | `getOutlookAccounts` |
51
51
  | Reading | `readInboxEmails` (the Inbox root, or any folder by name or path), `searchInboxByFilter` (walks the whole Inbox tree by subject glob or pattern, date window, attachments, folders), `readEmailBody` (the sender's own text, split from the quoted thread), `readSelectedEmail`, `openOutlookEmail`, `locateEmail` (finds an email again by subject, sender and time once its id has gone stale) |
52
52
  | Folders | `listInboxFolders`, `moveOutlookEmails` (creates a missing destination chain on request) |
53
- | Composing | `sendOutlookEmail` (to/cc/bcc, several attachments, a named signature, send or draft), `replyOutlookEmail` (reply or reply-all, from HTML or a saved template) |
53
+ | Composing | `sendOutlookEmail` (to/cc/bcc, several attachments, a named signature, send or draft; a draft filed without a window returns its id, so a caller can later send exactly the drafts it made), `replyOutlookEmail` (reply or reply-all, from HTML or a saved template) |
54
54
  | Drafts | `listOutlookDrafts`, `sendDrafts` (a chosen subset), `sendAllDrafts`, `deleteOutlookDrafts` |
55
55
  | Attachments | `saveEmailAttachment`, `saveEmailAttachments` |
56
56
  | Cleanup | `deleteOutlookEmails` (refuses received and sent mail unless allowed; dry-run first), `purgeDeletedItems` |
@@ -209,9 +209,11 @@ helpers, the error taxonomy, and the generated scripts themselves:
209
209
  - **On Windows**, every PowerShell script every operation generates is put through PowerShell's own parser, with
210
210
  arguments built to break out of a badly escaped literal. The test fails on a syntax error, and on any caller text
211
211
  inside a double-quoted string.
212
- - **On a Mac with Outlook installed**, every AppleScript is compiled with `osacompile`, which resolves dictionary terms
213
- without opening a session. Elsewhere, those tests skip; two guards that need no Outlook — no assignment to a reserved
214
- AppleScript word, no record field read through a nested accessor — run everywhere.
212
+ - **Everywhere**, the AppleScript counterpart: every macOS script is checked for caller text outside its string
213
+ literals and for the two mistakes compiling can't catch — an assignment to a reserved AppleScript word, a record
214
+ field read through a nested accessor — and canned script output is decoded into the result shapes Windows returns.
215
+ - **On a Mac**, the hostile argument is also round-tripped through `osascript`, and with Outlook installed every
216
+ AppleScript is compiled with `osacompile`, which resolves dictionary terms without opening a session.
215
217
 
216
218
  What no test covers is the automation itself: that a move really filed the mail, or a reply threaded correctly, is
217
219
  verified against a live mailbox.
package/dist/backend.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CleanUndeliverableResult, DeleteDraftsResult, DeleteMailResult, EmailLocator, InboxEmail, InboxFolderInfo, InboxSearchMatch, ListDraftsResult, MailFolderRef, MoveEmailsResult, PurgeDeletedItemsResult, ReplyEmailResult, SavedAttachment, SaveTemplateResult, SelectedEmail, SendDraftsResult, SentRecipientGroup, TemplateFolderResult } from './types';
1
+ import type { CleanUndeliverableResult, DeleteDraftsResult, DeleteMailResult, EmailLocator, InboxEmail, InboxFolderInfo, InboxSearchMatch, ListDraftsResult, MailFolderRef, MoveEmailsResult, PurgeDeletedItemsResult, ReplyEmailResult, SavedAttachment, SaveTemplateResult, SelectedEmail, SendDraftsResult, SendEmailResult, SentRecipientGroup, TemplateFolderResult } from './types';
2
2
  /** What to do with a composed email. */
3
3
  export type Disposition =
4
4
  /** Send it now. */
@@ -123,7 +123,7 @@ export interface EditTemplateRequest {
123
123
  /** One platform's Outlook automation. */
124
124
  export interface Backend {
125
125
  getOutlookAccounts(): Promise<string[]>;
126
- sendOutlookEmail(request: SendRequest): Promise<void>;
126
+ sendOutlookEmail(request: SendRequest): Promise<SendEmailResult>;
127
127
  replyOutlookEmail(request: ReplyRequest): Promise<ReplyEmailResult>;
128
128
  readInboxEmails(request: ReadInboxRequest): Promise<InboxEmail[]>;
129
129
  searchInboxByFilter(request: SearchRequest): Promise<InboxSearchMatch[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"","sourcesContent":["// What a platform implements.\n//\n// The public operations (bridge.ts) check every argument, apply every default,\n// and do all the work that is the same on both platforms — composing a reply\n// from a template, splitting a body from its quoted thread, choosing where\n// attachments go. What reaches a backend is a request in its final shape: counts\n// are whole numbers in range, strings are trimmed, folders are parsed, and each\n// field the platform's script needs is present. A backend's job is only to turn\n// that request into Outlook automation and its output into the result.\nimport type {\n CleanUndeliverableResult,\n DeleteDraftsResult,\n DeleteMailResult,\n EmailLocator,\n InboxEmail,\n InboxFolderInfo,\n InboxSearchMatch,\n ListDraftsResult,\n MailFolderRef,\n MoveEmailsResult,\n PurgeDeletedItemsResult,\n ReplyEmailResult,\n SavedAttachment,\n SaveTemplateResult,\n SelectedEmail,\n SendDraftsResult,\n SentRecipientGroup,\n TemplateFolderResult,\n} from './types';\n\n/** What to do with a composed email. */\nexport type Disposition =\n/** Send it now. */\n | 'send'\n /** Open it in a compose window for review. */\n | 'display'\n /** File it into Drafts without a window. */\n | 'save';\n\nexport interface AccountRequest {\n /** The mailbox's SMTP address, trimmed. */\n readonly account: string;\n}\n\nexport interface SendRequest extends AccountRequest {\n /** One entry per recipient, each an address or a display-name form. */\n readonly to: readonly string[];\n readonly cc: readonly string[];\n readonly bcc: readonly string[];\n readonly subject: string;\n readonly htmlBody: string;\n /** Absolute paths, each verified to exist. */\n readonly attachments: readonly string[];\n readonly disposition: Disposition;\n}\n\nexport interface ReplyRequest extends AccountRequest {\n readonly email: EmailLocator;\n /** The HTML to insert above the quoted original, fully composed. */\n readonly html: string;\n readonly replyAll: boolean;\n readonly disposition: Disposition;\n}\n\nexport interface ReadInboxRequest extends AccountRequest {\n readonly folder: MailFolderRef;\n /** The folder as the caller wrote it, for messages. */\n readonly folderLabel: string;\n readonly daysBack: number;\n readonly limit: number;\n /** 0 means no body is read at all. */\n readonly previewChars: number;\n}\n\nexport interface SearchRequest extends AccountRequest {\n readonly daysBack: number;\n readonly subjectLike?: string;\n readonly subjectPattern?: RegExp;\n readonly excludeReplies: boolean;\n readonly requireAttachment: boolean;\n readonly includeFolders: readonly string[];\n readonly excludeFolders: readonly string[];\n readonly includeBody: boolean;\n}\n\n/** One email as a backend reads it, before any splitting or capping. */\nexport interface RawEmail {\n readonly entryId: string;\n readonly subject: string;\n readonly senderName: string;\n readonly senderEmail: string;\n readonly receivedTime: string;\n /** The full plain-text body. */\n readonly body: string;\n readonly attachmentNames: readonly string[];\n}\n\nexport interface ListFoldersRequest extends AccountRequest {\n readonly maxDepth: number;\n}\n\nexport interface MoveRequest extends AccountRequest {\n /** Non-empty, deduplicated. */\n readonly entryIds: readonly string[];\n readonly folder: MailFolderRef;\n readonly folderLabel: string;\n readonly createIfMissing: boolean;\n}\n\nexport interface ListDraftsRequest extends AccountRequest {\n readonly limit: number;\n readonly previewChars: number;\n}\n\nexport interface EntryIdsRequest extends AccountRequest {\n /** Non-empty, deduplicated. */\n readonly entryIds: readonly string[];\n}\n\nexport interface DeleteEmailsRequest extends EntryIdsRequest {\n readonly allowProtected: boolean;\n readonly dryRun: boolean;\n}\n\nexport interface PurgeRequest extends AccountRequest {\n readonly olderThanDays: number;\n readonly dryRun: boolean;\n}\n\nexport interface SaveAttachmentsRequest {\n readonly email: EmailLocator;\n /** Non-empty; matched exactly first, then ignoring case and whitespace. */\n readonly fileNames: readonly string[];\n /** An existing directory to save into. */\n readonly destDir: string;\n}\n\nexport interface CleanUndeliverableRequest extends AccountRequest {\n readonly daysBack: number;\n readonly dryRun: boolean;\n}\n\nexport interface CollectBouncesRequest extends AccountRequest {\n readonly daysBack: number;\n readonly includeDeletedItems: boolean;\n}\n\nexport interface SentGroupsRequest extends AccountRequest {\n readonly daysBack: number;\n readonly limit: number;\n}\n\nexport interface ReadTemplatesRequest extends AccountRequest {\n readonly folder: string;\n readonly limit: number;\n readonly includeBody: boolean;\n /** Only the template with this subject, case-insensitively. */\n readonly subject?: string;\n}\n\nexport interface SaveTemplateRequest extends AccountRequest {\n readonly folder: string;\n readonly subject: string;\n readonly htmlBody: string;\n}\n\nexport interface EditTemplateRequest {\n readonly label: string;\n readonly html: string;\n}\n\n/** One platform's Outlook automation. */\nexport interface Backend {\n getOutlookAccounts(): Promise<string[]>;\n\n sendOutlookEmail(request: SendRequest): Promise<void>;\n\n replyOutlookEmail(request: ReplyRequest): Promise<ReplyEmailResult>;\n\n readInboxEmails(request: ReadInboxRequest): Promise<InboxEmail[]>;\n\n searchInboxByFilter(request: SearchRequest): Promise<InboxSearchMatch[]>;\n\n readSelectedEmail(): Promise<SelectedEmail>;\n\n readEmailBody(email: EmailLocator): Promise<RawEmail>;\n\n openOutlookEmail(email: EmailLocator): Promise<void>;\n\n listInboxFolders(request: ListFoldersRequest): Promise<InboxFolderInfo[]>;\n\n moveOutlookEmails(request: MoveRequest): Promise<MoveEmailsResult>;\n\n listOutlookDrafts(request: ListDraftsRequest): Promise<ListDraftsResult>;\n\n sendDrafts(request: EntryIdsRequest): Promise<SendDraftsResult>;\n\n sendAllDrafts(request: AccountRequest): Promise<SendDraftsResult>;\n\n deleteOutlookDrafts(request: EntryIdsRequest): Promise<DeleteDraftsResult>;\n\n deleteOutlookEmails(request: DeleteEmailsRequest): Promise<DeleteMailResult>;\n\n purgeDeletedItems(request: PurgeRequest): Promise<PurgeDeletedItemsResult>;\n\n saveEmailAttachments(request: SaveAttachmentsRequest): Promise<SavedAttachment[]>;\n\n cleanUndeliverableEmails(request: CleanUndeliverableRequest): Promise<CleanUndeliverableResult>;\n\n collectBouncedRecipients(request: CollectBouncesRequest): Promise<string[]>;\n\n readSentRecipientGroups(request: SentGroupsRequest): Promise<SentRecipientGroup[]>;\n\n listOutlookSignatures(): Promise<string[]>;\n\n /** '' when there is no signature by that name. */\n readOutlookSignatureHtml(name: string): Promise<string>;\n\n readTemplateEmails(request: ReadTemplatesRequest): Promise<TemplateFolderResult>;\n\n saveTemplateEmail(request: SaveTemplateRequest): Promise<SaveTemplateResult>;\n\n editEmailTemplate(request: EditTemplateRequest): Promise<string>;\n}\n"]}
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"","sourcesContent":["// What a platform implements.\n//\n// The public operations (bridge.ts) check every argument, apply every default,\n// and do all the work that is the same on both platforms — composing a reply\n// from a template, splitting a body from its quoted thread, choosing where\n// attachments go. What reaches a backend is a request in its final shape: counts\n// are whole numbers in range, strings are trimmed, folders are parsed, and each\n// field the platform's script needs is present. A backend's job is only to turn\n// that request into Outlook automation and its output into the result.\nimport type {\n CleanUndeliverableResult,\n DeleteDraftsResult,\n DeleteMailResult,\n EmailLocator,\n InboxEmail,\n InboxFolderInfo,\n InboxSearchMatch,\n ListDraftsResult,\n MailFolderRef,\n MoveEmailsResult,\n PurgeDeletedItemsResult,\n ReplyEmailResult,\n SavedAttachment,\n SaveTemplateResult,\n SelectedEmail,\n SendDraftsResult,\n SendEmailResult,\n SentRecipientGroup,\n TemplateFolderResult,\n} from './types';\n\n/** What to do with a composed email. */\nexport type Disposition =\n/** Send it now. */\n | 'send'\n /** Open it in a compose window for review. */\n | 'display'\n /** File it into Drafts without a window. */\n | 'save';\n\nexport interface AccountRequest {\n /** The mailbox's SMTP address, trimmed. */\n readonly account: string;\n}\n\nexport interface SendRequest extends AccountRequest {\n /** One entry per recipient, each an address or a display-name form. */\n readonly to: readonly string[];\n readonly cc: readonly string[];\n readonly bcc: readonly string[];\n readonly subject: string;\n readonly htmlBody: string;\n /** Absolute paths, each verified to exist. */\n readonly attachments: readonly string[];\n readonly disposition: Disposition;\n}\n\nexport interface ReplyRequest extends AccountRequest {\n readonly email: EmailLocator;\n /** The HTML to insert above the quoted original, fully composed. */\n readonly html: string;\n readonly replyAll: boolean;\n readonly disposition: Disposition;\n}\n\nexport interface ReadInboxRequest extends AccountRequest {\n readonly folder: MailFolderRef;\n /** The folder as the caller wrote it, for messages. */\n readonly folderLabel: string;\n readonly daysBack: number;\n readonly limit: number;\n /** 0 means no body is read at all. */\n readonly previewChars: number;\n}\n\nexport interface SearchRequest extends AccountRequest {\n readonly daysBack: number;\n readonly subjectLike?: string;\n readonly subjectPattern?: RegExp;\n readonly excludeReplies: boolean;\n readonly requireAttachment: boolean;\n readonly includeFolders: readonly string[];\n readonly excludeFolders: readonly string[];\n readonly includeBody: boolean;\n}\n\n/** One email as a backend reads it, before any splitting or capping. */\nexport interface RawEmail {\n readonly entryId: string;\n readonly subject: string;\n readonly senderName: string;\n readonly senderEmail: string;\n readonly receivedTime: string;\n /** The full plain-text body. */\n readonly body: string;\n readonly attachmentNames: readonly string[];\n}\n\nexport interface ListFoldersRequest extends AccountRequest {\n readonly maxDepth: number;\n}\n\nexport interface MoveRequest extends AccountRequest {\n /** Non-empty, deduplicated. */\n readonly entryIds: readonly string[];\n readonly folder: MailFolderRef;\n readonly folderLabel: string;\n readonly createIfMissing: boolean;\n}\n\nexport interface ListDraftsRequest extends AccountRequest {\n readonly limit: number;\n readonly previewChars: number;\n}\n\nexport interface EntryIdsRequest extends AccountRequest {\n /** Non-empty, deduplicated. */\n readonly entryIds: readonly string[];\n}\n\nexport interface DeleteEmailsRequest extends EntryIdsRequest {\n readonly allowProtected: boolean;\n readonly dryRun: boolean;\n}\n\nexport interface PurgeRequest extends AccountRequest {\n readonly olderThanDays: number;\n readonly dryRun: boolean;\n}\n\nexport interface SaveAttachmentsRequest {\n readonly email: EmailLocator;\n /** Non-empty; matched exactly first, then ignoring case and whitespace. */\n readonly fileNames: readonly string[];\n /** An existing directory to save into. */\n readonly destDir: string;\n}\n\nexport interface CleanUndeliverableRequest extends AccountRequest {\n readonly daysBack: number;\n readonly dryRun: boolean;\n}\n\nexport interface CollectBouncesRequest extends AccountRequest {\n readonly daysBack: number;\n readonly includeDeletedItems: boolean;\n}\n\nexport interface SentGroupsRequest extends AccountRequest {\n readonly daysBack: number;\n readonly limit: number;\n}\n\nexport interface ReadTemplatesRequest extends AccountRequest {\n readonly folder: string;\n readonly limit: number;\n readonly includeBody: boolean;\n /** Only the template with this subject, case-insensitively. */\n readonly subject?: string;\n}\n\nexport interface SaveTemplateRequest extends AccountRequest {\n readonly folder: string;\n readonly subject: string;\n readonly htmlBody: string;\n}\n\nexport interface EditTemplateRequest {\n readonly label: string;\n readonly html: string;\n}\n\n/** One platform's Outlook automation. */\nexport interface Backend {\n getOutlookAccounts(): Promise<string[]>;\n\n sendOutlookEmail(request: SendRequest): Promise<SendEmailResult>;\n\n replyOutlookEmail(request: ReplyRequest): Promise<ReplyEmailResult>;\n\n readInboxEmails(request: ReadInboxRequest): Promise<InboxEmail[]>;\n\n searchInboxByFilter(request: SearchRequest): Promise<InboxSearchMatch[]>;\n\n readSelectedEmail(): Promise<SelectedEmail>;\n\n readEmailBody(email: EmailLocator): Promise<RawEmail>;\n\n openOutlookEmail(email: EmailLocator): Promise<void>;\n\n listInboxFolders(request: ListFoldersRequest): Promise<InboxFolderInfo[]>;\n\n moveOutlookEmails(request: MoveRequest): Promise<MoveEmailsResult>;\n\n listOutlookDrafts(request: ListDraftsRequest): Promise<ListDraftsResult>;\n\n sendDrafts(request: EntryIdsRequest): Promise<SendDraftsResult>;\n\n sendAllDrafts(request: AccountRequest): Promise<SendDraftsResult>;\n\n deleteOutlookDrafts(request: EntryIdsRequest): Promise<DeleteDraftsResult>;\n\n deleteOutlookEmails(request: DeleteEmailsRequest): Promise<DeleteMailResult>;\n\n purgeDeletedItems(request: PurgeRequest): Promise<PurgeDeletedItemsResult>;\n\n saveEmailAttachments(request: SaveAttachmentsRequest): Promise<SavedAttachment[]>;\n\n cleanUndeliverableEmails(request: CleanUndeliverableRequest): Promise<CleanUndeliverableResult>;\n\n collectBouncedRecipients(request: CollectBouncesRequest): Promise<string[]>;\n\n readSentRecipientGroups(request: SentGroupsRequest): Promise<SentRecipientGroup[]>;\n\n listOutlookSignatures(): Promise<string[]>;\n\n /** '' when there is no signature by that name. */\n readOutlookSignatureHtml(name: string): Promise<string>;\n\n readTemplateEmails(request: ReadTemplatesRequest): Promise<TemplateFolderResult>;\n\n saveTemplateEmail(request: SaveTemplateRequest): Promise<SaveTemplateResult>;\n\n editEmailTemplate(request: EditTemplateRequest): Promise<string>;\n}\n"]}
package/dist/bridge.js CHANGED
@@ -163,7 +163,7 @@ function createOperations(backendOrNull) {
163
163
  if (signatureName) {
164
164
  request.htmlBody = (0, replyBody_1.placeSignature)(request.htmlBody, await (0, replyBody_1.resolveSignatureHtml)(platform, signatureName));
165
165
  }
166
- await platform.sendOutlookEmail(request);
166
+ return platform.sendOutlookEmail(request);
167
167
  },
168
168
  async replyOutlookEmail(params) {
169
169
  const platform = backend();
@@ -320,7 +320,7 @@ function createOperations(backendOrNull) {
320
320
  entryIds: ids,
321
321
  folder: ref,
322
322
  folderLabel: label,
323
- createIfMissing
323
+ createIfMissing,
324
324
  });
325
325
  },
326
326
  async listOutlookDrafts(emailAccount, options) {
@@ -360,7 +360,7 @@ function createOperations(backendOrNull) {
360
360
  const allowProtected = (0, args_1.flag)(o.allowProtected, 'allowProtected', false);
361
361
  const dryRun = (0, args_1.flag)(o.dryRun, 'dryRun', false);
362
362
  if (ids.length === 0)
363
- return { dryRun, deleted: 0, refused: 0, failed: 0, items: [] };
363
+ return (0, mail_1.deleteMailResult)(dryRun, []);
364
364
  return platform.deleteOutlookEmails({ account, entryIds: ids, allowProtected, dryRun });
365
365
  },
366
366
  async purgeDeletedItems(emailAccount, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";;;;;;AA2IA,4CAuWC;AA0CD,oCAaC;AAYD,kDAEC;AAKD,oCAEC;AAGD,4BAEC;AAnkBD,8DAA8D;AAC9D,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,0EAA0E;AAC1E,6EAA6E;AAC7E,4CAAoB;AACpB,gDAAwB;AACxB,uCAA2C;AAC3C,+BAAmC;AAEnC,wCAgBuB;AACvB,kDAA4F;AAC5F,4CAAkH;AAClH,wDAA0D;AAC1D,iCAA2D;AAC3D,qCAAsG;AACtG,uCAOmB;AAGnB,kCAAkC;AAClC,MAAM,QAAQ,GAAG;IACb,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,GAAG;IACjB,YAAY,EAAE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AAE,MAAM,CAAC,MAAM,CAAC,EAAC,GAAG,MAAM,EAAC,CAAC;QACnC,YAAY,EAAE,GAAG,EAAE,CAAC,GAAG;QACvB,QAAQ,EAAE,CAAC,SAA2B,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,IAAI;QAClE,WAAW,EAAE,CAAC,OAAsB,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,IAAA,sBAAY,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChG,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,kBAAU,EAAE,CAAC;QAC5B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,IAAA,oBAAU,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,QAA4C,CAAC;AACxD,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CAAC,UAAyB,EAAE;IAC3D,OAAO,YAAY,CAAC,gBAAgB,EAAE,IAAA,sBAAY,EAAC,IAAA,yBAAe,GAAE,EAAE,OAAO,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,qBAAqB,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC;AAE9D,+FAA+F;AAC/F,SAAgB,YAAY;IACxB,OAAO,qBAAqB,CAAC;AACjC,CAAC;AAED,mDAAmD;AACnD,SAAgB,QAAQ,CAAC,SAA2B;IAChD,OAAO,qBAAqB,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,oGAAoG;AACvF,QAAA,aAAa,GAAkB,gBAAgB,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["// The public operations, implemented once for both platforms.\n//\n// Each operation checks its arguments, applies its defaults, does whatever work\n// is the same everywhere — composing a reply from a template, splitting a body\n// from its quoted thread, choosing where attachments go — and hands a finished\n// request to this machine's backend. Keeping that here means a default, a\n// range or a validation rule can't come to differ between Windows and macOS.\nimport fs from 'fs';\nimport path from 'path';\nimport { windowsBackend } from './windows';\nimport { macBackend } from './mac';\nimport type { Backend, Disposition } from './backend';\nimport {\n count,\n emailLocator,\n entryIdList,\n flag,\n nameList,\n optionalContent,\n optionalRegExp,\n optionalText,\n optionsObject,\n recipientList,\n requiredContent,\n requiredText,\n requireObject,\n stringRecord,\n textList,\n} from './shared/args';\nimport { composeReplyHtml, placeSignature, resolveSignatureHtml } from './shared/replyBody';\nimport { accountSearchOrder, bestMatch, daysBackFor, requireDescribed, subjectPrefilter, } from './shared/locate';\nimport { buildBounceReport } from './shared/bounceReport';\nimport { folderOption, splitQuotedOriginal } from './mail';\nimport { AbortedError, InvalidRequestError, NotFoundError, UnsupportedPlatformError } from './errors';\nimport {\n attachmentDestination,\n type BridgeOptions,\n getGlobalConfig,\n mergeOptions,\n type ResolvedConfig,\n withConfig,\n} from './runtime';\nimport type { BridgeCapability, CapabilityMap, OutlookBridge, SavedAttachment } from './types';\n\n/** Every default, stated once. */\nconst DEFAULTS = {\n daysBack: 60,\n inboxLimit: 50,\n previewChars: 600,\n bodyMaxChars: 8000,\n quotedMaxChars: 4000,\n folderDepth: 2,\n draftsLimit: 100,\n draftsPreviewChars: 300,\n bounceDaysBack: 30,\n sentGroupsLimit: 3000,\n templateFolder: 'Templates',\n templatesLimit: 20,\n} as const;\n\n/** The widest window any scan accepts, in days. */\nconst MAX_DAYS = 3650;\n\n/**\n * Every operation name. `satisfies` makes this list fail to compile the moment\n * it and the OutlookBridge interface disagree, in either direction.\n */\nconst OPERATION_NAMES = {\n getOutlookAccounts: true,\n sendOutlookEmail: true,\n replyOutlookEmail: true,\n readInboxEmails: true,\n searchInboxByFilter: true,\n readSelectedEmail: true,\n readEmailBody: true,\n openOutlookEmail: true,\n locateEmail: true,\n listInboxFolders: true,\n moveOutlookEmails: true,\n listOutlookDrafts: true,\n sendDrafts: true,\n sendAllDrafts: true,\n deleteOutlookDrafts: true,\n deleteOutlookEmails: true,\n purgeDeletedItems: true,\n saveEmailAttachment: true,\n saveEmailAttachments: true,\n cleanUndeliverableEmails: true,\n collectBouncedRecipients: true,\n readSentRecipientGroups: true,\n readBounceReport: true,\n listOutlookSignatures: true,\n readOutlookSignatureHtml: true,\n readTemplateEmails: true,\n saveTemplateEmail: true,\n editEmailTemplate: true,\n} satisfies Record<BridgeCapability, true>;\n\nexport const OPERATIONS = Object.freeze(Object.keys(OPERATION_NAMES) as BridgeCapability[]);\n\n/** This machine's backend, or null where Outlook can't be automated. */\nfunction platformBackend(): Backend | null {\n switch (process.platform) {\n case 'win32':\n return windowsBackend;\n case 'darwin':\n return macBackend;\n default:\n return null;\n }\n}\n\nconst PLATFORM_BACKEND = platformBackend();\n\nfunction dispositionOf(sendImmediately: unknown, openDraftWindow: unknown): Disposition {\n if (flag(sendImmediately, 'sendImmediately', false)) return 'send';\n return flag(openDraftWindow, 'openDraftWindow', true) ? 'display' : 'save';\n}\n\n/** Attachment paths as absolute paths to files that exist — Outlook resolves a relative path against its own directory, not the caller's. */\nfunction attachmentFiles(value: unknown): string[] {\n return textList(value, 'attachments').map(file => {\n const absolute = path.resolve(file);\n let isFile = false;\n try {\n isFile = fs.statSync(absolute).isFile();\n } catch {\n // Reported below.\n }\n if (!isFile) throw new NotFoundError('file', `Attachment file '${absolute}' does not exist.`);\n return absolute;\n });\n}\n\n/**\n * The operations over one backend. A null backend is a platform without Outlook\n * automation: every operation rejects with UNSUPPORTED_PLATFORM before looking\n * at its arguments, since nothing about them could make it work.\n */\nexport function createOperations(backendOrNull: Backend | null): OutlookBridge {\n const backend = (): Backend => {\n if (!backendOrNull) throw new UnsupportedPlatformError(process.platform);\n return backendOrNull;\n };\n\n async function saveEmailAttachments(\n email: Parameters<OutlookBridge['saveEmailAttachments']>[0],\n fileNames: readonly string[],\n options?: Parameters<OutlookBridge['saveEmailAttachments']>[2],\n ): Promise<SavedAttachment[]> {\n const platform = backend();\n const target = emailLocator(email);\n const names = nameList(fileNames, 'fileNames');\n const destDir = optionalText(optionsObject(options).destDir, 'destDir');\n if (names.length === 0) return [];\n const destination = attachmentDestination(destDir === undefined ? undefined : path.resolve(destDir));\n try {\n return await platform.saveEmailAttachments({email: target, fileNames: names, destDir: destination.dir});\n } catch (error) {\n destination.discardIfUnused();\n throw error;\n }\n }\n\n return {\n async getOutlookAccounts() {\n return backend().getOutlookAccounts();\n },\n\n async sendOutlookEmail(params) {\n const platform = backend();\n const p = requireObject(params, 'params');\n const signatureName = optionalText(p.signatureName, 'signatureName');\n const request = {\n account: requiredText(p.emailAccount, 'emailAccount'),\n to: recipientList(p.to, 'to'),\n cc: recipientList(p.cc, 'cc'),\n bcc: recipientList(p.bcc, 'bcc'),\n subject: requiredContent(p.subject, 'subject'),\n htmlBody: requiredContent(p.htmlBody, 'htmlBody'),\n attachments: attachmentFiles(p.attachments),\n disposition: dispositionOf(p.sendImmediately, p.openDraftWindow),\n };\n if (request.disposition === 'send' && request.to.length + request.cc.length + request.bcc.length === 0) {\n throw new InvalidRequestError('An email sent immediately needs at least one recipient.');\n }\n if (signatureName) {\n request.htmlBody = placeSignature(request.htmlBody, await resolveSignatureHtml(platform, signatureName));\n }\n await platform.sendOutlookEmail(request);\n },\n\n async replyOutlookEmail(params) {\n const platform = backend();\n const p = requireObject(params, 'params');\n const account = requiredText(p.emailAccount, 'emailAccount');\n const email = emailLocator({entryId: p.entryId as string, storeId: p.storeId}, 'params');\n const html = await composeReplyHtml({\n account,\n htmlBody: optionalContent(p.htmlBody, 'htmlBody'),\n templateSubject: optionalText(p.templateSubject, 'templateSubject'),\n templateFolder: optionalText(p.templateFolder, 'templateFolder') ?? DEFAULTS.templateFolder,\n templateSection: optionalText(p.templateSection, 'templateSection'),\n templatePlaceholders: stringRecord(p.templatePlaceholders, 'templatePlaceholders'),\n signatureName: optionalText(p.signatureName, 'signatureName'),\n }, platform);\n return platform.replyOutlookEmail({\n account,\n email,\n html,\n replyAll: flag(p.replyAll, 'replyAll', false),\n disposition: dispositionOf(p.sendImmediately, p.openDraftWindow),\n });\n },\n\n async readInboxEmails(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n const {ref, label} = folderOption(optionalText(o.folder, 'folder'));\n return platform.readInboxEmails({\n account: requiredText(emailAccount, 'emailAccount'),\n folder: ref,\n folderLabel: label,\n daysBack: count(o.daysBack, 'daysBack', DEFAULTS.daysBack, 1, MAX_DAYS),\n limit: count(o.limit, 'limit', DEFAULTS.inboxLimit, 1, 100_000),\n previewChars: count(o.previewChars, 'previewChars', DEFAULTS.previewChars, 0, 1_000_000),\n });\n },\n\n async searchInboxByFilter(emailAccount, filter) {\n const platform = backend();\n const f = optionsObject(filter, 'filter');\n return platform.searchInboxByFilter({\n account: requiredText(emailAccount, 'emailAccount'),\n daysBack: count(f.daysBack, 'daysBack', DEFAULTS.daysBack, 1, MAX_DAYS),\n subjectLike: optionalText(f.subjectLike, 'subjectLike'),\n subjectPattern: optionalRegExp(f.subjectPattern, 'subjectPattern'),\n excludeReplies: flag(f.excludeReplies, 'excludeReplies', false),\n requireAttachment: flag(f.requireAttachment, 'requireAttachment', false),\n includeFolders: textList(f.includeFolders, 'includeFolders'),\n excludeFolders: textList(f.excludeFolders, 'excludeFolders'),\n includeBody: flag(f.includeBody, 'includeBody', true),\n });\n },\n\n async readSelectedEmail() {\n return backend().readSelectedEmail();\n },\n\n async readEmailBody(email, options) {\n const platform = backend();\n const target = emailLocator(email);\n const o = optionsObject(options);\n const maxChars = count(o.maxChars, 'maxChars', DEFAULTS.bodyMaxChars, 1, 100_000_000);\n const maxQuotedChars = count(o.maxQuotedChars, 'maxQuotedChars', DEFAULTS.quotedMaxChars, 0, 100_000_000);\n const includeQuoted = flag(o.includeQuoted, 'includeQuoted', false);\n const raw = await platform.readEmailBody(target);\n // The quoted thread is context, never the sender's own answer, so it is\n // capped by the tighter of the two limits.\n const {body, quoted, separator} = splitQuotedOriginal(raw.body);\n return {\n entryId: raw.entryId,\n subject: raw.subject,\n senderName: raw.senderName,\n senderEmail: raw.senderEmail,\n receivedTime: raw.receivedTime,\n body: body.slice(0, maxChars),\n truncated: body.length > maxChars,\n bodyLength: body.length,\n quoteSeparator: separator,\n quotedLength: quoted.length,\n quotedOriginal: includeQuoted ? quoted.slice(0, Math.min(maxChars, maxQuotedChars)) : '',\n attachmentNames: [...raw.attachmentNames],\n attachmentCount: raw.attachmentNames.length,\n };\n },\n\n async openOutlookEmail(email) {\n const platform = backend();\n await platform.openOutlookEmail(emailLocator(email));\n },\n\n async locateEmail(description, options) {\n const platform = backend();\n const d = requireObject(description, 'description');\n const wanted = {\n subject: optionalText(d.subject, 'subject'),\n sender: optionalText(d.sender, 'sender'),\n receivedTime: optionalText(d.receivedTime, 'receivedTime'),\n };\n requireDescribed(wanted);\n const emailAccount = optionalText(d.emailAccount, 'emailAccount');\n const folderPath = optionalText(d.folderPath, 'folderPath');\n const fallbackDays = count(optionsObject(options).daysBack, 'daysBack', DEFAULTS.daysBack, 1, MAX_DAYS);\n const search = {\n daysBack: Math.min(MAX_DAYS, daysBackFor(wanted.receivedTime, fallbackDays)),\n subjectLike: subjectPrefilter(wanted.subject),\n excludeReplies: false,\n requireAttachment: false,\n includeFolders: [],\n excludeFolders: [],\n // Judging a match reads subjects, senders and times, so the bodies\n // (the heavy part of a scan) are left behind.\n includeBody: false,\n };\n const accounts = emailAccount\n ? [emailAccount]\n : accountSearchOrder(await platform.getOutlookAccounts(), folderPath);\n\n let searched = 0;\n let firstFailure: unknown;\n for (const account of accounts) {\n let matches;\n try {\n matches = await platform.searchInboxByFilter({account, ...search});\n } catch (error) {\n if (error instanceof AbortedError) throw error;\n // One mailbox that can't be read shouldn't decide the answer\n // for the rest; only every one failing is an error.\n firstFailure ??= error;\n continue;\n }\n searched++;\n const found = bestMatch(wanted, matches);\n if (found) return found;\n }\n if (searched === 0 && firstFailure !== undefined) throw firstFailure;\n return null;\n },\n\n async listInboxFolders(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.listInboxFolders({\n account: requiredText(emailAccount, 'emailAccount'),\n maxDepth: count(o.maxDepth, 'maxDepth', DEFAULTS.folderDepth, 1, 10),\n });\n },\n\n async moveOutlookEmails(emailAccount, entryIds, folder, options) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const ids = entryIdList(entryIds);\n const {ref, label} = folderOption(requiredText(folder, 'folder'));\n const createIfMissing = flag(optionsObject(options).createIfMissing, 'createIfMissing', false);\n if (ids.length === 0) return {folderPath: '', folderCreated: false, moved: 0, failed: []};\n return platform.moveOutlookEmails({\n account,\n entryIds: ids,\n folder: ref,\n folderLabel: label,\n createIfMissing\n });\n },\n\n async listOutlookDrafts(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.listOutlookDrafts({\n account: requiredText(emailAccount, 'emailAccount'),\n limit: count(o.limit, 'limit', DEFAULTS.draftsLimit, 1, 100_000),\n previewChars: count(o.previewChars, 'previewChars', DEFAULTS.draftsPreviewChars, 0, 1_000_000),\n });\n },\n\n async sendDrafts(emailAccount, entryIds) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const ids = entryIdList(entryIds);\n if (ids.length === 0) return {sent: 0, failed: []};\n return platform.sendDrafts({account, entryIds: ids});\n },\n\n async sendAllDrafts(emailAccount) {\n const platform = backend();\n return platform.sendAllDrafts({account: requiredText(emailAccount, 'emailAccount')});\n },\n\n async deleteOutlookDrafts(emailAccount, entryIds) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const ids = entryIdList(entryIds);\n if (ids.length === 0) return {deleted: 0, failed: []};\n return platform.deleteOutlookDrafts({account, entryIds: ids});\n },\n\n async deleteOutlookEmails(emailAccount, entryIds, options) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const ids = entryIdList(entryIds);\n const o = optionsObject(options);\n const allowProtected = flag(o.allowProtected, 'allowProtected', false);\n const dryRun = flag(o.dryRun, 'dryRun', false);\n if (ids.length === 0) return {dryRun, deleted: 0, refused: 0, failed: 0, items: []};\n return platform.deleteOutlookEmails({account, entryIds: ids, allowProtected, dryRun});\n },\n\n async purgeDeletedItems(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.purgeDeletedItems({\n account: requiredText(emailAccount, 'emailAccount'),\n olderThanDays: count(o.olderThanDays, 'olderThanDays', 0, 0, 36_500),\n dryRun: flag(o.dryRun, 'dryRun', false),\n });\n },\n\n async saveEmailAttachment(email, fileName, options) {\n const [saved] = await saveEmailAttachments(email, [fileName], options);\n if (!saved) throw new NotFoundError('attachment', `Attachment '${fileName}' was not saved.`);\n return saved;\n },\n\n saveEmailAttachments,\n\n async cleanUndeliverableEmails(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.cleanUndeliverableEmails({\n account: requiredText(emailAccount, 'emailAccount'),\n daysBack: count(o.daysBack, 'daysBack', DEFAULTS.bounceDaysBack, 1, MAX_DAYS),\n // Deleting has to be asked for.\n dryRun: flag(o.dryRun, 'dryRun', true),\n });\n },\n\n async collectBouncedRecipients(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.collectBouncedRecipients({\n account: requiredText(emailAccount, 'emailAccount'),\n daysBack: count(o.daysBack, 'daysBack', DEFAULTS.bounceDaysBack, 1, MAX_DAYS),\n includeDeletedItems: flag(o.includeDeletedItems, 'includeDeletedItems', true),\n });\n },\n\n async readSentRecipientGroups(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.readSentRecipientGroups({\n account: requiredText(emailAccount, 'emailAccount'),\n daysBack: count(o.daysBack, 'daysBack', DEFAULTS.bounceDaysBack, 1, MAX_DAYS),\n limit: count(o.limit, 'limit', DEFAULTS.sentGroupsLimit, 1, 100_000),\n });\n },\n\n async readBounceReport(emailAccount, options) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const o = optionsObject(options);\n const daysBack = count(o.daysBack, 'daysBack', DEFAULTS.bounceDaysBack, 1, MAX_DAYS);\n const includeDeletedItems = flag(o.includeDeletedItems, 'includeDeletedItems', true);\n const bounced = await platform.collectBouncedRecipients({account, daysBack, includeDeletedItems});\n const sent = await platform.readSentRecipientGroups({account, daysBack, limit: DEFAULTS.sentGroupsLimit});\n return buildBounceReport(account, daysBack, bounced, sent);\n },\n\n async listOutlookSignatures() {\n return backend().listOutlookSignatures();\n },\n\n async readOutlookSignatureHtml(name) {\n const platform = backend();\n return platform.readOutlookSignatureHtml(requiredText(name, 'name'));\n },\n\n async readTemplateEmails(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.readTemplateEmails({\n account: requiredText(emailAccount, 'emailAccount'),\n folder: optionalText(o.folder, 'folder') ?? DEFAULTS.templateFolder,\n limit: count(o.limit, 'limit', DEFAULTS.templatesLimit, 1, 200),\n includeBody: flag(o.includeBody, 'includeBody', true),\n subject: optionalText(o.subject, 'subject'),\n });\n },\n\n async saveTemplateEmail(emailAccount, template) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const t = requireObject(template, 'template');\n return platform.saveTemplateEmail({\n account,\n folder: optionalText(t.folder, 'folder') ?? DEFAULTS.templateFolder,\n subject: requiredText(t.subject, 'subject'),\n htmlBody: requiredContent(t.htmlBody, 'htmlBody'),\n });\n },\n\n async editEmailTemplate(label, currentHtml) {\n const platform = backend();\n return platform.editEmailTemplate({\n label: requiredText(label, 'label'),\n html: requiredContent(currentHtml, 'currentHtml'),\n });\n },\n };\n}\n\n// ── Instances and capabilities ───────────────────────────────────────────\n\n/**\n * A bridge carrying its own settings, plus capability discovery.\n *\n * The exported functions are the same operations under the process-wide\n * settings; an instance is what to use when the process holds more than one\n * caller, or when a call needs its own timeout or AbortSignal.\n */\nexport interface OutlookBridgeInstance extends OutlookBridge {\n /** The settings this bridge runs with. */\n readonly options: ResolvedConfig;\n\n /** Which operations work on this machine. */\n capabilities(): CapabilityMap;\n\n /** Whether one operation works on this machine. */\n supports(operation: BridgeCapability): boolean;\n\n /**\n * A bridge like this one with some settings changed — how one call gets its\n * own budget or cancellation: `bridge.withOptions({ signal }).readInboxEmails(...)`.\n */\n withOptions(options: BridgeOptions): OutlookBridgeInstance;\n}\n\nfunction capabilityMap(backend: Backend | null): CapabilityMap {\n return Object.freeze(Object.fromEntries(OPERATIONS.map(name => [name, backend !== null]))) as CapabilityMap;\n}\n\ntype AnyOperation = (...args: unknown[]) => Promise<unknown>;\n\n/**\n * A bridge over `backend` whose every call runs with `config` in force.\n *\n * The platform code reads settings through `getConfig()`, so the config is put\n * in place around each call rather than passed into it: `withConfig` scopes it\n * to the call's whole async subtree, which is why two bridges with different\n * settings can run concurrently without seeing each other's.\n */\nexport function createBridge(backend: Backend | null, config: ResolvedConfig): OutlookBridgeInstance {\n const operations = createOperations(backend) as unknown as Record<BridgeCapability, AnyOperation>;\n const map = capabilityMap(backend);\n const instance: Record<string, unknown> = {\n options: Object.freeze({...config}),\n capabilities: () => map,\n supports: (operation: BridgeCapability) => map[operation] === true,\n withOptions: (options: BridgeOptions) => createBridge(backend, mergeOptions(config, options)),\n };\n for (const name of OPERATIONS) {\n instance[name] = (...args: unknown[]) => withConfig(config, () => operations[name](...args));\n }\n return instance as unknown as OutlookBridgeInstance;\n}\n\n/**\n * A bridge with its own settings, isolated from `configure()` and from every\n * other bridge. Options left out take the process-wide values as they stand\n * when this is called.\n *\n * ```ts\n * const outlook = createOutlookBridge({ timeoutMs: 30_000 });\n * const recent = await outlook.readInboxEmails('me@example.com', { daysBack: 7 });\n * ```\n */\nexport function createOutlookBridge(options: BridgeOptions = {}): OutlookBridgeInstance {\n return createBridge(PLATFORM_BACKEND, mergeOptions(getGlobalConfig(), options));\n}\n\nconst PLATFORM_CAPABILITIES = capabilityMap(PLATFORM_BACKEND);\n\n/** Which operations work on this machine: all of them on Windows and macOS, none elsewhere. */\nexport function capabilities(): CapabilityMap {\n return PLATFORM_CAPABILITIES;\n}\n\n/** Whether one operation works on this machine. */\nexport function supports(operation: BridgeCapability): boolean {\n return PLATFORM_CAPABILITIES[operation] === true;\n}\n\n/** The operations under the process-wide settings — what the package exports as plain functions. */\nexport const defaultBridge: OutlookBridge = createOperations(PLATFORM_BACKEND);\n"]}
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";;;;;;AA2IA,4CAuWC;AA0CD,oCAaC;AAYD,kDAEC;AAKD,oCAEC;AAGD,4BAEC;AAnkBD,8DAA8D;AAC9D,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,0EAA0E;AAC1E,6EAA6E;AAC7E,4CAAoB;AACpB,gDAAwB;AACxB,uCAA2C;AAC3C,+BAAmC;AAEnC,wCAgBuB;AACvB,kDAA4F;AAC5F,4CAAiH;AACjH,wDAA0D;AAC1D,iCAA6E;AAC7E,qCAAsG;AACtG,uCAOmB;AAGnB,kCAAkC;AAClC,MAAM,QAAQ,GAAG;IACb,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,GAAG;IACjB,YAAY,EAAE,IAAI;IAClB,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,GAAG;IAChB,kBAAkB,EAAE,GAAG;IACvB,cAAc,EAAE,EAAE;IAClB,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,WAAW;IAC3B,cAAc,EAAE,EAAE;CACZ,CAAC;AAEX,mDAAmD;AACnD,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB;;;GAGG;AACH,MAAM,eAAe,GAAG;IACpB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,IAAI;IACtB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,IAAI;IACrB,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,IAAI;IAC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AgB,mBAAmB,CAAC,UAAyB,EAAE;IAC3D,OAAO,YAAY,CAAC,gBAAgB,EAAE,IAAA,sBAAY,EAAC,IAAA,yBAAe,GAAE,EAAE,OAAO,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,qBAAqB,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC;AAE9D,+FAA+F;AAC/F,SAAgB,YAAY;IACxB,OAAO,qBAAqB,CAAC;AACjC,CAAC;AAED,mDAAmD;AACnD,SAAgB,QAAQ,CAAC,SAA2B;IAChD,OAAO,qBAAqB,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,oGAAoG;AACvF,QAAA,aAAa,GAAkB,gBAAgB,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["// The public operations, implemented once for both platforms.\n//\n// Each operation checks its arguments, applies its defaults, does whatever work\n// is the same everywhere — composing a reply from a template, splitting a body\n// from its quoted thread, choosing where attachments go — and hands a finished\n// request to this machine's backend. Keeping that here means a default, a\n// range or a validation rule can't come to differ between Windows and macOS.\nimport fs from 'fs';\nimport path from 'path';\nimport { windowsBackend } from './windows';\nimport { macBackend } from './mac';\nimport type { Backend, Disposition } from './backend';\nimport {\n count,\n emailLocator,\n entryIdList,\n flag,\n nameList,\n optionalContent,\n optionalRegExp,\n optionalText,\n optionsObject,\n recipientList,\n requiredContent,\n requiredText,\n requireObject,\n stringRecord,\n textList,\n} from './shared/args';\nimport { composeReplyHtml, placeSignature, resolveSignatureHtml } from './shared/replyBody';\nimport { accountSearchOrder, bestMatch, daysBackFor, requireDescribed, subjectPrefilter } from './shared/locate';\nimport { buildBounceReport } from './shared/bounceReport';\nimport { deleteMailResult, folderOption, splitQuotedOriginal } from './mail';\nimport { AbortedError, InvalidRequestError, NotFoundError, UnsupportedPlatformError } from './errors';\nimport {\n attachmentDestination,\n type BridgeOptions,\n getGlobalConfig,\n mergeOptions,\n type ResolvedConfig,\n withConfig,\n} from './runtime';\nimport type { BridgeCapability, CapabilityMap, OutlookBridge, SavedAttachment } from './types';\n\n/** Every default, stated once. */\nconst DEFAULTS = {\n daysBack: 60,\n inboxLimit: 50,\n previewChars: 600,\n bodyMaxChars: 8000,\n quotedMaxChars: 4000,\n folderDepth: 2,\n draftsLimit: 100,\n draftsPreviewChars: 300,\n bounceDaysBack: 30,\n sentGroupsLimit: 3000,\n templateFolder: 'Templates',\n templatesLimit: 20,\n} as const;\n\n/** The widest window any scan accepts, in days. */\nconst MAX_DAYS = 3650;\n\n/**\n * Every operation name. `satisfies` makes this list fail to compile the moment\n * it and the OutlookBridge interface disagree, in either direction.\n */\nconst OPERATION_NAMES = {\n getOutlookAccounts: true,\n sendOutlookEmail: true,\n replyOutlookEmail: true,\n readInboxEmails: true,\n searchInboxByFilter: true,\n readSelectedEmail: true,\n readEmailBody: true,\n openOutlookEmail: true,\n locateEmail: true,\n listInboxFolders: true,\n moveOutlookEmails: true,\n listOutlookDrafts: true,\n sendDrafts: true,\n sendAllDrafts: true,\n deleteOutlookDrafts: true,\n deleteOutlookEmails: true,\n purgeDeletedItems: true,\n saveEmailAttachment: true,\n saveEmailAttachments: true,\n cleanUndeliverableEmails: true,\n collectBouncedRecipients: true,\n readSentRecipientGroups: true,\n readBounceReport: true,\n listOutlookSignatures: true,\n readOutlookSignatureHtml: true,\n readTemplateEmails: true,\n saveTemplateEmail: true,\n editEmailTemplate: true,\n} satisfies Record<BridgeCapability, true>;\n\nexport const OPERATIONS = Object.freeze(Object.keys(OPERATION_NAMES) as BridgeCapability[]);\n\n/** This machine's backend, or null where Outlook can't be automated. */\nfunction platformBackend(): Backend | null {\n switch (process.platform) {\n case 'win32':\n return windowsBackend;\n case 'darwin':\n return macBackend;\n default:\n return null;\n }\n}\n\nconst PLATFORM_BACKEND = platformBackend();\n\nfunction dispositionOf(sendImmediately: unknown, openDraftWindow: unknown): Disposition {\n if (flag(sendImmediately, 'sendImmediately', false)) return 'send';\n return flag(openDraftWindow, 'openDraftWindow', true) ? 'display' : 'save';\n}\n\n/** Attachment paths as absolute paths to files that exist — Outlook resolves a relative path against its own directory, not the caller's. */\nfunction attachmentFiles(value: unknown): string[] {\n return textList(value, 'attachments').map(file => {\n const absolute = path.resolve(file);\n let isFile = false;\n try {\n isFile = fs.statSync(absolute).isFile();\n } catch {\n // Reported below.\n }\n if (!isFile) throw new NotFoundError('file', `Attachment file '${absolute}' does not exist.`);\n return absolute;\n });\n}\n\n/**\n * The operations over one backend. A null backend is a platform without Outlook\n * automation: every operation rejects with UNSUPPORTED_PLATFORM before looking\n * at its arguments, since nothing about them could make it work.\n */\nexport function createOperations(backendOrNull: Backend | null): OutlookBridge {\n const backend = (): Backend => {\n if (!backendOrNull) throw new UnsupportedPlatformError(process.platform);\n return backendOrNull;\n };\n\n async function saveEmailAttachments(\n email: Parameters<OutlookBridge['saveEmailAttachments']>[0],\n fileNames: readonly string[],\n options?: Parameters<OutlookBridge['saveEmailAttachments']>[2],\n ): Promise<SavedAttachment[]> {\n const platform = backend();\n const target = emailLocator(email);\n const names = nameList(fileNames, 'fileNames');\n const destDir = optionalText(optionsObject(options).destDir, 'destDir');\n if (names.length === 0) return [];\n const destination = attachmentDestination(destDir === undefined ? undefined : path.resolve(destDir));\n try {\n return await platform.saveEmailAttachments({ email: target, fileNames: names, destDir: destination.dir });\n } catch (error) {\n destination.discardIfUnused();\n throw error;\n }\n }\n\n return {\n async getOutlookAccounts() {\n return backend().getOutlookAccounts();\n },\n\n async sendOutlookEmail(params) {\n const platform = backend();\n const p = requireObject(params, 'params');\n const signatureName = optionalText(p.signatureName, 'signatureName');\n const request = {\n account: requiredText(p.emailAccount, 'emailAccount'),\n to: recipientList(p.to, 'to'),\n cc: recipientList(p.cc, 'cc'),\n bcc: recipientList(p.bcc, 'bcc'),\n subject: requiredContent(p.subject, 'subject'),\n htmlBody: requiredContent(p.htmlBody, 'htmlBody'),\n attachments: attachmentFiles(p.attachments),\n disposition: dispositionOf(p.sendImmediately, p.openDraftWindow),\n };\n if (request.disposition === 'send' && request.to.length + request.cc.length + request.bcc.length === 0) {\n throw new InvalidRequestError('An email sent immediately needs at least one recipient.');\n }\n if (signatureName) {\n request.htmlBody = placeSignature(request.htmlBody, await resolveSignatureHtml(platform, signatureName));\n }\n return platform.sendOutlookEmail(request);\n },\n\n async replyOutlookEmail(params) {\n const platform = backend();\n const p = requireObject(params, 'params');\n const account = requiredText(p.emailAccount, 'emailAccount');\n const email = emailLocator({ entryId: p.entryId as string, storeId: p.storeId }, 'params');\n const html = await composeReplyHtml({\n account,\n htmlBody: optionalContent(p.htmlBody, 'htmlBody'),\n templateSubject: optionalText(p.templateSubject, 'templateSubject'),\n templateFolder: optionalText(p.templateFolder, 'templateFolder') ?? DEFAULTS.templateFolder,\n templateSection: optionalText(p.templateSection, 'templateSection'),\n templatePlaceholders: stringRecord(p.templatePlaceholders, 'templatePlaceholders'),\n signatureName: optionalText(p.signatureName, 'signatureName'),\n }, platform);\n return platform.replyOutlookEmail({\n account,\n email,\n html,\n replyAll: flag(p.replyAll, 'replyAll', false),\n disposition: dispositionOf(p.sendImmediately, p.openDraftWindow),\n });\n },\n\n async readInboxEmails(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n const { ref, label } = folderOption(optionalText(o.folder, 'folder'));\n return platform.readInboxEmails({\n account: requiredText(emailAccount, 'emailAccount'),\n folder: ref,\n folderLabel: label,\n daysBack: count(o.daysBack, 'daysBack', DEFAULTS.daysBack, 1, MAX_DAYS),\n limit: count(o.limit, 'limit', DEFAULTS.inboxLimit, 1, 100_000),\n previewChars: count(o.previewChars, 'previewChars', DEFAULTS.previewChars, 0, 1_000_000),\n });\n },\n\n async searchInboxByFilter(emailAccount, filter) {\n const platform = backend();\n const f = optionsObject(filter, 'filter');\n return platform.searchInboxByFilter({\n account: requiredText(emailAccount, 'emailAccount'),\n daysBack: count(f.daysBack, 'daysBack', DEFAULTS.daysBack, 1, MAX_DAYS),\n subjectLike: optionalText(f.subjectLike, 'subjectLike'),\n subjectPattern: optionalRegExp(f.subjectPattern, 'subjectPattern'),\n excludeReplies: flag(f.excludeReplies, 'excludeReplies', false),\n requireAttachment: flag(f.requireAttachment, 'requireAttachment', false),\n includeFolders: textList(f.includeFolders, 'includeFolders'),\n excludeFolders: textList(f.excludeFolders, 'excludeFolders'),\n includeBody: flag(f.includeBody, 'includeBody', true),\n });\n },\n\n async readSelectedEmail() {\n return backend().readSelectedEmail();\n },\n\n async readEmailBody(email, options) {\n const platform = backend();\n const target = emailLocator(email);\n const o = optionsObject(options);\n const maxChars = count(o.maxChars, 'maxChars', DEFAULTS.bodyMaxChars, 1, 100_000_000);\n const maxQuotedChars = count(o.maxQuotedChars, 'maxQuotedChars', DEFAULTS.quotedMaxChars, 0, 100_000_000);\n const includeQuoted = flag(o.includeQuoted, 'includeQuoted', false);\n const raw = await platform.readEmailBody(target);\n // The quoted thread is context, never the sender's own answer, so it is\n // capped by the tighter of the two limits.\n const { body, quoted, separator } = splitQuotedOriginal(raw.body);\n return {\n entryId: raw.entryId,\n subject: raw.subject,\n senderName: raw.senderName,\n senderEmail: raw.senderEmail,\n receivedTime: raw.receivedTime,\n body: body.slice(0, maxChars),\n truncated: body.length > maxChars,\n bodyLength: body.length,\n quoteSeparator: separator,\n quotedLength: quoted.length,\n quotedOriginal: includeQuoted ? quoted.slice(0, Math.min(maxChars, maxQuotedChars)) : '',\n attachmentNames: [...raw.attachmentNames],\n attachmentCount: raw.attachmentNames.length,\n };\n },\n\n async openOutlookEmail(email) {\n const platform = backend();\n await platform.openOutlookEmail(emailLocator(email));\n },\n\n async locateEmail(description, options) {\n const platform = backend();\n const d = requireObject(description, 'description');\n const wanted = {\n subject: optionalText(d.subject, 'subject'),\n sender: optionalText(d.sender, 'sender'),\n receivedTime: optionalText(d.receivedTime, 'receivedTime'),\n };\n requireDescribed(wanted);\n const emailAccount = optionalText(d.emailAccount, 'emailAccount');\n const folderPath = optionalText(d.folderPath, 'folderPath');\n const fallbackDays = count(optionsObject(options).daysBack, 'daysBack', DEFAULTS.daysBack, 1, MAX_DAYS);\n const search = {\n daysBack: Math.min(MAX_DAYS, daysBackFor(wanted.receivedTime, fallbackDays)),\n subjectLike: subjectPrefilter(wanted.subject),\n excludeReplies: false,\n requireAttachment: false,\n includeFolders: [],\n excludeFolders: [],\n // Judging a match reads subjects, senders and times, so the bodies\n // (the heavy part of a scan) are left behind.\n includeBody: false,\n };\n const accounts = emailAccount\n ? [emailAccount]\n : accountSearchOrder(await platform.getOutlookAccounts(), folderPath);\n\n let searched = 0;\n let firstFailure: unknown;\n for (const account of accounts) {\n let matches;\n try {\n matches = await platform.searchInboxByFilter({ account, ...search });\n } catch (error) {\n if (error instanceof AbortedError) throw error;\n // One mailbox that can't be read shouldn't decide the answer\n // for the rest; only every one failing is an error.\n firstFailure ??= error;\n continue;\n }\n searched++;\n const found = bestMatch(wanted, matches);\n if (found) return found;\n }\n if (searched === 0 && firstFailure !== undefined) throw firstFailure;\n return null;\n },\n\n async listInboxFolders(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.listInboxFolders({\n account: requiredText(emailAccount, 'emailAccount'),\n maxDepth: count(o.maxDepth, 'maxDepth', DEFAULTS.folderDepth, 1, 10),\n });\n },\n\n async moveOutlookEmails(emailAccount, entryIds, folder, options) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const ids = entryIdList(entryIds);\n const { ref, label } = folderOption(requiredText(folder, 'folder'));\n const createIfMissing = flag(optionsObject(options).createIfMissing, 'createIfMissing', false);\n if (ids.length === 0) return { folderPath: '', folderCreated: false, moved: 0, failed: [] };\n return platform.moveOutlookEmails({\n account,\n entryIds: ids,\n folder: ref,\n folderLabel: label,\n createIfMissing,\n });\n },\n\n async listOutlookDrafts(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.listOutlookDrafts({\n account: requiredText(emailAccount, 'emailAccount'),\n limit: count(o.limit, 'limit', DEFAULTS.draftsLimit, 1, 100_000),\n previewChars: count(o.previewChars, 'previewChars', DEFAULTS.draftsPreviewChars, 0, 1_000_000),\n });\n },\n\n async sendDrafts(emailAccount, entryIds) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const ids = entryIdList(entryIds);\n if (ids.length === 0) return { sent: 0, failed: [] };\n return platform.sendDrafts({ account, entryIds: ids });\n },\n\n async sendAllDrafts(emailAccount) {\n const platform = backend();\n return platform.sendAllDrafts({ account: requiredText(emailAccount, 'emailAccount') });\n },\n\n async deleteOutlookDrafts(emailAccount, entryIds) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const ids = entryIdList(entryIds);\n if (ids.length === 0) return { deleted: 0, failed: [] };\n return platform.deleteOutlookDrafts({ account, entryIds: ids });\n },\n\n async deleteOutlookEmails(emailAccount, entryIds, options) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const ids = entryIdList(entryIds);\n const o = optionsObject(options);\n const allowProtected = flag(o.allowProtected, 'allowProtected', false);\n const dryRun = flag(o.dryRun, 'dryRun', false);\n if (ids.length === 0) return deleteMailResult(dryRun, []);\n return platform.deleteOutlookEmails({ account, entryIds: ids, allowProtected, dryRun });\n },\n\n async purgeDeletedItems(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.purgeDeletedItems({\n account: requiredText(emailAccount, 'emailAccount'),\n olderThanDays: count(o.olderThanDays, 'olderThanDays', 0, 0, 36_500),\n dryRun: flag(o.dryRun, 'dryRun', false),\n });\n },\n\n async saveEmailAttachment(email, fileName, options) {\n const [saved] = await saveEmailAttachments(email, [fileName], options);\n if (!saved) throw new NotFoundError('attachment', `Attachment '${fileName}' was not saved.`);\n return saved;\n },\n\n saveEmailAttachments,\n\n async cleanUndeliverableEmails(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.cleanUndeliverableEmails({\n account: requiredText(emailAccount, 'emailAccount'),\n daysBack: count(o.daysBack, 'daysBack', DEFAULTS.bounceDaysBack, 1, MAX_DAYS),\n // Deleting has to be asked for.\n dryRun: flag(o.dryRun, 'dryRun', true),\n });\n },\n\n async collectBouncedRecipients(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.collectBouncedRecipients({\n account: requiredText(emailAccount, 'emailAccount'),\n daysBack: count(o.daysBack, 'daysBack', DEFAULTS.bounceDaysBack, 1, MAX_DAYS),\n includeDeletedItems: flag(o.includeDeletedItems, 'includeDeletedItems', true),\n });\n },\n\n async readSentRecipientGroups(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.readSentRecipientGroups({\n account: requiredText(emailAccount, 'emailAccount'),\n daysBack: count(o.daysBack, 'daysBack', DEFAULTS.bounceDaysBack, 1, MAX_DAYS),\n limit: count(o.limit, 'limit', DEFAULTS.sentGroupsLimit, 1, 100_000),\n });\n },\n\n async readBounceReport(emailAccount, options) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const o = optionsObject(options);\n const daysBack = count(o.daysBack, 'daysBack', DEFAULTS.bounceDaysBack, 1, MAX_DAYS);\n const includeDeletedItems = flag(o.includeDeletedItems, 'includeDeletedItems', true);\n const bounced = await platform.collectBouncedRecipients({ account, daysBack, includeDeletedItems });\n const sent = await platform.readSentRecipientGroups({ account, daysBack, limit: DEFAULTS.sentGroupsLimit });\n return buildBounceReport(account, daysBack, bounced, sent);\n },\n\n async listOutlookSignatures() {\n return backend().listOutlookSignatures();\n },\n\n async readOutlookSignatureHtml(name) {\n const platform = backend();\n return platform.readOutlookSignatureHtml(requiredText(name, 'name'));\n },\n\n async readTemplateEmails(emailAccount, options) {\n const platform = backend();\n const o = optionsObject(options);\n return platform.readTemplateEmails({\n account: requiredText(emailAccount, 'emailAccount'),\n folder: optionalText(o.folder, 'folder') ?? DEFAULTS.templateFolder,\n limit: count(o.limit, 'limit', DEFAULTS.templatesLimit, 1, 200),\n includeBody: flag(o.includeBody, 'includeBody', true),\n subject: optionalText(o.subject, 'subject'),\n });\n },\n\n async saveTemplateEmail(emailAccount, template) {\n const platform = backend();\n const account = requiredText(emailAccount, 'emailAccount');\n const t = requireObject(template, 'template');\n return platform.saveTemplateEmail({\n account,\n folder: optionalText(t.folder, 'folder') ?? DEFAULTS.templateFolder,\n subject: requiredText(t.subject, 'subject'),\n htmlBody: requiredContent(t.htmlBody, 'htmlBody'),\n });\n },\n\n async editEmailTemplate(label, currentHtml) {\n const platform = backend();\n return platform.editEmailTemplate({\n label: requiredText(label, 'label'),\n html: requiredContent(currentHtml, 'currentHtml'),\n });\n },\n };\n}\n\n// ── Instances and capabilities ───────────────────────────────────────────\n\n/**\n * A bridge carrying its own settings, plus capability discovery.\n *\n * The exported functions are the same operations under the process-wide\n * settings; an instance is what to use when the process holds more than one\n * caller, or when a call needs its own timeout or AbortSignal.\n */\nexport interface OutlookBridgeInstance extends OutlookBridge {\n /** The settings this bridge runs with. */\n readonly options: ResolvedConfig;\n\n /** Which operations work on this machine. */\n capabilities(): CapabilityMap;\n\n /** Whether one operation works on this machine. */\n supports(operation: BridgeCapability): boolean;\n\n /**\n * A bridge like this one with some settings changed — how one call gets its\n * own budget or cancellation: `bridge.withOptions({ signal }).readInboxEmails(...)`.\n */\n withOptions(options: BridgeOptions): OutlookBridgeInstance;\n}\n\nfunction capabilityMap(backend: Backend | null): CapabilityMap {\n return Object.freeze(Object.fromEntries(OPERATIONS.map(name => [name, backend !== null]))) as CapabilityMap;\n}\n\ntype AnyOperation = (...args: unknown[]) => Promise<unknown>;\n\n/**\n * A bridge over `backend` whose every call runs with `config` in force.\n *\n * The platform code reads settings through `getConfig()`, so the config is put\n * in place around each call rather than passed into it: `withConfig` scopes it\n * to the call's whole async subtree, which is why two bridges with different\n * settings can run concurrently without seeing each other's.\n */\nexport function createBridge(backend: Backend | null, config: ResolvedConfig): OutlookBridgeInstance {\n const operations = createOperations(backend) as unknown as Record<BridgeCapability, AnyOperation>;\n const map = capabilityMap(backend);\n const instance: Record<string, unknown> = {\n options: Object.freeze({ ...config }),\n capabilities: () => map,\n supports: (operation: BridgeCapability) => map[operation] === true,\n withOptions: (options: BridgeOptions) => createBridge(backend, mergeOptions(config, options)),\n };\n for (const name of OPERATIONS) {\n instance[name] = (...args: unknown[]) => withConfig(config, () => operations[name](...args));\n }\n return instance as unknown as OutlookBridgeInstance;\n}\n\n/**\n * A bridge with its own settings, isolated from `configure()` and from every\n * other bridge. Options left out take the process-wide values as they stand\n * when this is called.\n *\n * ```ts\n * const outlook = createOutlookBridge({ timeoutMs: 30_000 });\n * const recent = await outlook.readInboxEmails('me@example.com', { daysBack: 7 });\n * ```\n */\nexport function createOutlookBridge(options: BridgeOptions = {}): OutlookBridgeInstance {\n return createBridge(PLATFORM_BACKEND, mergeOptions(getGlobalConfig(), options));\n}\n\nconst PLATFORM_CAPABILITIES = capabilityMap(PLATFORM_BACKEND);\n\n/** Which operations work on this machine: all of them on Windows and macOS, none elsewhere. */\nexport function capabilities(): CapabilityMap {\n return PLATFORM_CAPABILITIES;\n}\n\n/** Whether one operation works on this machine. */\nexport function supports(operation: BridgeCapability): boolean {\n return PLATFORM_CAPABILITIES[operation] === true;\n}\n\n/** The operations under the process-wide settings — what the package exports as plain functions. */\nexport const defaultBridge: OutlookBridge = createOperations(PLATFORM_BACKEND);\n"]}
package/dist/errors.d.ts CHANGED
@@ -117,8 +117,6 @@ export declare function failureTag(code: 'NOT_FOUND', kind: NotFoundKind): strin
117
117
  * message carries no tag.
118
118
  */
119
119
  export declare function errorFromTaggedMessage(message: string): OutlookError | null;
120
- /** Remove any failure tags from a message meant for display — e.g. a per-item error. */
121
- export declare function stripFailureTags(message: string): string;
122
120
  /**
123
121
  * Turn a failed run into the most specific error that can be proven.
124
122
  *
package/dist/errors.js CHANGED
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.AbortedError = exports.TimeoutError = exports.OutputTooLargeError = exports.ScriptError = exports.InvalidRequestError = exports.NotFoundError = exports.AccountNotFoundError = exports.NotImplementedError = exports.UnsupportedPlatformError = exports.OutlookError = void 0;
11
11
  exports.failureTag = failureTag;
12
12
  exports.errorFromTaggedMessage = errorFromTaggedMessage;
13
- exports.stripFailureTags = stripFailureTags;
14
13
  exports.classifyRunFailure = classifyRunFailure;
15
14
  const NOT_FOUND_KINDS = ['folder', 'email', 'attachment', 'template', 'signature', 'file'];
16
15
  /** Base class for every error this package raises deliberately. */
@@ -165,10 +164,6 @@ function errorFromTaggedMessage(message) {
165
164
  return new InvalidRequestError(text);
166
165
  }
167
166
  }
168
- /** Remove any failure tags from a message meant for display — e.g. a per-item error. */
169
- function stripFailureTags(message) {
170
- return message.replace(new RegExp(FAILURE_TAG.source, 'g'), '').trim();
171
- }
172
167
  /**
173
168
  * Turn a failed run into the most specific error that can be proven.
174
169
  *
@@ -199,7 +194,7 @@ function classifyRunFailure(init) {
199
194
  durationMs,
200
195
  message,
201
196
  line: init.line,
202
- cause: nodeError ?? undefined
197
+ cause: nodeError ?? undefined,
203
198
  });
204
199
  }
205
200
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,wEAAwE;AACxE,4CAA4C;;;AAqM5C,gCAEC;AAWD,wDAcC;AAGD,4CAEC;AAUD,gDAyCC;AAxPD,MAAM,eAAe,GAA4B,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAEpH,mEAAmE;AACnE,MAAa,YAAa,SAAQ,KAAK;IAC1B,IAAI,CAAmB;IAEhC,kDAAkD;IACzC,KAAK,CAAW;IAEzB,YAAY,IAAsB,EAAE,OAAe,EAAE,OAA6B;QAC9E,wEAAwE;QACxE,sEAAsE;QACtE,kCAAkC;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO;YAAE,IAAI,CAAC,K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AS,EAAE,IAAI,KAAK,mCAAmC,EAAE,CAAC;QAC1D,OAAO,IAAI,mBAAmB,CAAC,EAAC,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,CAAC,EAAE,MAAM,EAAC,CAAC,CAAC;IAC/F,CAAC;IACD,IAAI,SAAS,EAAE,MAAM,IAAI,SAAS,EAAE,CAAC;QACjC,OAAO,IAAI,YAAY,CAAC,EAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAC,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,SAAS,EAAE,OAAO,IAAI,EAAE,CAAC;IACzF,MAAM,KAAK,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,OAAO,IAAI,WAAW,CAAC;QACnB,MAAM;QACN,MAAM;QACN,MAAM;QACN,UAAU;QACV,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,SAAS,IAAI,SAAS;KAChC,CAAC,CAAC;AACP,CAAC","sourcesContent":["// The package's error taxonomy.\n//\n// Every failure the package raises on purpose is an `OutlookError` carrying a\n// stable `code`. The codes are the API; the messages beside them are not — a\n// caller branches on `error.code`, never on message text, so a message can be\n// reworded without breaking anyone. `err instanceof OutlookError` alone\n// separates an expected failure from a bug.\n\n/**\n * Stable discriminants.\n *\n * - `UNSUPPORTED_PLATFORM` — no Outlook automation exists on this OS.\n * - `NOT_IMPLEMENTED` — the platform could do this, but this corner isn't written.\n * - `ACCOUNT_NOT_FOUND` — no mailbox in the Outlook profile matches the address.\n * - `NOT_FOUND` — a folder, email, attachment, template, signature or file didn't resolve.\n * - `INVALID_REQUEST` — the arguments can't produce a call.\n * - `SCRIPT_FAILED` — the automation script ran and failed.\n * - `OUTPUT_TOO_LARGE` — the script printed more than `maxBufferBytes` and was killed.\n * - `TIMEOUT` — the run exceeded its time budget and was killed.\n * - `ABORTED` — the caller's AbortSignal fired.\n */\nexport type OutlookErrorCode =\n | 'UNSUPPORTED_PLATFORM'\n | 'NOT_IMPLEMENTED'\n | 'ACCOUNT_NOT_FOUND'\n | 'NOT_FOUND'\n | 'INVALID_REQUEST'\n | 'SCRIPT_FAILED'\n | 'OUTPUT_TOO_LARGE'\n | 'TIMEOUT'\n | 'ABORTED';\n\n/** The interpreter a script ran under. */\nexport type ScriptRunner = 'powershell' | 'osascript';\n\n/** What a NOT_FOUND error failed to find. */\nexport type NotFoundKind = 'folder' | 'email' | 'attachment' | 'template' | 'signature' | 'file';\n\nconst NOT_FOUND_KINDS: readonly NotFoundKind[] = ['folder', 'email', 'attachment', 'template', 'signature', 'file'];\n\n/** Base class for every error this package raises deliberately. */\nexport class OutlookError extends Error {\n readonly code: OutlookErrorCode;\n\n /** The underlying failure, when there was one. */\n readonly cause?: unknown;\n\n constructor(code: OutlookErrorCode, message: string, options?: { cause?: unknown }) {\n // `cause` is an own enumerable field rather than `super`'s option: that\n // is what puts it in a JSON dump of the error, which is where someone\n // logging a failure looks for it.\n super(message);\n if (options && 'cause' in options) this.cause = options.cause;\n this.code = code;\n // `name` is what an unhandled-rejection dump shows, so make it the subclass.\n this.name = new.target.name;\n }\n}\n\n/** This OS has no Outlook automation. */\nexport class UnsupportedPlatformError extends OutlookError {\n /** The platform that was asked, i.e. `process.platform` at the time. */\n readonly platform: string;\n\n constructor(platform: string) {\n super('UNSUPPORTED_PLATFORM', `Outlook automation is only supported on Windows and macOS (running on '${platform}').`);\n this.platform = platform;\n }\n}\n\n/** The platform could do this, but this corner isn't written. */\nexport class NotImplementedError extends OutlookError {\n /** What isn't implemented. */\n readonly operation: string;\n readonly platform: string;\n\n constructor(operation: string, platform: string) {\n super('NOT_IMPLEMENTED', `${operation} is not implemented for Outlook on ${platform}.`);\n this.operation = operation;\n this.platform = platform;\n }\n}\n\n/** No mailbox in the Outlook profile matches the requested address. */\nexport class AccountNotFoundError extends OutlookError {\n readonly account: string;\n\n constructor(account: string, message = `Outlook account '${account}' not found.`) {\n super('ACCOUNT_NOT_FOUND', message);\n this.account = account;\n }\n}\n\n/** A named folder, email, attachment, template, signature or file didn't resolve. */\nexport class NotFoundError extends OutlookError {\n readonly kind: NotFoundKind;\n\n constructor(kind: NotFoundKind, message: string) {\n super('NOT_FOUND', message);\n this.kind = kind;\n }\n}\n\n/** The arguments can't produce a call. */\nexport class InvalidRequestError extends OutlookError {\n constructor(message: string) {\n super('INVALID_REQUEST', message);\n }\n}\n\n/**\n * The script ran and failed.\n *\n * Carries the generated script verbatim — the most useful thing to have when\n * one of these fires, and otherwise reachable only through a debug hook wired\n * up in advance.\n */\nexport class ScriptError extends OutlookError {\n readonly runner: ScriptRunner;\n readonly script: string;\n readonly stderr: string;\n readonly durationMs: number;\n /** The line of `script` the failure was raised on, when the runner reports one. */\n readonly line?: number;\n\n constructor(init: {\n runner: ScriptRunner;\n script: string;\n stderr: string;\n durationMs: number;\n message?: string;\n line?: number;\n cause?: unknown;\n }) {\n super('SCRIPT_FAILED', init.message || init.stderr || `${init.runner} failed with no output.`, {cause: init.cause});\n this.runner = init.runner;\n this.script = init.script;\n this.stderr = init.stderr;\n this.durationMs = init.durationMs;\n if (init.line !== undefined) this.line = init.line;\n }\n}\n\n/** The script printed more than `maxBufferBytes` and was killed. */\nexport class OutputTooLargeError extends OutlookError {\n readonly runner: ScriptRunner;\n readonly maxBufferBytes: number;\n readonly script: string;\n\n constructor(init: { runner: ScriptRunner; maxBufferBytes: number; script: string }) {\n super(\n 'OUTPUT_TOO_LARGE',\n `${init.runner} output exceeded maxBufferBytes (${init.maxBufferBytes}). `\n + 'Raise maxBufferBytes, or narrow the request.',\n );\n this.runner = init.runner;\n this.maxBufferBytes = init.maxBufferBytes;\n this.script = init.script;\n }\n}\n\n/** The run exceeded its time budget and was killed. */\nexport class TimeoutError extends OutlookError {\n readonly runner: ScriptRunner;\n readonly timeoutMs: number;\n readonly script: string;\n\n constructor(init: { runner: ScriptRunner; timeoutMs: number; script: string }) {\n super('TIMEOUT', `${init.runner} run exceeded its ${init.timeoutMs}ms budget and was killed.`);\n this.runner = init.runner;\n this.timeoutMs = init.timeoutMs;\n this.script = init.script;\n }\n}\n\n/** The caller's AbortSignal fired. */\nexport class AbortedError extends OutlookError {\n readonly runner: ScriptRunner;\n\n constructor(runner: ScriptRunner, reason?: unknown) {\n super('ABORTED', `${runner} run was aborted by the caller.`, {cause: reason});\n this.runner = runner;\n }\n}\n\n// ── Typed failures from inside a script ─────────────────────────────────\n//\n// A generated script can only fail by printing a message, so a script that\n// knows WHY it failed — the folder isn't there, the id resolves to nothing —\n// says so by starting the message with a tag: `[outlook-bridge:NOT_FOUND:folder]`.\n// The runner turns a tagged message into the matching error class and strips\n// the tag, so a caller can branch on NOT_FOUND without reading the sentence.\n\n/** The codes a script may raise by tagging its failure message. */\nexport type ScriptFailureCode = 'ACCOUNT_NOT_FOUND' | 'NOT_FOUND' | 'INVALID_REQUEST';\n\n/**\n * The tag that opens a typed script failure, ready to be followed by the\n * human-readable message. Plain ASCII with no quote or `$`, so it can sit\n * inside a PowerShell or AppleScript string literal unescaped.\n */\nexport function failureTag(code: 'ACCOUNT_NOT_FOUND' | 'INVALID_REQUEST'): string;\nexport function failureTag(code: 'NOT_FOUND', kind: NotFoundKind): string;\nexport function failureTag(code: ScriptFailureCode, kind?: NotFoundKind): string {\n return `[outlook-bridge:${code}${kind ? `:${kind}` : ''}] `;\n}\n\nconst FAILURE_TAG = /\\[outlook-bridge:(ACCOUNT_NOT_FOUND|NOT_FOUND|INVALID_REQUEST)(?::([a-z]+))?\\]\\s*/;\n\n/** A script's account-not-found message names the address in single quotes. */\nconst QUOTED_ACCOUNT = /'(.*)'/;\n\n/**\n * The typed error a tagged script message stands for, or null when the\n * message carries no tag.\n */\nexport function errorFromTaggedMessage(message: string): OutlookError | null {\n const match = FAILURE_TAG.exec(message);\n if (!match) return null;\n const text = (message.slice(0, match.index) + message.slice(match.index + match[0].length)).trim();\n switch (match[1]) {\n case 'ACCOUNT_NOT_FOUND':\n return new AccountNotFoundError(QUOTED_ACCOUNT.exec(text)?.[1] ?? '', text);\n case 'NOT_FOUND': {\n const kind = NOT_FOUND_KINDS.find(k => k === match[2]) ?? 'email';\n return new NotFoundError(kind, text);\n }\n default:\n return new InvalidRequestError(text);\n }\n}\n\n/** Remove any failure tags from a message meant for display — e.g. a per-item error. */\nexport function stripFailureTags(message: string): string {\n return message.replace(new RegExp(FAILURE_TAG.source, 'g'), '').trim();\n}\n\n/**\n * Turn a failed run into the most specific error that can be proven.\n *\n * Order matters. An abort and a timeout both kill the child, so the signal's\n * own state is checked before the kill; an overflow kills it too, and is told\n * apart by its error code. Only then is the script's message worth reading — a\n * process killed mid-write may have printed a partial, misleading one.\n */\nexport function classifyRunFailure(init: {\n runner: ScriptRunner;\n script: string;\n /** Everything the run wrote to stderr. */\n stderr: string;\n /** The script's own failure message, when the runner could isolate one. */\n message?: string;\n /** The script line the failure was raised on, when known. */\n line?: number;\n durationMs: number;\n /** The error `execFile` handed back. */\n nodeError?: (Error & { killed?: boolean; code?: string | number | null }) | null;\n /** The time budget in force, for the TIMEOUT message. */\n timeoutMs?: number;\n /** The stdout cap in force, for the OUTPUT_TOO_LARGE message. */\n maxBufferBytes?: number;\n signal?: AbortSignal;\n}): OutlookError {\n const {runner, script, stderr, durationMs, nodeError, timeoutMs, signal} = init;\n\n if (signal?.aborted || nodeError?.name === 'AbortError' || nodeError?.code === 'ABORT_ERR') {\n return new AbortedError(runner, signal?.reason);\n }\n if (nodeError?.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') {\n return new OutputTooLargeError({runner, maxBufferBytes: init.maxBufferBytes ?? 0, script});\n }\n if (nodeError?.killed && timeoutMs) {\n return new TimeoutError({runner, timeoutMs, script});\n }\n const message = (init.message ?? '').trim() || stderr.trim() || nodeError?.message || '';\n const typed = errorFromTaggedMessage(message);\n if (typed) return typed;\n return new ScriptError({\n runner,\n script,\n stderr,\n durationMs,\n message,\n line: init.line,\n cause: nodeError ?? undefined\n });\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,wEAAwE;AACxE,4CAA4C;;;AAqM5C,gCAEC;AAWD,wDAcC;AAUD,gDAyCC;AAnPD,MAAM,eAAe,GAA4B,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAEpH,mEAAmE;AACnE,MAAa,YAAa,SAAQ,KAAK;IAC1B,IAAI,CAAmB;IAEhC,kDAAkD;IACzC,KAAK,CAAW;IAEzB,YAAY,IAAsB,EAAE,OAAe,EAAE,OAA6B;QAC9E,wEAAwE;QACxE,sEAAsE;QACtE,kCAAkC;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,6EAA6E;QAC7E,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAChC,CAAC;CACJ;AAhBD,oCAgBC;AAED,yCAAyC;AACzC,MAAa,wBAAyB,SAAQ,YAAY;IACtD,wEAAwE;IAC/D,QAAQ,CAAS;IAE1B,YAAY,QAAgB;QACxB,KAAK,CAAC,sBAAsB,EAAE,0EAA0E,QAAQ,KAAK,CAAC,CAAC;QACvH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ;AARD,4DAQC;AAED,iEAAiE;AACjE,MAAa,mBAAoB,SAAQ,YAAY;IACjD,8BAA8B;IACrB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AI;QACf,KAAK,EAAE,SAAS,IAAI,SAAS;KAChC,CAAC,CAAC;AACP,CAAC","sourcesContent":["// The package's error taxonomy.\n//\n// Every failure the package raises on purpose is an `OutlookError` carrying a\n// stable `code`. The codes are the API; the messages beside them are not — a\n// caller branches on `error.code`, never on message text, so a message can be\n// reworded without breaking anyone. `err instanceof OutlookError` alone\n// separates an expected failure from a bug.\n\n/**\n * Stable discriminants.\n *\n * - `UNSUPPORTED_PLATFORM` — no Outlook automation exists on this OS.\n * - `NOT_IMPLEMENTED` — the platform could do this, but this corner isn't written.\n * - `ACCOUNT_NOT_FOUND` — no mailbox in the Outlook profile matches the address.\n * - `NOT_FOUND` — a folder, email, attachment, template, signature or file didn't resolve.\n * - `INVALID_REQUEST` — the arguments can't produce a call.\n * - `SCRIPT_FAILED` — the automation script ran and failed.\n * - `OUTPUT_TOO_LARGE` — the script printed more than `maxBufferBytes` and was killed.\n * - `TIMEOUT` — the run exceeded its time budget and was killed.\n * - `ABORTED` — the caller's AbortSignal fired.\n */\nexport type OutlookErrorCode =\n | 'UNSUPPORTED_PLATFORM'\n | 'NOT_IMPLEMENTED'\n | 'ACCOUNT_NOT_FOUND'\n | 'NOT_FOUND'\n | 'INVALID_REQUEST'\n | 'SCRIPT_FAILED'\n | 'OUTPUT_TOO_LARGE'\n | 'TIMEOUT'\n | 'ABORTED';\n\n/** The interpreter a script ran under. */\nexport type ScriptRunner = 'powershell' | 'osascript';\n\n/** What a NOT_FOUND error failed to find. */\nexport type NotFoundKind = 'folder' | 'email' | 'attachment' | 'template' | 'signature' | 'file';\n\nconst NOT_FOUND_KINDS: readonly NotFoundKind[] = ['folder', 'email', 'attachment', 'template', 'signature', 'file'];\n\n/** Base class for every error this package raises deliberately. */\nexport class OutlookError extends Error {\n readonly code: OutlookErrorCode;\n\n /** The underlying failure, when there was one. */\n readonly cause?: unknown;\n\n constructor(code: OutlookErrorCode, message: string, options?: { cause?: unknown }) {\n // `cause` is an own enumerable field rather than `super`'s option: that\n // is what puts it in a JSON dump of the error, which is where someone\n // logging a failure looks for it.\n super(message);\n if (options && 'cause' in options) this.cause = options.cause;\n this.code = code;\n // `name` is what an unhandled-rejection dump shows, so make it the subclass.\n this.name = new.target.name;\n }\n}\n\n/** This OS has no Outlook automation. */\nexport class UnsupportedPlatformError extends OutlookError {\n /** The platform that was asked, i.e. `process.platform` at the time. */\n readonly platform: string;\n\n constructor(platform: string) {\n super('UNSUPPORTED_PLATFORM', `Outlook automation is only supported on Windows and macOS (running on '${platform}').`);\n this.platform = platform;\n }\n}\n\n/** The platform could do this, but this corner isn't written. */\nexport class NotImplementedError extends OutlookError {\n /** What isn't implemented. */\n readonly operation: string;\n readonly platform: string;\n\n constructor(operation: string, platform: string) {\n super('NOT_IMPLEMENTED', `${operation} is not implemented for Outlook on ${platform}.`);\n this.operation = operation;\n this.platform = platform;\n }\n}\n\n/** No mailbox in the Outlook profile matches the requested address. */\nexport class AccountNotFoundError extends OutlookError {\n readonly account: string;\n\n constructor(account: string, message = `Outlook account '${account}' not found.`) {\n super('ACCOUNT_NOT_FOUND', message);\n this.account = account;\n }\n}\n\n/** A named folder, email, attachment, template, signature or file didn't resolve. */\nexport class NotFoundError extends OutlookError {\n readonly kind: NotFoundKind;\n\n constructor(kind: NotFoundKind, message: string) {\n super('NOT_FOUND', message);\n this.kind = kind;\n }\n}\n\n/** The arguments can't produce a call. */\nexport class InvalidRequestError extends OutlookError {\n constructor(message: string) {\n super('INVALID_REQUEST', message);\n }\n}\n\n/**\n * The script ran and failed.\n *\n * Carries the generated script verbatim — the most useful thing to have when\n * one of these fires, and otherwise reachable only through a debug hook wired\n * up in advance.\n */\nexport class ScriptError extends OutlookError {\n readonly runner: ScriptRunner;\n readonly script: string;\n readonly stderr: string;\n readonly durationMs: number;\n /** The line of `script` the failure was raised on, when the runner reports one. */\n readonly line?: number;\n\n constructor(init: {\n runner: ScriptRunner;\n script: string;\n stderr: string;\n durationMs: number;\n message?: string;\n line?: number;\n cause?: unknown;\n }) {\n super('SCRIPT_FAILED', init.message || init.stderr || `${init.runner} failed with no output.`, { cause: init.cause });\n this.runner = init.runner;\n this.script = init.script;\n this.stderr = init.stderr;\n this.durationMs = init.durationMs;\n if (init.line !== undefined) this.line = init.line;\n }\n}\n\n/** The script printed more than `maxBufferBytes` and was killed. */\nexport class OutputTooLargeError extends OutlookError {\n readonly runner: ScriptRunner;\n readonly maxBufferBytes: number;\n readonly script: string;\n\n constructor(init: { runner: ScriptRunner; maxBufferBytes: number; script: string }) {\n super(\n 'OUTPUT_TOO_LARGE',\n `${init.runner} output exceeded maxBufferBytes (${init.maxBufferBytes}). `\n + 'Raise maxBufferBytes, or narrow the request.',\n );\n this.runner = init.runner;\n this.maxBufferBytes = init.maxBufferBytes;\n this.script = init.script;\n }\n}\n\n/** The run exceeded its time budget and was killed. */\nexport class TimeoutError extends OutlookError {\n readonly runner: ScriptRunner;\n readonly timeoutMs: number;\n readonly script: string;\n\n constructor(init: { runner: ScriptRunner; timeoutMs: number; script: string }) {\n super('TIMEOUT', `${init.runner} run exceeded its ${init.timeoutMs}ms budget and was killed.`);\n this.runner = init.runner;\n this.timeoutMs = init.timeoutMs;\n this.script = init.script;\n }\n}\n\n/** The caller's AbortSignal fired. */\nexport class AbortedError extends OutlookError {\n readonly runner: ScriptRunner;\n\n constructor(runner: ScriptRunner, reason?: unknown) {\n super('ABORTED', `${runner} run was aborted by the caller.`, { cause: reason });\n this.runner = runner;\n }\n}\n\n// ── Typed failures from inside a script ─────────────────────────────────\n//\n// A generated script can only fail by printing a message, so a script that\n// knows WHY it failed — the folder isn't there, the id resolves to nothing —\n// says so by starting the message with a tag: `[outlook-bridge:NOT_FOUND:folder]`.\n// The runner turns a tagged message into the matching error class and strips\n// the tag, so a caller can branch on NOT_FOUND without reading the sentence.\n\n/** The codes a script may raise by tagging its failure message. */\nexport type ScriptFailureCode = 'ACCOUNT_NOT_FOUND' | 'NOT_FOUND' | 'INVALID_REQUEST';\n\n/**\n * The tag that opens a typed script failure, ready to be followed by the\n * human-readable message. Plain ASCII with no quote or `$`, so it can sit\n * inside a PowerShell or AppleScript string literal unescaped.\n */\nexport function failureTag(code: 'ACCOUNT_NOT_FOUND' | 'INVALID_REQUEST'): string;\nexport function failureTag(code: 'NOT_FOUND', kind: NotFoundKind): string;\nexport function failureTag(code: ScriptFailureCode, kind?: NotFoundKind): string {\n return `[outlook-bridge:${code}${kind ? `:${kind}` : ''}] `;\n}\n\nconst FAILURE_TAG = /\\[outlook-bridge:(ACCOUNT_NOT_FOUND|NOT_FOUND|INVALID_REQUEST)(?::([a-z]+))?\\]\\s*/;\n\n/** A script's account-not-found message names the address in single quotes. */\nconst QUOTED_ACCOUNT = /'(.*)'/;\n\n/**\n * The typed error a tagged script message stands for, or null when the\n * message carries no tag.\n */\nexport function errorFromTaggedMessage(message: string): OutlookError | null {\n const match = FAILURE_TAG.exec(message);\n if (!match) return null;\n const text = (message.slice(0, match.index) + message.slice(match.index + match[0].length)).trim();\n switch (match[1]) {\n case 'ACCOUNT_NOT_FOUND':\n return new AccountNotFoundError(QUOTED_ACCOUNT.exec(text)?.[1] ?? '', text);\n case 'NOT_FOUND': {\n const kind = NOT_FOUND_KINDS.find(k => k === match[2]) ?? 'email';\n return new NotFoundError(kind, text);\n }\n default:\n return new InvalidRequestError(text);\n }\n}\n\n/**\n * Turn a failed run into the most specific error that can be proven.\n *\n * Order matters. An abort and a timeout both kill the child, so the signal's\n * own state is checked before the kill; an overflow kills it too, and is told\n * apart by its error code. Only then is the script's message worth reading — a\n * process killed mid-write may have printed a partial, misleading one.\n */\nexport function classifyRunFailure(init: {\n runner: ScriptRunner;\n script: string;\n /** Everything the run wrote to stderr. */\n stderr: string;\n /** The script's own failure message, when the runner could isolate one. */\n message?: string;\n /** The script line the failure was raised on, when known. */\n line?: number;\n durationMs: number;\n /** The error `execFile` handed back. */\n nodeError?: (Error & { killed?: boolean; code?: string | number | null }) | null;\n /** The time budget in force, for the TIMEOUT message. */\n timeoutMs?: number;\n /** The stdout cap in force, for the OUTPUT_TOO_LARGE message. */\n maxBufferBytes?: number;\n signal?: AbortSignal;\n}): OutlookError {\n const { runner, script, stderr, durationMs, nodeError, timeoutMs, signal } = init;\n\n if (signal?.aborted || nodeError?.name === 'AbortError' || nodeError?.code === 'ABORT_ERR') {\n return new AbortedError(runner, signal?.reason);\n }\n if (nodeError?.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') {\n return new OutputTooLargeError({ runner, maxBufferBytes: init.maxBufferBytes ?? 0, script });\n }\n if (nodeError?.killed && timeoutMs) {\n return new TimeoutError({ runner, timeoutMs, script });\n }\n const message = (init.message ?? '').trim() || stderr.trim() || nodeError?.message || '';\n const typed = errorFromTaggedMessage(message);\n if (typed) return typed;\n return new ScriptError({\n runner,\n script,\n stderr,\n durationMs,\n message,\n line: init.line,\n cause: nodeError ?? undefined,\n });\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const getOutlookAccounts: () => Promise<string[]>, sendOutlookEmail: (params: import("./types").SendEmailParams) => Promise<void>, 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>;
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
2
  export { createOutlookBridge, capabilities, supports } from './bridge';
3
3
  export type { OutlookBridgeInstance } from './bridge';
4
4
  export { configure } from './runtime';
@@ -8,4 +8,4 @@ export type { OutlookErrorCode, NotFoundKind, ScriptRunner } from './errors';
8
8
  export { hasReplyPrefix, mailFolderRef, splitQuotedOriginal, threadSubject, WELL_KNOWN_FOLDERS } from './mail';
9
9
  export { composeTemplateBody, findTemplateMarkers, findTokens, findUnfilledTokens, removeTokenLine, replaceToken, } from './templateBody';
10
10
  export type { ComposeOptions, TemplateMarkers } from './templateBody';
11
- export type { OutlookBridge, BridgeCapability, CapabilityMap, EmailLocator, EmailRef, Recipients, SendEmailParams, 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';
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.map CHANGED
@@ -1 +1 @@
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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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 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"]}
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,yBAAi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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"]}
@@ -1 +1 @@
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,EAAC,YAAY,EAAC,IAAI,OAAO,EAAE,CAAC;QACnC,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
+ {"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"]}
@@ -33,7 +33,7 @@ end tell`, 'quick'));
33
33
  senderEmail: (0, run_1.field)(parts, scripts_1.MessageDetail.senderEmail),
34
34
  receivedTime: (0, run_1.field)(parts, scripts_1.MessageDetail.receivedTime),
35
35
  };
36
- const attachmentNames = (0, run_1.splitList)((0, run_1.field)(parts, scripts_1.MessageDetail.attachmentNames));
36
+ const attachmentNames = (0, run_1.splitPositionalList)((0, run_1.field)(parts, scripts_1.MessageDetail.attachmentNames));
37
37
  const picks = request.fileNames.map(fileName => {
38
38
  const index = (0, attachmentMatch_1.findAttachmentIndex)(attachmentNames, fileName);
39
39
  if (index === -1) {
@@ -1 +1 @@
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,+BAA8F;AAC9F,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;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,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,EAAC,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC;IACjC,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,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,KAAK,EAAC,CAAC,CAAC,CAAC;AACrF,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, splitList, 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 = splitList(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"]}
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,uCAM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,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"]}