@dawnlit/outlook-bridge 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +150 -183
  2. package/dist/backend.d.ts +151 -0
  3. package/dist/backend.js +3 -0
  4. package/dist/backend.js.map +1 -0
  5. package/dist/bridge.d.ts +56 -0
  6. package/dist/bridge.js +507 -0
  7. package/dist/bridge.js.map +1 -0
  8. package/dist/errors.d.ts +81 -43
  9. package/dist/errors.js +98 -52
  10. package/dist/errors.js.map +1 -1
  11. package/dist/index.d.ts +10 -10
  12. package/dist/index.js +25 -52
  13. package/dist/index.js.map +1 -1
  14. package/dist/mac/accounts.d.ts +7 -2
  15. package/dist/mac/accounts.js +23 -6
  16. package/dist/mac/accounts.js.map +1 -1
  17. package/dist/mac/attachments.d.ts +5 -25
  18. package/dist/mac/attachments.js +40 -99
  19. package/dist/mac/attachments.js.map +1 -1
  20. package/dist/mac/bounces.d.ts +12 -27
  21. package/dist/mac/bounces.js +95 -112
  22. package/dist/mac/bounces.js.map +1 -1
  23. package/dist/mac/cleanup.d.ts +11 -25
  24. package/dist/mac/cleanup.js +50 -76
  25. package/dist/mac/cleanup.js.map +1 -1
  26. package/dist/mac/drafts.d.ts +13 -34
  27. package/dist/mac/drafts.js +95 -169
  28. package/dist/mac/drafts.js.map +1 -1
  29. package/dist/mac/folders.d.ts +10 -21
  30. package/dist/mac/folders.js +33 -47
  31. package/dist/mac/folders.js.map +1 -1
  32. package/dist/mac/index.d.ts +2 -22
  33. package/dist/mac/index.js +19 -81
  34. package/dist/mac/index.js.map +1 -1
  35. package/dist/mac/profile.d.ts +13 -0
  36. package/dist/mac/profile.js +149 -0
  37. package/dist/mac/profile.js.map +1 -0
  38. package/dist/mac/read.d.ts +18 -36
  39. package/dist/mac/read.js +154 -208
  40. package/dist/mac/read.js.map +1 -1
  41. package/dist/mac/run.d.ts +35 -39
  42. package/dist/mac/run.js +97 -102
  43. package/dist/mac/run.js.map +1 -1
  44. package/dist/mac/scripts.d.ts +78 -86
  45. package/dist/mac/scripts.js +125 -115
  46. package/dist/mac/scripts.js.map +1 -1
  47. package/dist/mac/send.d.ts +10 -20
  48. package/dist/mac/send.js +64 -86
  49. package/dist/mac/send.js.map +1 -1
  50. package/dist/mac/signatures.d.ts +2 -2
  51. package/dist/mac/signatures.js +9 -11
  52. package/dist/mac/signatures.js.map +1 -1
  53. package/dist/mac/templates.d.ts +14 -26
  54. package/dist/mac/templates.js +75 -113
  55. package/dist/mac/templates.js.map +1 -1
  56. package/dist/mail.d.ts +77 -45
  57. package/dist/mail.js +166 -73
  58. package/dist/mail.js.map +1 -1
  59. package/dist/runtime.d.ts +76 -43
  60. package/dist/runtime.js +103 -48
  61. package/dist/runtime.js.map +1 -1
  62. package/dist/shared/args.d.ts +48 -0
  63. package/dist/shared/args.js +216 -0
  64. package/dist/shared/args.js.map +1 -0
  65. package/dist/shared/attachmentMatch.d.ts +28 -16
  66. package/dist/shared/attachmentMatch.js +60 -22
  67. package/dist/shared/attachmentMatch.js.map +1 -1
  68. package/dist/shared/bounceReport.d.ts +11 -0
  69. package/dist/shared/bounceReport.js +45 -0
  70. package/dist/shared/bounceReport.js.map +1 -0
  71. package/dist/shared/bounceRules.d.ts +38 -10
  72. package/dist/shared/bounceRules.js +50 -32
  73. package/dist/shared/bounceRules.js.map +1 -1
  74. package/dist/shared/exec.d.ts +21 -0
  75. package/dist/shared/exec.js +47 -0
  76. package/dist/shared/exec.js.map +1 -0
  77. package/dist/shared/json.d.ts +12 -6
  78. package/dist/shared/json.js +29 -23
  79. package/dist/shared/json.js.map +1 -1
  80. package/dist/shared/locate.d.ts +39 -0
  81. package/dist/shared/locate.js +129 -0
  82. package/dist/shared/locate.js.map +1 -0
  83. package/dist/shared/replyBody.d.ts +42 -32
  84. package/dist/shared/replyBody.js +84 -71
  85. package/dist/shared/replyBody.js.map +1 -1
  86. package/dist/templateBody.d.ts +63 -0
  87. package/dist/{outlookTemplateSections.js → templateBody.js} +72 -72
  88. package/dist/templateBody.js.map +1 -0
  89. package/dist/types.d.ts +360 -165
  90. package/dist/types.js +8 -9
  91. package/dist/types.js.map +1 -1
  92. package/dist/windows/accounts.d.ts +10 -1
  93. package/dist/windows/accounts.js +25 -13
  94. package/dist/windows/accounts.js.map +1 -1
  95. package/dist/windows/attachments.d.ts +9 -24
  96. package/dist/windows/attachments.js +94 -119
  97. package/dist/windows/attachments.js.map +1 -1
  98. package/dist/windows/bounces.d.ts +13 -26
  99. package/dist/windows/bounces.js +169 -200
  100. package/dist/windows/bounces.js.map +1 -1
  101. package/dist/windows/cleanup.d.ts +19 -23
  102. package/dist/windows/cleanup.js +93 -111
  103. package/dist/windows/cleanup.js.map +1 -1
  104. package/dist/windows/drafts.d.ts +16 -35
  105. package/dist/windows/drafts.js +167 -253
  106. package/dist/windows/drafts.js.map +1 -1
  107. package/dist/windows/folders.d.ts +8 -13
  108. package/dist/windows/folders.js +45 -52
  109. package/dist/windows/folders.js.map +1 -1
  110. package/dist/windows/index.d.ts +2 -27
  111. package/dist/windows/index.js +11 -65
  112. package/dist/windows/index.js.map +1 -1
  113. package/dist/windows/read.d.ts +24 -45
  114. package/dist/windows/read.js +266 -279
  115. package/dist/windows/read.js.map +1 -1
  116. package/dist/windows/run.d.ts +39 -39
  117. package/dist/windows/run.js +151 -111
  118. package/dist/windows/run.js.map +1 -1
  119. package/dist/windows/scripts.d.ts +71 -38
  120. package/dist/windows/scripts.js +123 -71
  121. package/dist/windows/scripts.js.map +1 -1
  122. package/dist/windows/send.d.ts +6 -11
  123. package/dist/windows/send.js +70 -79
  124. package/dist/windows/send.js.map +1 -1
  125. package/dist/windows/signatures.d.ts +4 -10
  126. package/dist/windows/signatures.js +30 -37
  127. package/dist/windows/signatures.js.map +1 -1
  128. package/dist/windows/templates.d.ts +12 -18
  129. package/dist/windows/templates.js +126 -151
  130. package/dist/windows/templates.js.map +1 -1
  131. package/package.json +5 -4
  132. package/dist/OutlookService.d.ts +0 -43
  133. package/dist/OutlookService.js +0 -137
  134. package/dist/OutlookService.js.map +0 -1
  135. package/dist/outlookTemplateSections.d.ts +0 -62
  136. package/dist/outlookTemplateSections.js.map +0 -1
  137. package/dist/shared/capabilities.d.ts +0 -3
  138. package/dist/shared/capabilities.js +0 -9
  139. package/dist/shared/capabilities.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../src/mac/scripts.ts"],"names":[],"mappings":";;;AAiBA,oDAWC;AAqBD,oCAEC;AAOD,sCAEC;AAGD,4BAUC;AAcD,4CAyBC;AASD,oCAUC;AASD,kDAcC;AAQD,oDAMC;AAQD,sCAYC;AAgBD,oDAsBC;AAMD,kDAWC;AAkBD,sDAeC;AAQD,oDAcC;AA1SD,yEAAyE;AACzE,+BAAyC;AACzC,sCAAqE;AAErE,kCAAyC;AAEzC;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAAC,YAAoB;IACrD,OAAO;;;oDAGyC,IAAA,cAAQ,EAAC,YAAY,CAAC;;;;;;0DAMhB,IAAA,cAAQ,EAAC,YAAY,CAAC,cAAc,CAAC;AAC/F,CAAC;AAED;;;;;;;;GAQG;AACU,QAAA,cAAc,GAA2B;IAClD,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,YAAY;IACf,EAAE,EAAE,QAAQ;IACZ,CAAC,EAAE,eAAe;IAClB,CAAC,EAAE,QAAQ;IACX,EAAE,EAAE,WAAW;CAClB,CAAC;AAEF,yDAAyD;AACzD,SAAgB,YAAY,CAAC,MAAc;IACvC,OAAO,IAAA,qBAAc,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC;AAClE,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,YAAoB,EAAE,SAAiB,EAAE,QAAkB;IACrF,OAAO,CAAC,MAAM,GAAG,YAAY,EAAE,SAAS,EAAE,GAAG,QAAQ,CAA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,CAAC;AAClB,CAAC;AAED;;;GAGG;AACU,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;CAelC,CAAC;AAEF;;;GAGG;AACU,QAAA,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;CAoBpC,CAAC","sourcesContent":["// The AppleScript fragments more than one macOS operation is built from.\nimport { asString } from './run';\nimport { readProfileAccounts } from './profile';\nimport { failureTag, InvalidRequestError, NotImplementedError } from '../errors';\nimport { FolderId, isOutgoingRoot } from '../mail';\nimport type { ItemFailure, MailFolderRef } from '../types';\n\n/**\n * An account as the generated AppleScript reaches it.\n *\n * `folderIds` carries what Outlook's profile database knows about the mailbox's\n * well-known folders — the only handle on a mailbox the dictionary publishes no\n * account object for (see profile.ts). It is filled in for every account the\n * profile lists, because the generated script chooses between the account\n * object and the folder id at run time; nothing here has to predict which kinds\n * of account a given Outlook build exposes.\n */\nexport interface MacAccount {\n readonly emailAccount: string;\n readonly folderIds?: Readonly<Record<string, number>>;\n}\n\n/** Look an address up in Outlook's profile database, for the folder ids it can add. */\nexport async function resolveMacAccount(emailAccount: string): Promise<MacAccount> {\n const wanted = emailAccount.trim().toLowerCase();\n const found = (await readProfileAccounts())\n .find(account => account.emailAccount.trim().toLowerCase() === wanted);\n return found ? {emailAccount, folderIds: found.folderIds} : {emailAccount};\n}\n\n/**\n * Resolve the account whose address matches into `targetAcct`, inside a\n * `tell application \"Microsoft Outlook\"` block.\n *\n * `every account` errors even in legacy mode, so the typed classes are probed.\n * A `whose email address is …` filter can't be used either: `email address` is\n * also a class name, and AppleScript resolves it as one.\n *\n * A mailbox the dictionary publishes no account object for leaves `targetAcct`\n * as `missing value` rather than failing, provided the profile gave a folder id\n * to reach it by. `needsAccountObject` is for composing mail, which can't work\n * without the object: the account a message is sent from can only be set from\n * it, and a message composed without it goes out from the default mailbox.\n */\nexport function accountLookupSnippet(acct: MacAccount, needsAccountObject = false): string {\n const probe = ` set targetAcct to missing value\n try\n repeat with a in (exchange accounts & imap accounts & pop accounts)\n if (email address of a as string) is ${asString(acct.emailAccount)} then\n set targetAcct to a\n exit repeat\n end if\n end repeat\n end try`;\n if (acct.folderIds && !needsAccountObject) return probe;\n const complaint = acct.folderIds\n ? `${failureTag('INVALID_REQUEST')}Outlook publishes no account object for '${acct.emailAccount}', `\n + 'so the account a message is sent from cannot be set. Its folders can be read; mail cannot be composed from it.'\n : `${failureTag('ACCOUNT_NOT_FOUND')}Account '${acct.emailAccount}' not found in Outlook.`;\n return `${probe}\n if targetAcct is missing value then error ${asString(complaint)}`;\n}\n\n/**\n * Bind `variable` to one of the account's well-known folders: through the\n * account object when the probe found one, else by the folder's own id. `mail\n * folder id N` resolves against the application rather than an account, and N is\n * the id Outlook's profile database records for that folder.\n */\nexport function rootFolderSnippet(acct: MacAccount, term: string, variable: string): string {\n const viaAccount = ` set ${variable} to ${term} of targetAcct`;\n const id = acct.folderIds?.[term];\n if (id !== undefined) {\n return ` if targetAcct is missing value then\n set ${variable} to mail folder id ${id}\n else\n${viaAccount}\n end if`;\n }\n // The profile listed the mailbox but not this root, so the probe is the only\n // way in — and it may have come up empty. Name the folder out of reach\n // rather than let `<term> of missing value` say it.\n if (acct.folderIds) {\n const complaint = `${failureTag('NOT_FOUND', 'folder')}Account '${acct.emailAccount}' has no ${term} folder AppleScript can reach.`;\n return ` if targetAcct is missing value then error ${asString(complaint)}\n${viaAccount}`;\n }\n return viaAccount;\n}\n\n/**\n * Outlook for Mac's dictionary term for each well-known root, by olDefaultFolders\n * id. Verified against the running app: the terms are NOT what the Windows names\n * suggest — `sent mail` and `junk email` don't compile, `sent items` and `junk\n * mail` do — and one bad term fails the whole script at compile time.\n */\nexport const MAC_ROOT_TERMS: Readonly<Record<number, string>> = {\n [FolderId.Inbox]: 'inbox',\n [FolderId.SentMail]: 'sent items',\n [FolderId.Drafts]: 'drafts',\n [FolderId.DeletedItems]: 'deleted items',\n [FolderId.Outbox]: 'outbox',\n [FolderId.Junk]: 'junk mail',\n};\n\n/** The date property a root's items carry. */\nexport function dateProperty(rootId: number): string {\n return isOutgoingRoot(rootId) ? 'time sent' : 'time received';\n}\n\n/**\n * The Windows folder-path shape (`\\\\mailbox\\Inbox\\Invoices`), assembled in\n * TypeScript: escaping backslashes through a template literal and then an\n * AppleScript literal is unreadable, and the parts are known here anyway.\n */\nexport function macFolderPath(emailAccount: string, rootLabel: string, segments: readonly string[]): string {\n return ['\\\\\\\\' + emailAccount, rootLabel, ...segments].join('\\\\');\n}\n\n/** The dictionary term for a root, or NOT_IMPLEMENTED naming what was asked. */\nexport function rootTerm(ref: MailFolderRef, folderLabel = ''): string {\n const term = MAC_ROOT_TERMS[ref.rootId];\n if (!term) {\n const asked = folderLabel ? ` (asked for '${folderLabel}')` : '';\n throw new NotImplementedError(\n `Reading the '${ref.rootLabel}' folder${asked}`,\n `macOS, whose readable roots are ${Object.values(MAC_ROOT_TERMS).join(', ')}`,\n );\n }\n return term;\n}\n\n/**\n * Resolve `scopeFolder` from `targetAcct`: a well-known root walked down through\n * any further segments. Also binds `scopeCreated`.\n *\n * Names compare with `is`, which is case-insensitive in AppleScript, matching\n * the Windows walk. A missing segment fails as NOT_FOUND rather than falling\n * back to the root; `createMissing` builds the chain instead.\n */\nexport function mailScopeSnippet(acct: MacAccount, ref: MailFolderRef, folderLabel = '', createMissing = false): string {\n const term = rootTerm(ref, folderLabel);\n const walk = ref.segments.map(segment => {\n const complaint = `${failureTag('NOT_FOUND', 'folder')}Folder '${segment}' not found under '${ref.rootLabel}'.`;\n const create = createMissing\n ? ` set foundFolder to (make new mail folder at scopeFolder with properties {name:${asString(segment)}})\n set scopeCreated to true`\n : ` error ${asString(complaint)}`;\n return `\n set foundFolder to missing value\n repeat with sf in (mail folders of scopeFolder)\n if (name of sf as string) is ${asString(segment)} then\n set foundFolder to sf\n exit repeat\n end if\n end repeat\n if foundFolder is missing value then\n${create}\n end if\n set scopeFolder to foundFolder`;\n }).join('');\n return ` set scopeCreated to false\n${rootFolderSnippet(acct, term, 'scopeFolder')}${walk}`;\n}\n\n/**\n * The message id text for a script, or INVALID_REQUEST.\n *\n * Outlook for Mac ids are small integers; a Windows EntryID is refused up front\n * rather than left to fail as a confusing \"not found\", because a caller that\n * persisted one from a Windows run needs to be told exactly that.\n */\nexport function macMessageId(entryId: string): string {\n const id = String(entryId ?? '').trim();\n if (!/^\\d+$/.test(id)) {\n throw new InvalidRequestError(\n `'${entryId}' is not an Outlook for Mac message id. Mac ids are small integers `\n + '(e.g. \"1263\") listed on this machine; a Windows EntryID cannot be resolved here.',\n );\n }\n return id;\n}\n\n/**\n * Split ids into those a script can look up and those that can only fail. A\n * batch reports an unusable id beside a genuine miss rather than throwing and\n * discarding the ids that would have worked.\n */\nexport function partitionMessageIds(entryIds: readonly string[]): { valid: string[]; invalid: ItemFailure[] } {\n const valid: string[] = [];\n const invalid: ItemFailure[] = [];\n for (const entryId of entryIds) {\n try {\n valid.push(macMessageId(entryId));\n } catch (error) {\n invalid.push({entryId: String(entryId), subject: '', error: (error as Error).message});\n }\n }\n return {valid, invalid};\n}\n\n/**\n * Resolve `variable` from a message id, or fail as NOT_FOUND. `message id N`\n * resolves against the application, so the message is found wherever it sits.\n */\nexport function messageLookupSnippet(id: string, variable = 'theMsg'): string {\n const complaint = `${failureTag('NOT_FOUND', 'email')}No email found for message id '${id}'. It may have been deleted - list the mail again for a current id.`;\n return ` set ${variable} to missing value\n try\n set ${variable} to message id ${id}\n end try\n if ${variable} is missing value then error ${asString(complaint)}`;\n}\n\n/**\n * The sender's display name and address as `sndName` / `sndAddr`. `sender` is a\n * record, and `address of sender of m` doesn't coerce, so the record is bound\n * first.\n */\nexport function senderSnippet(messageVariable = 'theMsg', indent = ' '): string {\n return `${indent}set sndName to \"\"\n${indent}set sndAddr to \"\"\n${indent}try\n${indent} set snd to sender of ${messageVariable}\n${indent} try\n${indent} set sndAddr to (address of snd) as string\n${indent} end try\n${indent} try\n${indent} set sndName to (name of snd) as string\n${indent} end try\n${indent}end try`;\n}\n\n/**\n * Everything a reader wants off one message bound to `theMsg`, emitted together\n * with the row it produces (see `messageDetailFields`) so the read order and the\n * positions the decoders index into cannot drift apart. `bodyText` is emitted\n * LAST when asked for, so a stray separator in an earlier field can't shift it.\n */\nexport function messageDetailSnippet(withBody = false, indent = ' '): string {\n return `${indent}set subj to \"\"\n${indent}try\n${indent} set subj to (subject of theMsg) as string\n${indent}end try\n${senderSnippet('theMsg', indent)}\n${indent}set recvd to \"\"\n${indent}try\n${indent} set recvd to my isoDate(time received of theMsg)\n${indent}on error\n${indent} try\n${indent} set recvd to my isoDate(time sent of theMsg)\n${indent} end try\n${indent}end try\n${indent}set attNames to {}\n${indent}try\n${indent} set attNames to name of every attachment of theMsg\n${indent}end try` + (withBody ? `\n${indent}set bodyText to \"\"\n${indent}try\n${indent} set bodyText to (plain text content of theMsg) as string\n${indent}end try` : '');\n}\n\n/** The fields `messageDetailSnippet` fills, in row order — see `MessageDetail`. */\nexport function messageDetailFields(withBody = false): string[] {\n const fields = ['(id of theMsg as string)', 'subj', 'sndName', 'sndAddr', 'recvd', 'my sanitizeList(attNames)'];\n if (withBody) fields.push('bodyText');\n return fields;\n}\n\n/** Where each of those fields lands in the row. */\nexport const MessageDetail = {\n id: 0,\n subject: 1,\n senderName: 2,\n senderEmail: 3,\n receivedTime: 4,\n attachmentNames: 5,\n body: 6,\n} as const;\n\n/**\n * The first recipient's name and address as `sndName` / `sndAddr` — what\n * outgoing mail reports in place of a sender.\n */\nexport function firstRecipientSnippet(messageVariable = 'theMsg', indent = ' '): string {\n return `${indent}set sndName to \"\"\n${indent}set sndAddr to \"\"\n${indent}try\n${indent} set rcps to to recipients of ${messageVariable}\n${indent} if (count of rcps) > 0 then\n${indent} set ea to email address of (item 1 of rcps)\n${indent} try\n${indent} set sndAddr to (address of ea) as string\n${indent} end try\n${indent} try\n${indent} set sndName to (name of ea) as string\n${indent} end try\n${indent} end if\n${indent}end try`;\n}\n\n/** Every address a message was sent to — To, CC and BCC — as the list `addrList`. */\nexport function allRecipientsSnippet(messageVariable = 'theMsg', indent = ' '): string {\n return `${indent}set addrList to {}\n${indent}try\n${indent} repeat with r in (every recipient of ${messageVariable})\n${indent} try\n${indent} -- The record is bound before its field is read: a nested\n${indent} -- 'address of (email address of r)' doesn't coerce, and fails\n${indent} -- inside the try as an empty list rather than an error.\n${indent} set ea to email address of r\n${indent} set oneAddr to (address of ea) as string\n${indent} if oneAddr is not \"\" then set end of addrList to oneAddr\n${indent} end try\n${indent} end repeat\n${indent}end try`;\n}\n\n/**\n * Recursive, case-insensitive, depth-capped folder search from `startFolder` —\n * the macOS counterpart of the Windows Find-FolderByName.\n */\nexport const FIND_FOLDER_HANDLER = `\non findFolderByName(startFolder, wantedName, depth)\n tell application \"Microsoft Outlook\"\n set subs to mail folders of startFolder\n end tell\n repeat with f in subs\n if (name of f as string) is wantedName then return f\n end repeat\n if depth is less than or equal to 1 then return missing value\n repeat with f in subs\n set hit to my findFolderByName(f, wantedName, depth - 1)\n if hit is not missing value then return hit\n end repeat\n return missing value\nend findFolderByName\n`;\n\n/**\n * Enumerate the accounts, probing each class separately: legacy Outlook errors\n * on `every account`, and New Outlook returns empty lists for the classes.\n */\nexport const LIST_ACCOUNTS_SNIPPET = `\nset acctList to {}\ntell application \"Microsoft Outlook\"\n repeat with acctClass in {\"exchange\", \"imap\", \"pop\"}\n try\n if (acctClass as string) is \"exchange\" then\n set accts to exchange accounts\n else if (acctClass as string) is \"imap\" then\n set accts to imap accounts\n else\n set accts to pop accounts\n end if\n repeat with a in accts\n try\n set end of acctList to (email address of a as string)\n end try\n end repeat\n end try\n end repeat\nend tell\n`;\n"]}
