@dawnlit/outlook-bridge 1.1.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +152 -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 +79 -43
  9. package/dist/errors.js +93 -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 +96 -117
  22. package/dist/mac/bounces.js.map +1 -1
  23. package/dist/mac/cleanup.d.ts +11 -25
  24. package/dist/mac/cleanup.js +44 -107
  25. package/dist/mac/cleanup.js.map +1 -1
  26. package/dist/mac/drafts.d.ts +15 -34
  27. package/dist/mac/drafts.js +113 -186
  28. package/dist/mac/drafts.js.map +1 -1
  29. package/dist/mac/folders.d.ts +12 -21
  30. package/dist/mac/folders.js +44 -59
  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 +21 -37
  39. package/dist/mac/read.js +198 -216
  40. package/dist/mac/read.js.map +1 -1
  41. package/dist/mac/run.d.ts +51 -38
  42. package/dist/mac/run.js +138 -103
  43. package/dist/mac/run.js.map +1 -1
  44. package/dist/mac/scripts.d.ts +90 -91
  45. package/dist/mac/scripts.js +167 -126
  46. package/dist/mac/scripts.js.map +1 -1
  47. package/dist/mac/send.d.ts +10 -20
  48. package/dist/mac/send.js +99 -89
  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 +79 -120
  55. package/dist/mac/templates.js.map +1 -1
  56. package/dist/mail.d.ts +80 -46
  57. package/dist/mail.js +179 -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 +26 -20
  66. package/dist/shared/attachmentMatch.js +60 -23
  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 +17 -6
  78. package/dist/shared/json.js +35 -24
  79. package/dist/shared/json.js.map +1 -1
  80. package/dist/shared/locate.d.ts +31 -0
  81. package/dist/shared/locate.js +128 -0
  82. package/dist/shared/locate.js.map +1 -0
  83. package/dist/shared/replyBody.d.ts +31 -36
  84. package/dist/shared/replyBody.js +83 -72
  85. package/dist/shared/replyBody.js.map +1 -1
  86. package/dist/shared/templateLimits.d.ts +14 -0
  87. package/dist/shared/templateLimits.js +21 -0
  88. package/dist/shared/templateLimits.js.map +1 -0
  89. package/dist/templateBody.d.ts +69 -0
  90. package/dist/{outlookTemplateSections.js → templateBody.js} +80 -73
  91. package/dist/templateBody.js.map +1 -0
  92. package/dist/types.d.ts +381 -168
  93. package/dist/types.js +8 -9
  94. package/dist/types.js.map +1 -1
  95. package/dist/windows/accounts.d.ts +7 -12
  96. package/dist/windows/accounts.js +19 -34
  97. package/dist/windows/accounts.js.map +1 -1
  98. package/dist/windows/attachments.d.ts +9 -24
  99. package/dist/windows/attachments.js +94 -119
  100. package/dist/windows/attachments.js.map +1 -1
  101. package/dist/windows/bounces.d.ts +13 -26
  102. package/dist/windows/bounces.js +168 -200
  103. package/dist/windows/bounces.js.map +1 -1
  104. package/dist/windows/cleanup.d.ts +23 -23
  105. package/dist/windows/cleanup.js +99 -113
  106. package/dist/windows/cleanup.js.map +1 -1
  107. package/dist/windows/drafts.d.ts +16 -35
  108. package/dist/windows/drafts.js +156 -253
  109. package/dist/windows/drafts.js.map +1 -1
  110. package/dist/windows/folders.d.ts +8 -13
  111. package/dist/windows/folders.js +44 -52
  112. package/dist/windows/folders.js.map +1 -1
  113. package/dist/windows/index.d.ts +2 -27
  114. package/dist/windows/index.js +11 -66
  115. package/dist/windows/index.js.map +1 -1
  116. package/dist/windows/read.d.ts +24 -60
  117. package/dist/windows/read.js +265 -306
  118. package/dist/windows/read.js.map +1 -1
  119. package/dist/windows/run.d.ts +38 -40
  120. package/dist/windows/run.js +151 -112
  121. package/dist/windows/run.js.map +1 -1
  122. package/dist/windows/scripts.d.ts +65 -55
  123. package/dist/windows/scripts.js +109 -85
  124. package/dist/windows/scripts.js.map +1 -1
  125. package/dist/windows/send.d.ts +9 -9
  126. package/dist/windows/send.js +76 -88
  127. package/dist/windows/send.js.map +1 -1
  128. package/dist/windows/signatures.d.ts +4 -10
  129. package/dist/windows/signatures.js +30 -37
  130. package/dist/windows/signatures.js.map +1 -1
  131. package/dist/windows/templates.d.ts +12 -18
  132. package/dist/windows/templates.js +117 -150
  133. package/dist/windows/templates.js.map +1 -1
  134. package/package.json +5 -4
  135. package/dist/OutlookService.d.ts +0 -43
  136. package/dist/OutlookService.js +0 -137
  137. package/dist/OutlookService.js.map +0 -1
  138. package/dist/outlookTemplateSections.d.ts +0 -62
  139. package/dist/outlookTemplateSections.js.map +0 -1
  140. package/dist/shared/capabilities.d.ts +0 -3
  141. package/dist/shared/capabilities.js +0 -9
  142. package/dist/shared/capabilities.js.map +0 -1
