@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.
- package/README.md +150 -183
- package/dist/backend.d.ts +151 -0
- package/dist/backend.js +3 -0
- package/dist/backend.js.map +1 -0
- package/dist/bridge.d.ts +56 -0
- package/dist/bridge.js +507 -0
- package/dist/bridge.js.map +1 -0
- package/dist/errors.d.ts +81 -43
- package/dist/errors.js +98 -52
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +25 -52
- package/dist/index.js.map +1 -1
- package/dist/mac/accounts.d.ts +7 -2
- package/dist/mac/accounts.js +23 -6
- package/dist/mac/accounts.js.map +1 -1
- package/dist/mac/attachments.d.ts +5 -25
- package/dist/mac/attachments.js +40 -99
- package/dist/mac/attachments.js.map +1 -1
- package/dist/mac/bounces.d.ts +12 -27
- package/dist/mac/bounces.js +95 -112
- package/dist/mac/bounces.js.map +1 -1
- package/dist/mac/cleanup.d.ts +11 -25
- package/dist/mac/cleanup.js +50 -76
- package/dist/mac/cleanup.js.map +1 -1
- package/dist/mac/drafts.d.ts +13 -34
- package/dist/mac/drafts.js +95 -169
- package/dist/mac/drafts.js.map +1 -1
- package/dist/mac/folders.d.ts +10 -21
- package/dist/mac/folders.js +33 -47
- package/dist/mac/folders.js.map +1 -1
- package/dist/mac/index.d.ts +2 -22
- package/dist/mac/index.js +19 -81
- package/dist/mac/index.js.map +1 -1
- package/dist/mac/profile.d.ts +13 -0
- package/dist/mac/profile.js +149 -0
- package/dist/mac/profile.js.map +1 -0
- package/dist/mac/read.d.ts +18 -36
- package/dist/mac/read.js +154 -208
- package/dist/mac/read.js.map +1 -1
- package/dist/mac/run.d.ts +35 -39
- package/dist/mac/run.js +97 -102
- package/dist/mac/run.js.map +1 -1
- package/dist/mac/scripts.d.ts +78 -86
- package/dist/mac/scripts.js +125 -115
- package/dist/mac/scripts.js.map +1 -1
- package/dist/mac/send.d.ts +10 -20
- package/dist/mac/send.js +64 -86
- package/dist/mac/send.js.map +1 -1
- package/dist/mac/signatures.d.ts +2 -2
- package/dist/mac/signatures.js +9 -11
- package/dist/mac/signatures.js.map +1 -1
- package/dist/mac/templates.d.ts +14 -26
- package/dist/mac/templates.js +75 -113
- package/dist/mac/templates.js.map +1 -1
- package/dist/mail.d.ts +77 -45
- package/dist/mail.js +166 -73
- package/dist/mail.js.map +1 -1
- package/dist/runtime.d.ts +76 -43
- package/dist/runtime.js +103 -48
- package/dist/runtime.js.map +1 -1
- package/dist/shared/args.d.ts +48 -0
- package/dist/shared/args.js +216 -0
- package/dist/shared/args.js.map +1 -0
- package/dist/shared/attachmentMatch.d.ts +28 -16
- package/dist/shared/attachmentMatch.js +60 -22
- package/dist/shared/attachmentMatch.js.map +1 -1
- package/dist/shared/bounceReport.d.ts +11 -0
- package/dist/shared/bounceReport.js +45 -0
- package/dist/shared/bounceReport.js.map +1 -0
- package/dist/shared/bounceRules.d.ts +38 -10
- package/dist/shared/bounceRules.js +50 -32
- package/dist/shared/bounceRules.js.map +1 -1
- package/dist/shared/exec.d.ts +21 -0
- package/dist/shared/exec.js +47 -0
- package/dist/shared/exec.js.map +1 -0
- package/dist/shared/json.d.ts +12 -6
- package/dist/shared/json.js +29 -23
- package/dist/shared/json.js.map +1 -1
- package/dist/shared/locate.d.ts +39 -0
- package/dist/shared/locate.js +129 -0
- package/dist/shared/locate.js.map +1 -0
- package/dist/shared/replyBody.d.ts +42 -32
- package/dist/shared/replyBody.js +84 -71
- package/dist/shared/replyBody.js.map +1 -1
- package/dist/templateBody.d.ts +63 -0
- package/dist/{outlookTemplateSections.js → templateBody.js} +72 -72
- package/dist/templateBody.js.map +1 -0
- package/dist/types.d.ts +360 -165
- package/dist/types.js +8 -9
- package/dist/types.js.map +1 -1
- package/dist/windows/accounts.d.ts +10 -1
- package/dist/windows/accounts.js +25 -13
- package/dist/windows/accounts.js.map +1 -1
- package/dist/windows/attachments.d.ts +9 -24
- package/dist/windows/attachments.js +94 -119
- package/dist/windows/attachments.js.map +1 -1
- package/dist/windows/bounces.d.ts +13 -26
- package/dist/windows/bounces.js +169 -200
- package/dist/windows/bounces.js.map +1 -1
- package/dist/windows/cleanup.d.ts +19 -23
- package/dist/windows/cleanup.js +93 -111
- package/dist/windows/cleanup.js.map +1 -1
- package/dist/windows/drafts.d.ts +16 -35
- package/dist/windows/drafts.js +167 -253
- package/dist/windows/drafts.js.map +1 -1
- package/dist/windows/folders.d.ts +8 -13
- package/dist/windows/folders.js +45 -52
- package/dist/windows/folders.js.map +1 -1
- package/dist/windows/index.d.ts +2 -27
- package/dist/windows/index.js +11 -65
- package/dist/windows/index.js.map +1 -1
- package/dist/windows/read.d.ts +24 -45
- package/dist/windows/read.js +266 -279
- package/dist/windows/read.js.map +1 -1
- package/dist/windows/run.d.ts +39 -39
- package/dist/windows/run.js +151 -111
- package/dist/windows/run.js.map +1 -1
- package/dist/windows/scripts.d.ts +71 -38
- package/dist/windows/scripts.js +123 -71
- package/dist/windows/scripts.js.map +1 -1
- package/dist/windows/send.d.ts +6 -11
- package/dist/windows/send.js +70 -79
- package/dist/windows/send.js.map +1 -1
- package/dist/windows/signatures.d.ts +4 -10
- package/dist/windows/signatures.js +30 -37
- package/dist/windows/signatures.js.map +1 -1
- package/dist/windows/templates.d.ts +12 -18
- package/dist/windows/templates.js +126 -151
- package/dist/windows/templates.js.map +1 -1
- package/package.json +5 -4
- package/dist/OutlookService.d.ts +0 -43
- package/dist/OutlookService.js +0 -137
- package/dist/OutlookService.js.map +0 -1
- package/dist/outlookTemplateSections.d.ts +0 -62
- package/dist/outlookTemplateSections.js.map +0 -1
- package/dist/shared/capabilities.d.ts +0 -3
- package/dist/shared/capabilities.js +0 -9
- package/dist/shared/capabilities.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";;;;;;AA2IA,4CAuWC;A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AC;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"]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stable discriminants.
|
|
2
|
+
* Stable discriminants.
|
|
3
3
|
*
|
|
4
|
-
* - `UNSUPPORTED_PLATFORM` — no Outlook automation exists on this OS
|
|
5
|
-
* - `NOT_IMPLEMENTED` — the platform could do this, but
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - `
|
|
10
|
-
* - `
|
|
11
|
-
* - `
|
|
12
|
-
* - `SCRIPT_FAILED` — the interpreter ran and reported failure.
|
|
13
|
-
* - `TIMEOUT` — the run exceeded its budget and was killed.
|
|
4
|
+
* - `UNSUPPORTED_PLATFORM` — no Outlook automation exists on this OS.
|
|
5
|
+
* - `NOT_IMPLEMENTED` — the platform could do this, but this corner isn't written.
|
|
6
|
+
* - `ACCOUNT_NOT_FOUND` — no mailbox in the Outlook profile matches the address.
|
|
7
|
+
* - `NOT_FOUND` — a folder, email, attachment, template, signature or file didn't resolve.
|
|
8
|
+
* - `INVALID_REQUEST` — the arguments can't produce a call.
|
|
9
|
+
* - `SCRIPT_FAILED` — the automation script ran and failed.
|
|
10
|
+
* - `OUTPUT_TOO_LARGE` — the script printed more than `maxBufferBytes` and was killed.
|
|
11
|
+
* - `TIMEOUT` — the run exceeded its time budget and was killed.
|
|
14
12
|
* - `ABORTED` — the caller's AbortSignal fired.
|
|
15
13
|
*/
|
|
16
|
-
export type OutlookErrorCode = 'UNSUPPORTED_PLATFORM' | 'NOT_IMPLEMENTED' | 'ACCOUNT_NOT_FOUND' | 'NOT_FOUND' | 'INVALID_REQUEST' | 'SCRIPT_FAILED' | 'TIMEOUT' | 'ABORTED';
|
|
14
|
+
export type OutlookErrorCode = 'UNSUPPORTED_PLATFORM' | 'NOT_IMPLEMENTED' | 'ACCOUNT_NOT_FOUND' | 'NOT_FOUND' | 'INVALID_REQUEST' | 'SCRIPT_FAILED' | 'OUTPUT_TOO_LARGE' | 'TIMEOUT' | 'ABORTED';
|
|
15
|
+
/** The interpreter a script ran under. */
|
|
16
|
+
export type ScriptRunner = 'powershell' | 'osascript';
|
|
17
|
+
/** What a NOT_FOUND error failed to find. */
|
|
18
|
+
export type NotFoundKind = 'folder' | 'email' | 'attachment' | 'template' | 'signature' | 'file';
|
|
17
19
|
/** Base class for every error this package raises deliberately. */
|
|
18
20
|
export declare class OutlookError extends Error {
|
|
19
21
|
readonly code: OutlookErrorCode;
|
|
@@ -23,90 +25,126 @@ export declare class OutlookError extends Error {
|
|
|
23
25
|
cause?: unknown;
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
|
-
/** This OS has no Outlook automation
|
|
28
|
+
/** This OS has no Outlook automation. */
|
|
27
29
|
export declare class UnsupportedPlatformError extends OutlookError {
|
|
28
30
|
/** The platform that was asked, i.e. `process.platform` at the time. */
|
|
29
31
|
readonly platform: string;
|
|
30
|
-
constructor(platform: string
|
|
32
|
+
constructor(platform: string);
|
|
31
33
|
}
|
|
32
|
-
/** The platform
|
|
34
|
+
/** The platform could do this, but this corner isn't written. */
|
|
33
35
|
export declare class NotImplementedError extends OutlookError {
|
|
34
|
-
/**
|
|
36
|
+
/** What isn't implemented. */
|
|
35
37
|
readonly operation: string;
|
|
36
38
|
readonly platform: string;
|
|
37
39
|
constructor(operation: string, platform: string);
|
|
38
40
|
}
|
|
39
|
-
/** No
|
|
41
|
+
/** No mailbox in the Outlook profile matches the requested address. */
|
|
40
42
|
export declare class AccountNotFoundError extends OutlookError {
|
|
41
43
|
readonly account: string;
|
|
42
|
-
constructor(account: string);
|
|
44
|
+
constructor(account: string, message?: string);
|
|
43
45
|
}
|
|
44
|
-
/** A named folder, template, signature or
|
|
46
|
+
/** A named folder, email, attachment, template, signature or file didn't resolve. */
|
|
45
47
|
export declare class NotFoundError extends OutlookError {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
constructor(kind: string, message: string);
|
|
48
|
+
readonly kind: NotFoundKind;
|
|
49
|
+
constructor(kind: NotFoundKind, message: string);
|
|
49
50
|
}
|
|
50
|
-
/** The arguments can't produce a call
|
|
51
|
+
/** The arguments can't produce a call. */
|
|
51
52
|
export declare class InvalidRequestError extends OutlookError {
|
|
52
53
|
constructor(message: string);
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
|
-
* The
|
|
56
|
+
* The script ran and failed.
|
|
56
57
|
*
|
|
57
|
-
* Carries the generated script verbatim
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* attached to the failure itself.
|
|
58
|
+
* Carries the generated script verbatim — the most useful thing to have when
|
|
59
|
+
* one of these fires, and otherwise reachable only through a debug hook wired
|
|
60
|
+
* up in advance.
|
|
61
61
|
*/
|
|
62
62
|
export declare class ScriptError extends OutlookError {
|
|
63
|
-
readonly runner:
|
|
63
|
+
readonly runner: ScriptRunner;
|
|
64
64
|
readonly script: string;
|
|
65
65
|
readonly stderr: string;
|
|
66
66
|
readonly durationMs: number;
|
|
67
|
+
/** The line of `script` the failure was raised on, when the runner reports one. */
|
|
68
|
+
readonly line?: number;
|
|
67
69
|
constructor(init: {
|
|
68
|
-
runner:
|
|
70
|
+
runner: ScriptRunner;
|
|
69
71
|
script: string;
|
|
70
72
|
stderr: string;
|
|
71
73
|
durationMs: number;
|
|
74
|
+
message?: string;
|
|
75
|
+
line?: number;
|
|
72
76
|
cause?: unknown;
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
|
-
/** The
|
|
79
|
+
/** The script printed more than `maxBufferBytes` and was killed. */
|
|
80
|
+
export declare class OutputTooLargeError extends OutlookError {
|
|
81
|
+
readonly runner: ScriptRunner;
|
|
82
|
+
readonly maxBufferBytes: number;
|
|
83
|
+
readonly script: string;
|
|
84
|
+
constructor(init: {
|
|
85
|
+
runner: ScriptRunner;
|
|
86
|
+
maxBufferBytes: number;
|
|
87
|
+
script: string;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** The run exceeded its time budget and was killed. */
|
|
76
91
|
export declare class TimeoutError extends OutlookError {
|
|
77
|
-
readonly runner:
|
|
92
|
+
readonly runner: ScriptRunner;
|
|
78
93
|
readonly timeoutMs: number;
|
|
79
94
|
readonly script: string;
|
|
80
95
|
constructor(init: {
|
|
81
|
-
runner:
|
|
96
|
+
runner: ScriptRunner;
|
|
82
97
|
timeoutMs: number;
|
|
83
98
|
script: string;
|
|
84
99
|
});
|
|
85
100
|
}
|
|
86
101
|
/** The caller's AbortSignal fired. */
|
|
87
102
|
export declare class AbortedError extends OutlookError {
|
|
88
|
-
readonly runner:
|
|
89
|
-
constructor(runner:
|
|
103
|
+
readonly runner: ScriptRunner;
|
|
104
|
+
constructor(runner: ScriptRunner, reason?: unknown);
|
|
90
105
|
}
|
|
106
|
+
/** The codes a script may raise by tagging its failure message. */
|
|
107
|
+
export type ScriptFailureCode = 'ACCOUNT_NOT_FOUND' | 'NOT_FOUND' | 'INVALID_REQUEST';
|
|
108
|
+
/**
|
|
109
|
+
* The tag that opens a typed script failure, ready to be followed by the
|
|
110
|
+
* human-readable message. Plain ASCII with no quote or `$`, so it can sit
|
|
111
|
+
* inside a PowerShell or AppleScript string literal unescaped.
|
|
112
|
+
*/
|
|
113
|
+
export declare function failureTag(code: 'ACCOUNT_NOT_FOUND' | 'INVALID_REQUEST'): string;
|
|
114
|
+
export declare function failureTag(code: 'NOT_FOUND', kind: NotFoundKind): string;
|
|
115
|
+
/**
|
|
116
|
+
* The typed error a tagged script message stands for, or null when the
|
|
117
|
+
* message carries no tag.
|
|
118
|
+
*/
|
|
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;
|
|
91
122
|
/**
|
|
92
|
-
*
|
|
123
|
+
* Turn a failed run into the most specific error that can be proven.
|
|
93
124
|
*
|
|
94
|
-
* Order matters.
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
125
|
+
* Order matters. An abort and a timeout both kill the child, so the signal's
|
|
126
|
+
* own state is checked before the kill; an overflow kills it too, and is told
|
|
127
|
+
* apart by its error code. Only then is the script's message worth reading — a
|
|
128
|
+
* process killed mid-write may have printed a partial, misleading one.
|
|
98
129
|
*/
|
|
99
130
|
export declare function classifyRunFailure(init: {
|
|
100
|
-
runner:
|
|
131
|
+
runner: ScriptRunner;
|
|
101
132
|
script: string;
|
|
133
|
+
/** Everything the run wrote to stderr. */
|
|
102
134
|
stderr: string;
|
|
135
|
+
/** The script's own failure message, when the runner could isolate one. */
|
|
136
|
+
message?: string;
|
|
137
|
+
/** The script line the failure was raised on, when known. */
|
|
138
|
+
line?: number;
|
|
103
139
|
durationMs: number;
|
|
104
|
-
/** The error `execFile` handed back
|
|
140
|
+
/** The error `execFile` handed back. */
|
|
105
141
|
nodeError?: (Error & {
|
|
106
142
|
killed?: boolean;
|
|
107
143
|
code?: string | number | null;
|
|
108
144
|
}) | null;
|
|
109
|
-
/** The budget in force, for the TIMEOUT message. */
|
|
145
|
+
/** The time budget in force, for the TIMEOUT message. */
|
|
110
146
|
timeoutMs?: number;
|
|
147
|
+
/** The stdout cap in force, for the OUTPUT_TOO_LARGE message. */
|
|
148
|
+
maxBufferBytes?: number;
|
|
111
149
|
signal?: AbortSignal;
|
|
112
150
|
}): OutlookError;
|
package/dist/errors.js
CHANGED
|
@@ -1,73 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// The package's error taxonomy.
|
|
3
3
|
//
|
|
4
|
-
// Every failure
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// Every error this package throws on purpose is an `OutlookError`. A caller that
|
|
11
|
-
// wants one branch for "expected failure" and another for "bug" can switch on
|
|
12
|
-
// `err instanceof OutlookError` alone.
|
|
4
|
+
// Every failure the package raises on purpose is an `OutlookError` carrying a
|
|
5
|
+
// stable `code`. The codes are the API; the messages beside them are not — a
|
|
6
|
+
// caller branches on `error.code`, never on message text, so a message can be
|
|
7
|
+
// reworded without breaking anyone. `err instanceof OutlookError` alone
|
|
8
|
+
// separates an expected failure from a bug.
|
|
13
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.AbortedError = exports.TimeoutError = exports.ScriptError = exports.InvalidRequestError = exports.NotFoundError = exports.AccountNotFoundError = exports.NotImplementedError = exports.UnsupportedPlatformError = exports.OutlookError = void 0;
|
|
10
|
+
exports.AbortedError = exports.TimeoutError = exports.OutputTooLargeError = exports.ScriptError = exports.InvalidRequestError = exports.NotFoundError = exports.AccountNotFoundError = exports.NotImplementedError = exports.UnsupportedPlatformError = exports.OutlookError = void 0;
|
|
11
|
+
exports.failureTag = failureTag;
|
|
12
|
+
exports.errorFromTaggedMessage = errorFromTaggedMessage;
|
|
13
|
+
exports.stripFailureTags = stripFailureTags;
|
|
15
14
|
exports.classifyRunFailure = classifyRunFailure;
|
|
15
|
+
const NOT_FOUND_KINDS = ['folder', 'email', 'attachment', 'template', 'signature', 'file'];
|
|
16
16
|
/** Base class for every error this package raises deliberately. */
|
|
17
17
|
class OutlookError extends Error {
|
|
18
18
|
code;
|
|
19
19
|
/** The underlying failure, when there was one. */
|
|
20
20
|
cause;
|
|
21
21
|
constructor(code, message, options) {
|
|
22
|
-
//
|
|
23
|
-
//
|
|
22
|
+
// `cause` is an own enumerable field rather than `super`'s option: that
|
|
23
|
+
// is what puts it in a JSON dump of the error, which is where someone
|
|
24
|
+
// logging a failure looks for it.
|
|
24
25
|
super(message);
|
|
25
26
|
if (options && 'cause' in options)
|
|
26
27
|
this.cause = options.cause;
|
|
27
28
|
this.code = code;
|
|
28
|
-
// `name` is what
|
|
29
|
-
// subclass rather than a uniform "Error".
|
|
29
|
+
// `name` is what an unhandled-rejection dump shows, so make it the subclass.
|
|
30
30
|
this.name = new.target.name;
|
|
31
|
-
// Restores the prototype chain when the package is consumed as compiled
|
|
32
|
-
// ES2020 output — without it `instanceof` fails for a subclass.
|
|
33
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
exports.OutlookError = OutlookError;
|
|
37
|
-
/** This OS has no Outlook automation
|
|
34
|
+
/** This OS has no Outlook automation. */
|
|
38
35
|
class UnsupportedPlatformError extends OutlookError {
|
|
39
36
|
/** The platform that was asked, i.e. `process.platform` at the time. */
|
|
40
37
|
platform;
|
|
41
|
-
constructor(platform
|
|
42
|
-
super('UNSUPPORTED_PLATFORM',
|
|
38
|
+
constructor(platform) {
|
|
39
|
+
super('UNSUPPORTED_PLATFORM', `Outlook automation is only supported on Windows and macOS (running on '${platform}').`);
|
|
43
40
|
this.platform = platform;
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
exports.UnsupportedPlatformError = UnsupportedPlatformError;
|
|
47
|
-
/** The platform
|
|
44
|
+
/** The platform could do this, but this corner isn't written. */
|
|
48
45
|
class NotImplementedError extends OutlookError {
|
|
49
|
-
/**
|
|
46
|
+
/** What isn't implemented. */
|
|
50
47
|
operation;
|
|
51
48
|
platform;
|
|
52
49
|
constructor(operation, platform) {
|
|
53
|
-
super('NOT_IMPLEMENTED',
|
|
50
|
+
super('NOT_IMPLEMENTED', `${operation} is not implemented for Outlook on ${platform}.`);
|
|
54
51
|
this.operation = operation;
|
|
55
52
|
this.platform = platform;
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
55
|
exports.NotImplementedError = NotImplementedError;
|
|
59
|
-
/** No
|
|
56
|
+
/** No mailbox in the Outlook profile matches the requested address. */
|
|
60
57
|
class AccountNotFoundError extends OutlookError {
|
|
61
58
|
account;
|
|
62
|
-
constructor(account) {
|
|
63
|
-
super('ACCOUNT_NOT_FOUND',
|
|
59
|
+
constructor(account, message = `Outlook account '${account}' not found.`) {
|
|
60
|
+
super('ACCOUNT_NOT_FOUND', message);
|
|
64
61
|
this.account = account;
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
exports.AccountNotFoundError = AccountNotFoundError;
|
|
68
|
-
/** A named folder, template, signature or
|
|
65
|
+
/** A named folder, email, attachment, template, signature or file didn't resolve. */
|
|
69
66
|
class NotFoundError extends OutlookError {
|
|
70
|
-
/** What kind of thing was looked up — 'folder', 'template', 'signature', 'email'. */
|
|
71
67
|
kind;
|
|
72
68
|
constructor(kind, message) {
|
|
73
69
|
super('NOT_FOUND', message);
|
|
@@ -75,7 +71,7 @@ class NotFoundError extends OutlookError {
|
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
73
|
exports.NotFoundError = NotFoundError;
|
|
78
|
-
/** The arguments can't produce a call
|
|
74
|
+
/** The arguments can't produce a call. */
|
|
79
75
|
class InvalidRequestError extends OutlookError {
|
|
80
76
|
constructor(message) {
|
|
81
77
|
super('INVALID_REQUEST', message);
|
|
@@ -83,28 +79,45 @@ class InvalidRequestError extends OutlookError {
|
|
|
83
79
|
}
|
|
84
80
|
exports.InvalidRequestError = InvalidRequestError;
|
|
85
81
|
/**
|
|
86
|
-
* The
|
|
82
|
+
* The script ran and failed.
|
|
87
83
|
*
|
|
88
|
-
* Carries the generated script verbatim
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* attached to the failure itself.
|
|
84
|
+
* Carries the generated script verbatim — the most useful thing to have when
|
|
85
|
+
* one of these fires, and otherwise reachable only through a debug hook wired
|
|
86
|
+
* up in advance.
|
|
92
87
|
*/
|
|
93
88
|
class ScriptError extends OutlookError {
|
|
94
89
|
runner;
|
|
95
90
|
script;
|
|
96
91
|
stderr;
|
|
97
92
|
durationMs;
|
|
93
|
+
/** The line of `script` the failure was raised on, when the runner reports one. */
|
|
94
|
+
line;
|
|
98
95
|
constructor(init) {
|
|
99
|
-
super('SCRIPT_FAILED', init.stderr || `${init.runner} failed with no output.`, { cause: init.cause });
|
|
96
|
+
super('SCRIPT_FAILED', init.message || init.stderr || `${init.runner} failed with no output.`, { cause: init.cause });
|
|
100
97
|
this.runner = init.runner;
|
|
101
98
|
this.script = init.script;
|
|
102
99
|
this.stderr = init.stderr;
|
|
103
100
|
this.durationMs = init.durationMs;
|
|
101
|
+
if (init.line !== undefined)
|
|
102
|
+
this.line = init.line;
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
exports.ScriptError = ScriptError;
|
|
107
|
-
/** The
|
|
106
|
+
/** The script printed more than `maxBufferBytes` and was killed. */
|
|
107
|
+
class OutputTooLargeError extends OutlookError {
|
|
108
|
+
runner;
|
|
109
|
+
maxBufferBytes;
|
|
110
|
+
script;
|
|
111
|
+
constructor(init) {
|
|
112
|
+
super('OUTPUT_TOO_LARGE', `${init.runner} output exceeded maxBufferBytes (${init.maxBufferBytes}). `
|
|
113
|
+
+ 'Raise maxBufferBytes, or narrow the request.');
|
|
114
|
+
this.runner = init.runner;
|
|
115
|
+
this.maxBufferBytes = init.maxBufferBytes;
|
|
116
|
+
this.script = init.script;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.OutputTooLargeError = OutputTooLargeError;
|
|
120
|
+
/** The run exceeded its time budget and was killed. */
|
|
108
121
|
class TimeoutError extends OutlookError {
|
|
109
122
|
runner;
|
|
110
123
|
timeoutMs;
|
|
@@ -126,34 +139,67 @@ class AbortedError extends OutlookError {
|
|
|
126
139
|
}
|
|
127
140
|
}
|
|
128
141
|
exports.AbortedError = AbortedError;
|
|
142
|
+
function failureTag(code, kind) {
|
|
143
|
+
return `[outlook-bridge:${code}${kind ? `:${kind}` : ''}] `;
|
|
144
|
+
}
|
|
145
|
+
const FAILURE_TAG = /\[outlook-bridge:(ACCOUNT_NOT_FOUND|NOT_FOUND|INVALID_REQUEST)(?::([a-z]+))?\]\s*/;
|
|
146
|
+
/** A script's account-not-found message names the address in single quotes. */
|
|
147
|
+
const QUOTED_ACCOUNT = /'(.*)'/;
|
|
129
148
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* operational mistake — a typo'd or freshly-removed account — into a code a
|
|
133
|
-
* caller can branch on, instead of a SCRIPT_FAILED they'd have to grep.
|
|
134
|
-
*
|
|
135
|
-
* Deliberately narrow: it only matches the sentence our own scripts emit.
|
|
149
|
+
* The typed error a tagged script message stands for, or null when the
|
|
150
|
+
* message carries no tag.
|
|
136
151
|
*/
|
|
137
|
-
|
|
152
|
+
function errorFromTaggedMessage(message) {
|
|
153
|
+
const match = FAILURE_TAG.exec(message);
|
|
154
|
+
if (!match)
|
|
155
|
+
return null;
|
|
156
|
+
const text = (message.slice(0, match.index) + message.slice(match.index + match[0].length)).trim();
|
|
157
|
+
switch (match[1]) {
|
|
158
|
+
case 'ACCOUNT_NOT_FOUND':
|
|
159
|
+
return new AccountNotFoundError(QUOTED_ACCOUNT.exec(text)?.[1] ?? '', text);
|
|
160
|
+
case 'NOT_FOUND': {
|
|
161
|
+
const kind = NOT_FOUND_KINDS.find(k => k === match[2]) ?? 'email';
|
|
162
|
+
return new NotFoundError(kind, text);
|
|
163
|
+
}
|
|
164
|
+
default:
|
|
165
|
+
return new InvalidRequestError(text);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
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
|
+
}
|
|
138
172
|
/**
|
|
139
|
-
*
|
|
173
|
+
* Turn a failed run into the most specific error that can be proven.
|
|
140
174
|
*
|
|
141
|
-
* Order matters.
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
175
|
+
* Order matters. An abort and a timeout both kill the child, so the signal's
|
|
176
|
+
* own state is checked before the kill; an overflow kills it too, and is told
|
|
177
|
+
* apart by its error code. Only then is the script's message worth reading — a
|
|
178
|
+
* process killed mid-write may have printed a partial, misleading one.
|
|
145
179
|
*/
|
|
146
180
|
function classifyRunFailure(init) {
|
|
147
181
|
const { runner, script, stderr, durationMs, nodeError, timeoutMs, signal } = init;
|
|
148
182
|
if (signal?.aborted || nodeError?.name === 'AbortError' || nodeError?.code === 'ABORT_ERR') {
|
|
149
183
|
return new AbortedError(runner, signal?.reason);
|
|
150
184
|
}
|
|
185
|
+
if (nodeError?.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') {
|
|
186
|
+
return new OutputTooLargeError({ runner, maxBufferBytes: init.maxBufferBytes ?? 0, script });
|
|
187
|
+
}
|
|
151
188
|
if (nodeError?.killed && timeoutMs) {
|
|
152
189
|
return new TimeoutError({ runner, timeoutMs, script });
|
|
153
190
|
}
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
191
|
+
const message = (init.message ?? '').trim() || stderr.trim() || nodeError?.message || '';
|
|
192
|
+
const typed = errorFromTaggedMessage(message);
|
|
193
|
+
if (typed)
|
|
194
|
+
return typed;
|
|
195
|
+
return new ScriptError({
|
|
196
|
+
runner,
|
|
197
|
+
script,
|
|
198
|
+
stderr,
|
|
199
|
+
durationMs,
|
|
200
|
+
message,
|
|
201
|
+
line: init.line,
|
|
202
|
+
cause: nodeError ?? undefined
|
|
203
|
+
});
|
|
158
204
|
}
|
|
159
205
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,EAAE;AACF,iFAAiF;AACjF,8EAA8E;AAC9E,uCAAuC;;;AA4KvC,gDAsBC;AAvKD,mEAAmE;AACnE,MAAa,YAAa,SAAQ,KAAK;IAC1B,IAAI,CAAmB;IAEhC,kDAAkD;IACzC,KAAK,CAAW;IAEzB,YAAY,IAAsB,EAAE,OAAe,EAAE,OAA6B;QAC9E,wEAAwE;QACxE,4DAA4D;QAC5D,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,yEAAyE;QACzE,0CAA0C;QAC1C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,wEAAwE;QACxE,gEAAgE;QAChE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACJ;AAnBD,oCAmBC;AAED,iDAAiD;AACjD,MAAa,wBAAyB,SAAQ,YAAY;IACtD,wEAAwE;IAC/D,QAAQ,CAAS;IAE1B,YAAY,QAAgB,EAAE,MAAM,GAAG,4DAA4D;QAC/F,KAAK,CAAC,sBAAsB,EAAE,GAAG,MAAM,iBAAiB,QAAQ,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ;AARD,4DAQC;AAED,kEAAkE;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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"]}
|