@@ -1,23 +1,13 @@
1
- import type { ReplyEmailParams, ReplyEmailResult, SendEmailParams } from '../types';
1
+ import type { ReplyRequest, SendRequest } from '../backend';
2
+ import type { ReplyEmailResult } from '../types';
3
+ /** Send, display or file a new email. */
4
+ export declare function sendOutlookEmail(request: SendRequest): Promise<void>;
2
5
  /**
3
- * Create an Outlook email as a draft window (or send it) via AppleScript.
4
- * Mirrors the Windows COM contract from windows/send.ts.
5
- */
6
- export declare function sendOutlookEmail(params: SendEmailParams): Promise<void>;
7
- /**
8
- * Reply to an email, inserting the caller's HTML above the quoted original.
9
- *
10
- * `entryId` is Outlook for Mac's small integer message id (see readInboxEmails),
11
- * not a Windows MAPI EntryID; `storeId` is accepted for signature parity and
12
- * ignored, since macOS has no StoreID and `message id N` resolves against the
13
- * application rather than one folder.
14
- *
15
- * `reply to` builds the quoted body Outlook itself would have — the same thing
16
- * COM's Reply() returns — so the insertion point is the one place the two
17
- * platforms have to agree, and both look for WordSection1 then `<body>`.
6
+ * Reply to an email with the composed HTML above the quoted original.
18
7
  *
19
- * The `to` line is the reply's resolved recipient addresses rather than the
20
- * display-name string Windows reports: Outlook for Mac exposes recipients as
21
- * records, and an address is the more useful half to verify against.
8
+ * `reply to` builds the same quoted body COM's Reply() returns, so the insertion
9
+ * point is the one thing the platforms must agree on (see WORD_SECTION_ANCHOR).
10
+ * `to` comes back as the reply's resolved addresses: Outlook for Mac exposes
11
+ * recipients as records, and the address is the half worth checking.
22
12
  */