@@ -1,106 +1,113 @@
1
- import type { MailFolderRef } from '../types';
1
+ import type { ItemFailure, MailFolderRef } from '../types';
2
2
  /**
3
- * Resolve the account whose SMTP address matches, or raise. Emitted into a
4
- * `tell application "Microsoft Outlook"` block; binds `targetAcct`.
3
+ * An account as the generated AppleScript reaches it.
5
4
  *
6
- * `every account` errors even in legacy mode, so probe the typed classes. A
7
- * `whose email address is ...` filter can't be used either: `email address` is
8
- * also a class name, and AppleScript resolves it as one ("into type specifier").
9
- *
10
- * The thrown sentence is the one `classifyRunFailure` recognises to raise
11
- * `AccountNotFoundError`, so its wording is load-bearing.
5
+ * `folderIds` carries what Outlook's profile database knows about the mailbox's
6
+ * well-known folders — the only handle on a mailbox the dictionary publishes no
7
+ * account object for (see profile.ts). It is filled in for every account the
8
+ * profile lists, because the generated script chooses between the account
9
+ * object and the folder id at run time; nothing here has to predict which kinds
10
+ * of account a given Outlook build exposes.
12
11
  */
13
- export declare function accountLookupSnippet(emailAccount: string): string;
12
+ export interface MacAccount {
13
+ readonly emailAccount: string;
14
+ readonly folderIds?: Readonly<Record<string, number>>;
15
+ }
16
+ /** Look an address up in Outlook's profile database, for the folder ids it can add. */
17
+ export declare function resolveMacAccount(emailAccount: string): Promise<MacAccount>;
14
18
  /**
15
- * Outlook for Mac's dictionary term for each well-known root, keyed by the
16
- * olDefaultFolders id `mailFolderRef` resolves.
19
+ * Resolve the account whose address matches into `targetAcct`, inside a
20
+ * `tell application "Microsoft Outlook"` block.
21
+ *
22
+ * `every account` errors even in legacy mode, so the typed classes are probed.
23
+ * A `whose email address is …` filter can't be used either: `email address` is
24
+ * also a class name, and AppleScript resolves it as one.
17
25
  *
18
- * Verified against the running app. The terms are NOT the ones the Windows ids
19
- * suggest — `sent mail` and `junk email` do not compile at all, while
20
- * `sent items` and `junk mail` do, and a bad term fails the whole script at
21
- * compile time rather than at the offending line.
26
+ * A mailbox the dictionary publishes no account object for leaves `targetAcct`
27
+ * as `missing value` rather than failing, provided the profile gave a folder id
28
+ * to reach it by. `needsAccountObject` is for composing mail, which can't work
29
+ * without the object: the account a message is sent from can only be set from
30
+ * it, and a message composed without it goes out from the default mailbox.
31
+ */
32
+ export declare function accountLookupSnippet(acct: MacAccount, needsAccountObject?: boolean): string;
33
+ /**
34
+ * Bind `variable` to one of the account's well-known folders: through the
35
+ * account object when the probe found one, else by the folder's own id. `mail
36
+ * folder id N` resolves against the application rather than an account, and N is
37
+ * the id Outlook's profile database records for that folder.
38
+ */
39
+ export declare function rootFolderSnippet(acct: MacAccount, term: string, variable: string): string;
40
+ /**
41
+ * Outlook for Mac's dictionary term for each well-known root, by olDefaultFolders
42
+ * id. Verified against the running app: the terms are NOT what the Windows names
43
+ * suggest — `sent mail` and `junk email` don't compile, `sent items` and `junk
44
+ * mail` do — and one bad term fails the whole script at compile time.
22
45
  */
23
- export declare const MAC_ROOT_TERMS: Record<number, string>;
24
- /** The date property a folder's items actually carry. */
46
+ export declare const MAC_ROOT_TERMS: Readonly<Record<number, string>>;
47
+ /** The date property a root's items carry. */
25
48
  export declare function dateProperty(rootId: number): string;