23
- export declare function replyOutlookEmail(params: ReplyEmailParams): Promise<ReplyEmailResult>;
13
+ export declare function replyOutlookEmail(request: ReplyRequest): Promise<ReplyEmailResult>;
package/dist/mac/send.js CHANGED
@@ -5,90 +5,74 @@ exports.replyOutlookEmail = replyOutlookEmail;
5
5
  // Composing outgoing mail on macOS: a new email, and a reply to an existing one.
6
6
  const run_1 = require("./run");
7
7
  const scripts_1 = require("./scripts");
8
- const replyBody_1 = require("../shared/replyBody");
9
- const signatures_1 = require("./signatures");
10
- const templates_1 = require("./templates");
11
- /** Split a To/CC string the way the Windows contract accepts it. */
12
- function splitAddresses(s) {
13
- return s.split(/[,;]+/).map(x => x.trim()).filter(Boolean);
14
- }
8
+ const args_1 = require("../shared/args");
15
9
  /**
16
- * What to do with a composed item.
10
+ * What to do with a composed message.
17
11
  *
18
- * A new outgoing message lands in Temporary Items, not Drafts — `open` is what
19
- * surfaces it, so a windowless draft has to be moved into the Drafts folder
20
- * explicitly. (`save` is no help: it demands a file destination, not a folder.)
21
- * `move` reports success even where it silently does nothing, so the folder is
22
- * confirmed to have grown rather than risk reporting a draft that doesn't exist.
12
+ * A new outgoing message lands in Temporary Items, not Drafts — `open` only
13
+ * shows it — so a windowless draft is moved into Drafts explicitly. `move`
14
+ * reports success even where it silently does nothing, so the folder is
15
+ * confirmed to have grown rather than report a draft that doesn't exist.
23
16
  */
24
- function composeAction(variable, sendImmediately, openDraftWindow) {
25
- if (sendImmediately)
26
- return { prelude: '', action: ` send ${variable}` };
27
- if (openDraftWindow !== false)
28
- return { prelude: '', action: ` open ${variable}` };
29
- return {
30
- prelude: ` set draftsFolder to drafts of targetAcct
17
+ function dispose(variable, disposition) {
18
+ switch (disposition) {
19
+ case 'send':
20
+ return { prelude: '', action: ` send ${variable}` };
21
+ case 'display':
22
+ return { prelude: '', action: ` open ${variable}` };
23
+ case 'save':
24
+ return {
25
+ prelude: ` set draftsFolder to drafts of targetAcct
31
26
  set draftsBefore to count of messages of draftsFolder`,
32
- action: ` move ${variable} to draftsFolder
27
+ action: ` move ${variable} to draftsFolder
33
28
  if (count of messages of draftsFolder) is not greater than draftsBefore then error "Outlook did not file the draft in the Drafts folder."`,
34
- };
29
+ };
30
+ }
35
31
  }
36
- /**
37
- * Create an Outlook email as a draft window (or send it) via AppleScript.
38
- * Mirrors the Windows COM contract from windows/send.ts.
39
- */
40
- async function sendOutlookEmail(params) {
41
- // Same safety property as Windows: never silently send from the wrong mailbox.
42
- // The account lookup raises when the address doesn't resolve, so there's no
43
- // pre-flight getOutlookAccounts() round-trip — it cost an extra osascript
44
- // launch on every email in a batch.
45
- const recipientLines = [
46
- ...splitAddresses(params.to).map(addr => ` make new to recipient at newMsg with properties {email address:{address:"${(0, run_1.asEscape)(addr)}"}}`),
47
- ...splitAddresses(params.cc || '').map(addr => ` make new cc recipient at newMsg with properties {email address:{address:"${(0, run_1.asEscape)(addr)}"}}`),
48
- ].join('\n');
49
- const attachLine = params.attachmentPath
50
- ? ` make new attachment at newMsg with properties {file:POSIX file "${(0, run_1.asEscape)(params.attachmentPath)}"}`
51
- : '';
52
- const { prelude, action } = composeAction('newMsg', params.sendImmediately, params.openDraftWindow);
53
- const script = `
32
+ /** One `make new … recipient` line per entry, keeping a display name when given. */
33
+ function recipientLines(kind, entries) {
34
+ return entries.map(entry => {
35
+ const { name, address } = (0, args_1.parseRecipient)(entry);
36
+ const emailAddress = name
37
+ ? `{name:${(0, run_1.asString)(name)}, address:${(0, run_1.asString)(address)}}`
38
+ : `{address:${(0, run_1.asString)(address)}}`;
39
+ return ` make new ${kind} recipient at newMsg with properties {email address:${emailAddress}}`;
40
+ });
41
+ }
42
+ /** Send, display or file a new email. */
43
+ async function sendOutlookEmail(request) {
44
+ const acct = await (0, scripts_1.resolveMacAccount)(request.account);
45
+ const { prelude, action } = dispose('newMsg', request.disposition);
46
+ const lines = [
47
+ ...recipientLines('to', request.to),
48
+ ...recipientLines('cc', request.cc),
49
+ ...recipientLines('bcc', request.bcc),
50
+ ...request.attachments.map(file => ` make new attachment at newMsg with properties {file:POSIX file ${(0, run_1.asString)(file)}}`),
51
+ ];
52
+ await (0, run_1.runOsaScript)(`
54
53
  tell application "Microsoft Outlook"
55
- ${(0, scripts_1.accountLookupSnippet)(params.emailAccount)}
54
+ ${(0, scripts_1.accountLookupSnippet)(acct, true)}
56
55
  ${prelude}
57
- set newMsg to make new outgoing message with properties {subject:"${(0, run_1.asEscape)(params.subject)}", content:"${(0, run_1.asEscape)(params.htmlBody)}"}
58
- ${recipientLines}
56
+ set newMsg to make new outgoing message with properties {subject:${(0, run_1.asString)(request.subject)}, content:${(0, run_1.asString)(request.htmlBody)}}
57
+ ${lines.join('\n')}
59
58
  set account of newMsg to targetAcct
60
- ${attachLine}
61
59
  ${action}
62
- end tell`;
63
- await (0, run_1.runOsaScript)(script, 120000);
60
+ end tell`, 'standard');
64
61
  }