26
49
  /**
27
- * The Windows `FolderPath` shape (`\\mailbox\Inbox\Invoices`), built here rather
28
- * than in AppleScript — escaping backslashes through a template literal and then
29
- * an AppleScript literal is unreadable, and TS already knows the parts.
50
+ * The Windows folder-path shape (`\\mailbox\Inbox\Invoices`), assembled in
51
+ * TypeScript: escaping backslashes through a template literal and then an
52
+ * AppleScript literal is unreadable, and the parts are known here anyway.
30
53
  */
31
- export declare function macFolderPath(emailAccount: string, rootLabel: string, segments: string[]): string;
32
- /** The dictionary term for a root, or a NOT_IMPLEMENTED naming what was asked. */
33
- export declare function rootTerm(ref: MailFolderRef, folderLabel?: string): string;
54
+ export declare function macFolderPath(emailAccount: string, rootLabel: string, segments: readonly string[]): string;
34
55
  /**
35
- * Emit the AppleScript that resolves `scopeFolder` from `targetAcct`, walking a
36
- * well-known root down through any further path segments. Also binds
37
- * `scopeCreated`.
56
+ * Walk a folder's `container` chain to the top as the list `chainNames`,
57
+ * nearest first. Requires `theFolder`, and leaves `cur` on the folder the walk
58
+ * stopped at: the account's nameless root folder, when it got that far.
38
59
  *
39
- * Folder names are compared with `is`, which is case-insensitive in AppleScript —
40
- * matching the Windows walk's `-ieq` so 'invoices' finds 'Invoices' on both.
41
- * A missing segment errors by name instead of falling back to the root: silently
42
- * returning the Inbox for a caller that scoped to one folder hands back the wrong
43
- * emails under a name that says otherwise. `createMissing` builds the whole
44
- * chain instead, so a nested destination is one call.
60
+ * The chain's last element is the folder directly under the account, and an
61
+ * account can't hold two top-level folders of one name, so comparing that name
62
+ * is exact.
45
63
  */
46
- export declare function mailScopeSnippet(ref: MailFolderRef, folderLabel?: string, createMissing?: boolean): string;
64
+ export declare function folderChainSnippet(indent: string): string;
47
65
  /**
48
- * The message-id text for a script, or an InvalidRequestError.
66
+ * Resolve `scopeFolder` from `targetAcct`: a well-known root walked down through
67
+ * any further segments. Also binds `scopeCreated`.
49
68
  *
50
- * Outlook for Mac ids are small integers; a Windows MAPI EntryID is rejected up
51
- * front rather than left to fail as a confusing "not found", because a caller
52
- * that persisted one from a Windows run needs to be told exactly that.
69
+ * Names compare with `is`, which is case-insensitive in AppleScript, matching
70
+ * the Windows walk. A missing segment fails as NOT_FOUND rather than falling
71
+ * back to the root; `createMissing` builds the chain instead.
53
72
  */
54
- export declare function macMessageId(entryId: string): string;
73
+ export declare function mailScopeSnippet(acct: MacAccount, ref: MailFolderRef, folderLabel?: string, createMissing?: boolean): string;
55
74
  /**
56
- * Split ids into the ones a script can look up and the ones that can only fail.
75
+ * The message id text for a script, or INVALID_REQUEST.
57
76
  *
58
- * The per-id operations report failures rather than throwing, so an unusable id
59
- * belongs in the result's `failed` list beside a genuine lookup miss — not as an
60
- * exception that discards the ids that would have worked.
77
+ * Outlook for Mac ids are small integers; a Windows EntryID is refused up front
78
+ * rather than left to fail as a confusing "not found", because a caller that
79
+ * persisted one from a Windows run needs to be told exactly that.
80
+ */
81
+ export declare function macMessageId(entryId: string): string;
82
+ /**
83
+ * Split ids into those a script can look up and those that can only fail. A
84
+ * batch reports an unusable id beside a genuine miss rather than throwing and
85
+ * discarding the ids that would have worked.
61
86
  */
62
87
  export declare function partitionMessageIds(entryIds: readonly string[]): {
63
88
  valid: string[];
64
- invalid: {
65
- entryId: string;
66
- error: string;
67
- }[];
89
+ invalid: ItemFailure[];
68
90
  };
69
91
  /**
70
- * Resolve `theMsg` from a macOS message id, or raise.
71
- *
72
- * `message id N` resolves against the application rather than one folder, so the
73
- * message is found wherever it currently sits — including a subfolder.
92
+ * Bind `theMsg` to a message id, or fail as NOT_FOUND. `message id N` resolves
93
+ * against the application, so the message is found wherever it sits.
74
94
  */