65
62
  /**
66
- * Reply to an email, inserting the caller's HTML above the quoted original.
67
- *
68
- * `entryId` is Outlook for Mac's small integer message id (see readInboxEmails),
69
- * not a Windows MAPI EntryID; `storeId` is accepted for signature parity and
70
- * ignored, since macOS has no StoreID and `message id N` resolves against the
71
- * application rather than one folder.
63
+ * Reply to an email with the composed HTML above the quoted original.
72
64
  *
73
- * `reply to` builds the quoted body Outlook itself would have — the same thing
74
- * COM's Reply() returns — so the insertion point is the one place the two
75
- * platforms have to agree, and both look for WordSection1 then `<body>`.
76
- *
77
- * The `to` line is the reply's resolved recipient addresses rather than the
78
- * display-name string Windows reports: Outlook for Mac exposes recipients as
79
- * records, and an address is the more useful half to verify against.
65
+ * `reply to` builds the same quoted body COM's Reply() returns, so the insertion
66
+ * point is the one thing the platforms must agree on (see WORD_SECTION_ANCHOR).
67
+ * `to` comes back as the reply's resolved addresses: Outlook for Mac exposes
68
+ * recipients as records, and the address is the half worth checking.
80
69
  */
81
- async function replyOutlookEmail(params) {
82
- const id = (0, scripts_1.macMessageId)(params.entryId);
83
- const insertHtml = await (0, replyBody_1.composeReplyHtml)(params, {
84
- readTemplateEmails: templates_1.readTemplateEmails,
85
- readOutlookSignatureHtml: signatures_1.readOutlookSignatureHtml,
86
- listOutlookSignatures: signatures_1.listOutlookSignatures,
87
- });
88
- const { prelude, action } = composeAction('theReply', params.sendImmediately, params.openDraftWindow);
89
- const replyAll = params.replyAll ? 'reply to all true' : 'without reply to all';
90
- const script = `tell application "Microsoft Outlook"
91
- ${(0, scripts_1.accountLookupSnippet)(params.emailAccount)}
70
+ async function replyOutlookEmail(request) {
71
+ const id = (0, scripts_1.macMessageId)(request.email.entryId);
72
+ const acct = await (0, scripts_1.resolveMacAccount)(request.account);
73
+ const { prelude, action } = dispose('theReply', request.disposition);
74
+ const raw = await (0, run_1.runOsaScript)(`tell application "Microsoft Outlook"
75
+ ${(0, scripts_1.accountLookupSnippet)(acct, true)}
92
76
  ${(0, scripts_1.messageLookupSnippet)(id)}
93
77
  set repliedTo to ""
94
78
  try
@@ -98,16 +82,14 @@ ${(0, scripts_1.messageLookupSnippet)(id)}
98
82
  set repliedTo to (address of origSender) as string
99
83
  end try
100
84
  ${prelude}
101
- set theReply to reply to theMsg opening window false ${replyAll}
102
- -- Neither of these is wrapped in a try, and both would read more defensively
103
- -- if they were. A swallowed account assignment sends from whichever mailbox
104
- -- Outlook considers default, and a swallowed insertion files a reply with the
105
- -- caller's text missing — the two failures this package exists to prevent,
106
- -- both of them invisible to the caller if tolerated here.
85
+ set theReply to reply to theMsg opening window false ${request.replyAll ? 'reply to all true' : 'without reply to all'}
86
+ -- Neither of these is wrapped in a try. A swallowed account assignment sends
87
+ -- from the default mailbox, and a swallowed insertion files a reply missing
88
+ -- its text — both invisible to the caller if tolerated here.
107
89
  set account of theReply to targetAcct
108
- set content of theReply to my insertAboveQuoted(content of theReply, "${(0, run_1.asEscape)(insertHtml)}")
109
- -- Read the outgoing fields BEFORE acting: sending moves the item, after which
110
- -- the reference is no longer readable.
90
+ set content of theReply to my insertAboveQuoted(content of theReply, ${(0, run_1.asString)(request.html)})
91
+ -- Read the outgoing fields BEFORE acting: sending moves the item, and the
92
+ -- reference can't be read afterwards.
111
93
  set toList to {}
112
94
  try
113
95
  repeat with r in (every to recipient of theReply)
@@ -124,12 +106,8 @@ ${prelude}
124
106
  end try
125
107
  ${action}
126
108
  return my sanitize(toLine) & (character id 31) & my sanitize(subj) & (character id 31) & my sanitize(repliedTo)
127
- end tell`;
128
- const parts = (0, run_1.splitFields)(await (0, run_1.runOsaScript)(script, 120000));
129
- return {
130
- to: (0, run_1.field)(parts, 0),
131
- subject: (0, run_1.field)(parts, 1),
132
- repliedToSender: (0, run_1.field)(parts, 2),
133
- };
109
+ end tell`, 'standard');
110
+ const parts = (0, run_1.splitFields)(raw);
111
+ return { to: (0, run_1.field)(parts, 0), subject: (0, run_1.field)(parts, 1), repliedToSender: (0, run_1.field)(parts, 2) };
134
112
  }
135
113
  //# sourceMappingURL=send.js.map
@@ -1 +1 @@
1
- {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K,UAAU,iBAAiB,CAAC,OAAqB;IACzD,MAAM,EAAE,GAAG,IAAA,sBAAY,EAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,MAAM,IAAA,2BAAiB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,EAAC,OAAO,EAAE,MAAM,EAAC,GAAG,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACnE,MAAM,GAAG,GAAG,MAAM,IAAA,kBAAY,EAAC;EACjC,IAAA,8BAAoB,EAAC,IAAI,EAAE,IAAI,CAAC;EAChC,IAAA,8BAAoB,EAAC,EAAE,CAAC;;;;;;;;EAQxB,OAAO;2DACkD,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,sBAAsB;;;;;2EAK/C,IAAA,cAAQ,EAAC,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;EAiB/F,MAAM;;SAEC,EAAE,UAAU,CAAC,CAAC;IACnB,MAAM,KAAK,GAAG,IAAA,iBAAW,EAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,EAAC,EAAE,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,IAAA,WAAK,EAAC,KAAK,EAAE,CAAC,CAAC,EAAC,CAAC;AAC7F,CAAC","sourcesContent":["// Composing outgoing mail on macOS: a new email, and a reply to an existing one.\nimport { asString, field, runOsaScript, splitFields } from './run';\nimport { accountLookupSnippet, macMessageId, messageLookupSnippet, resolveMacAccount } from './scripts';\nimport { parseRecipient } from '../shared/args';\nimport type { Disposition, ReplyRequest, SendRequest } from '../backend';\nimport type { ReplyEmailResult } from '../types';\n\n/**\n * What to do with a composed message.\n *\n * A new outgoing message lands in Temporary Items, not Drafts — `open` only\n * shows it — so a windowless draft is moved into Drafts explicitly. `move`\n * reports success even where it silently does nothing, so the folder is\n * confirmed to have grown rather than report a draft that doesn't exist.\n */\nfunction dispose(variable: string, disposition: Disposition): { prelude: string; action: string } {\n switch (disposition) {\n case 'send':\n return {prelude: '', action: ` send ${variable}`};\n case 'display':\n return {prelude: '', action: ` open ${variable}`};\n case 'save':\n return {\n prelude: ` set draftsFolder to drafts of targetAcct\n set draftsBefore to count of messages of draftsFolder`,\n action: ` move ${variable} to draftsFolder\n if (count of messages of draftsFolder) is not greater than draftsBefore then error \"Outlook did not file the draft in the Drafts folder.\"`,\n };\n }\n}\n\n/** One `make new … recipient` line per entry, keeping a display name when given. */\nfunction recipientLines(kind: 'to' | 'cc' | 'bcc', entries: readonly string[]): string[] {\n return entries.map(entry => {\n const {name, address} = parseRecipient(entry);\n const emailAddress = name\n ? `{name:${asString(name)}, address:${asString(address)}}`\n : `{address:${asString(address)}}`;\n return ` make new ${kind} recipient at newMsg with properties {email address:${emailAddress}}`;\n });\n}\n\n/** Send, display or file a new email. */\nexport async function sendOutlookEmail(request: SendRequest): Promise<void> {\n const acct = await resolveMacAccount(request.account);\n const {prelude, action} = dispose('newMsg', request.disposition);\n const lines = [\n ...recipientLines('to', request.to),\n ...recipientLines('cc', request.cc),\n ...recipientLines('bcc', request.bcc),\n ...request.attachments.map(file => ` make new attachment at newMsg with properties {file:POSIX file ${asString(file)}}`),\n ];\n await runOsaScript(`\ntell application \"Microsoft Outlook\"\n${accountLookupSnippet(acct, true)}\n${prelude}\n set newMsg to make new outgoing message with properties {subject:${asString(request.subject)}, content:${asString(request.htmlBody)}}\n${lines.join('\\n')}\n set account of newMsg to targetAcct\n${action}\nend tell`, 'standard');\n}\n\n/**\n * Reply to an email with the composed HTML above the quoted original.\n *\n * `reply to` builds the same quoted body COM's Reply() returns, so the insertion\n * point is the one thing the platforms must agree on (see WORD_SECTION_ANCHOR).\n * `to` comes back as the reply's resolved addresses: Outlook for Mac exposes\n * recipients as records, and the address is the half worth checking.\n */\nexport async function replyOutlookEmail(request: ReplyRequest): Promise<ReplyEmailResult> {\n const id = macMessageId(request.email.entryId);\n const acct = await resolveMacAccount(request.account);\n const {prelude, action} = dispose('theReply', request.disposition);\n const raw = await runOsaScript(`tell application \"Microsoft Outlook\"\n${accountLookupSnippet(acct, true)}\n${messageLookupSnippet(id)}\n set repliedTo to \"\"\n try\n -- Bind the record before reading its field: a nested\n -- 'address of (sender of theMsg)' does not coerce.\n set origSender to sender of theMsg\n set repliedTo to (address of origSender) as string\n end try\n${prelude}\n set theReply to reply to theMsg opening window false ${request.replyAll ? 'reply to all true' : 'without reply to all'}\n -- Neither of these is wrapped in a try. A swallowed account assignment sends\n -- from the default mailbox, and a swallowed insertion files a reply missing\n -- its text — both invisible to the caller if tolerated here.\n set account of theReply to targetAcct\n set content of theReply to my insertAboveQuoted(content of theReply, ${asString(request.html)})\n -- Read the outgoing fields BEFORE acting: sending moves the item, and the\n -- reference can't be read afterwards.\n set toList to {}\n try\n repeat with r in (every to recipient of theReply)\n try\n set ea to email address of r\n set end of toList to (address of ea) as string\n end try\n end repeat\n end try\n set toLine to my joinList(toList, \", \")\n set subj to \"\"\n try\n set subj to (subject of theReply) as string\n end try\n${action}\n return my sanitize(toLine) & (character id 31) & my sanitize(subj) & (character id 31) & my sanitize(repliedTo)\nend tell`, 'standard');\n const parts = splitFields(raw);\n return {to: field(parts, 0), subject: field(parts, 1), repliedToSender: field(parts, 2)};\n}\n"]}
@@ -1,4 +1,4 @@
1
- /** Names of the user's Outlook signatures. */
1
+ /** The signature names, sorted. */
2
2
  export declare function listOutlookSignatures(): Promise<string[]>;
3
- /** Read a named signature's HTML. Returns '' if the signature can't be found. */
3
+ /** A signature's HTML; '' when there is no signature by that name. */
4
4
  export declare function readOutlookSignatureHtml(name: string): Promise<string>;
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listOutlookSignatures = listOutlookSignatures;
4
4
  exports.readOutlookSignatureHtml = readOutlookSignatureHtml;
5
- // Unlike Windows (files on disk), Outlook for Mac serves signature content
6
- // directly through AppleScript, images included (inline data or remote refs).
5
+ // Outlook for Mac serves signatures through AppleScript, images included
6
+ // (inline data or remote references), where Windows keeps them as files.
7
7
  const run_1 = require("./run");
8
- /** Names of the user's Outlook signatures. */
8
+ /** The signature names, sorted. */
9
9
  async function listOutlookSignatures() {
10
- const script = `
10
+ const raw = await (0, run_1.runOsaScript)(`
11
11
  set sigNames to {}
12
12
  tell application "Microsoft Outlook"
13
13
  try
@@ -17,20 +17,18 @@ tell application "Microsoft Outlook"
17
17
  end try
18
18
  end tell
19
19
  set AppleScript's text item delimiters to linefeed
20
- return sigNames as string`;
21
- const raw = await (0, run_1.runOsaScript)(script, 15000);
20
+ return sigNames as string`, 'quick');
22
21
  return raw.split('\n').map(s => s.trim()).filter(Boolean).sort((a, b) => a.localeCompare(b));
23
22
  }