75
- export declare function messageLookupSnippet(id: string, variable?: string): string;
95
+ export declare function messageLookupSnippet(id: string): string;
76
96
  /**
77
- * The sender's display name and address, as `sndName` / `sndAddr`.
78
- *
79
- * `sender` yields a record, and `address of sender of m` fails to coerce, so the
80
- * record has to be bound first. `name` is absent when there is no display name.
97
+ * `theMsg`'s sender as `sndName` / `sndAddr`. `sender` is a record, and
98
+ * `address of sender of m` doesn't coerce, so the record is bound first.
81
99
  */
82
- export declare function senderSnippet(messageVariable?: string, indent?: string): string;
100
+ export declare function senderSnippet(indent?: string): string;
83
101
  /**
84
- * Everything a reader wants off ONE message already bound to `theMsg`, and the
85
- * row it produces — emitted together so the read order and the positions the
86
- * TypeScript decoders index into cannot drift apart.
87
- *
88
- * Three callers share it (`readEmailBody`, `readSelectedEmail`, and the
89
- * attachment resolver) and differ only in how they bind `theMsg`. They used to
90
- * share it by copy: thirty lines repeated, with the `time received` → `time sent`
91
- * fallback and the field order restated each time, so a dictionary fix reached
92
- * one reader and not the others.
93
- *
94
- * `bodyText` is emitted LAST when asked for, so a stray separator in an earlier
95
- * field cannot shift it.
102
+ * Everything a reader wants off one message bound to `theMsg`, emitted together
103
+ * with the row it produces (see `messageDetailFields`) so the read order and the
104
+ * positions the decoders index into cannot drift apart. `bodyText` is emitted
105
+ * LAST when asked for, so a stray separator in an earlier field can't shift it.
96
106
  */
97
107
  export declare function messageDetailSnippet(withBody?: boolean, indent?: string): string;
98
- /**
99
- * The fields `messageDetailSnippet` fills, in row order. The decoders read them
100
- * back by the positions in `MessageDetail`.
101
- */
108
+ /** The fields `messageDetailSnippet` fills, in row order — see `MessageDetail`. */
102
109
  export declare function messageDetailFields(withBody?: boolean): string[];
103
- /** Where each of those fields lands in the emitted row. */
110
+ /** Where each of those fields lands in the row. */
104
111
  export declare const MessageDetail: {
105
112
  readonly id: 0;
106
113
  readonly subject: 1;
@@ -111,27 +118,19 @@ export declare const MessageDetail: {
111
118
  readonly body: 6;
112
119
  };
113
120
  /**
114
- * The first recipient's name and address, as `sndName` / `sndAddr` — what
115
- * outgoing mail reports in place of a sender, matching the Windows reader's
116
- * contract for Sent Items (a folder of mail from yourself is unreadable).
117
- */
118
- export declare function firstRecipientSnippet(messageVariable?: string, indent?: string): string;
119
- /**
120
- * Every SMTP address a message was addressed to, as the list `addrList`.
121
- *
122
- * `every recipient` covers To, CC and BCC — the full set, which is the whole
123
- * point of readSentRecipientGroups.
121
+ * `theMsg`'s first recipient as `sndName` / `sndAddr` — what outgoing mail
122
+ * reports in place of a sender.
124
123
  */
125
- export declare function allRecipientsSnippet(messageVariable?: string, indent?: string): string;
124
+ export declare function firstRecipientSnippet(indent?: string): string;
125
+ /** Every address `theMsg` was sent to — To, CC and BCC — as the list `addrList`. */
126
+ export declare function allRecipientsSnippet(indent?: string): string;
126
127
  /**
127
- * Recursive folder-by-name search from `startFolder`, case-insensitive and
128
- * depth-capped — the macOS counterpart of the Windows Find-FolderByName, used to
129
- * resolve a template folder anywhere in the mailbox tree.
128
+ * Recursive, case-insensitive, depth-capped folder search from `startFolder` —
129
+ * the macOS counterpart of the Windows Find-FolderByName.
130
130
  */
131
131
  export declare 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";
132
132
  /**
133
- * Account enumeration only works when Outlook runs in legacy mode; New Outlook
134
- * errors on `every account` and returns empty lists for the typed classes, so
135
- * each class is probed independently and failures are ignored.
133
+ * Enumerate the accounts, probing each class separately: legacy Outlook errors
134
+ * on `every account`, and New Outlook returns empty lists for the classes.
136
135
  */
137
136
  export declare 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";