24
- /** Read a named signature's HTML. Returns '' if the signature can't be found. */
23
+ /** A signature's HTML; '' when there is no signature by that name. */
25
24
  async function readOutlookSignatureHtml(name) {
26
- const script = `
25
+ return (0, run_1.runOsaScript)(`
27
26
  tell application "Microsoft Outlook"
28
27
  try
29
- return content of (first signature whose name is "${(0, run_1.asEscape)(name)}")
28
+ return content of (first signature whose name is ${(0, run_1.asString)(name)})
30
29
  on error
31
30
  return ""
32
31
  end try
33
- end tell`;
34
- return (0, run_1.runOsaScript)(script, 15000);
32
+ end tell`, 'quick');
35
33
  }
36
34
  //# sourceMappingURL=signatures.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signatures.js","sourceRoot":"","sources":["../../src/mac/signatures.ts"],"names":[],"mappings":";;AAKA,sDAcC;AAGD,4DAUC;AAhCD,2EAA2E;AAC3E,8EAA8E;AAC9E,+BAA+C;AAE/C,8CAA8C;AACvC,KAAK,UAAU,qBAAqB;IACvC,MAAM,MAAM,GAAG;;;;;;;;;;0BAUO,CAAC;IACvB,MAAM,GAAG,GAAG,MAAM,IAAA,kBAAY,E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CAAC","sourcesContent":["// Outlook for Mac serves signatures through AppleScript, images included\n// (inline data or remote references), where Windows keeps them as files.\nimport { asString, runOsaScript } from './run';\n\n/** The signature names, sorted. */\nexport async function listOutlookSignatures(): Promise<string[]> {\n const raw = await runOsaScript(`\nset sigNames to {}\ntell application \"Microsoft Outlook\"\n try\n repeat with s in signatures\n set end of sigNames to (name of s as string)\n end repeat\n end try\nend tell\nset AppleScript's text item delimiters to linefeed\nreturn sigNames as string`, 'quick');\n return raw.split('\\n').map(s => s.trim()).filter(Boolean).sort((a, b) => a.localeCompare(b));\n}\n\n/** A signature's HTML; '' when there is no signature by that name. */\nexport async function readOutlookSignatureHtml(name: string): Promise<string> {\n return runOsaScript(`\ntell application \"Microsoft Outlook\"\n try\n return content of (first signature whose name is ${asString(name)})\n on error\n return \"\"\n end try\nend tell`, 'quick');\n}\n"]}
@@ -1,34 +1,22 @@
1
+ import type { EditTemplateRequest, ReadTemplatesRequest, SaveTemplateRequest } from '../backend';
1
2
  import type { SaveTemplateResult, TemplateFolderResult } from '../types';
2
3
  /**
3
- * Read the template emails saved in a mailbox folder (default "Templates"),
4
- * returning each item's full HTML body. When the folder doesn't exist, returns
5
- * folderFound:false plus the mailbox's folder names instead of throwing, so the
6
- * caller can ask the user whether to create it rather than fail.
4
+ * The template emails in a mailbox folder, newest first; a missing folder is
5
+ * reported as folderFound:false with the mailbox's top-level folder names.
7
6
  *
8
- * Bodies are read in a second pass, for the chosen templates only. That is not
9
- * a micro-optimisation: a folder of Word-sized templates is megabytes, and
10
- * pulling all of them through stdout on a call that wanted one is what overruns
11
- * the buffer — the same reason the Windows reader filters before reading.
7
+ * Bodies are read in a second pass, for the chosen templates only: a folder of
8
+ * Word-sized templates is megabytes, and pulling all of them through stdout on
9
+ * a call that wanted one is what overruns the output limit.
12
10
  */
13
- export declare function readTemplateEmails(emailAccount: string, folderName?: string, limit?: number, includeBody?: boolean, subject?: string): Promise<TemplateFolderResult>;
11
+ export declare function readTemplateEmails(request: ReadTemplatesRequest): Promise<TemplateFolderResult>;
14
12
  /**
15
- * Save a new template email into a mailbox folder (default "Templates"),
16
- * creating the folder at the mailbox root if it doesn't exist. The item is a
17
- * plain unsent mail (subject + HTML body) that can be edited in Outlook.
18
- * Never overwrites an existing item — it always adds a new one, so check with
19
- * readTemplateEmails first and only call after the user has agreed to create it.
13
+ * Save a new template email into a folder, creating the folder at the mailbox
14
+ * root when absent. Always adds a new item — never overwrites one.
20
15
  */
21
- export declare function saveTemplateEmail(emailAccount: string, subject: string, htmlBody: string, folderName?: string): Promise<SaveTemplateResult>;
16
+ export declare function saveTemplateEmail(request: SaveTemplateRequest): Promise<SaveTemplateResult>;
22
17
  /**
23
- * Open an Outlook compose window pre-filled with `currentHtml`, wait for the
24
- * user to close it, and return the HTML they saved.
25
- *
26
- * Deliberately unbounded: the run lasts as long as the person is editing. Give
27
- * it an AbortSignal (`bridge.withOptions({ signal })`) if the caller needs a way
28
- * to give up on them.
29
- *
30
- * The macOS half of the round trip differs from Windows in one visible way: an
31
- * edited draft is filed by answering Outlook's own "save this message?" prompt
32
- * on close, so the subject tells the user to save rather than to press a key.
18
+ * Open a compose window pre-filled with the HTML, wait for it to close, and
19
+ * return the saved draft's HTML. On macOS the edit is kept by answering
20
+ * Outlook's own "save this message?" prompt on close.
33
21
  */
34
- export declare function editEmailTemplate(label: string, currentHtml: string): Promise<string>;
22
+ export declare function editEmailTemplate(request: EditTemplateRequest): Promise<string>;