@jbctechsolutions/mcp-office365 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +667 -0
- package/dist/applescript/account-repository.d.ts +30 -0
- package/dist/applescript/account-repository.d.ts.map +1 -0
- package/dist/applescript/account-repository.js +38 -0
- package/dist/applescript/account-repository.js.map +1 -0
- package/dist/applescript/account-scripts.d.ts +21 -0
- package/dist/applescript/account-scripts.d.ts.map +1 -0
- package/dist/applescript/account-scripts.js +180 -0
- package/dist/applescript/account-scripts.js.map +1 -0
- package/dist/applescript/calendar-manager.d.ts +44 -0
- package/dist/applescript/calendar-manager.d.ts.map +1 -0
- package/dist/applescript/calendar-manager.js +92 -0
- package/dist/applescript/calendar-manager.js.map +1 -0
- package/dist/applescript/calendar-writer.d.ts +36 -0
- package/dist/applescript/calendar-writer.d.ts.map +1 -0
- package/dist/applescript/calendar-writer.js +94 -0
- package/dist/applescript/calendar-writer.js.map +1 -0
- package/dist/applescript/content-readers.d.ts +114 -0
- package/dist/applescript/content-readers.d.ts.map +1 -0
- package/dist/applescript/content-readers.js +328 -0
- package/dist/applescript/content-readers.js.map +1 -0
- package/dist/applescript/executor.d.ts +60 -0
- package/dist/applescript/executor.d.ts.map +1 -0
- package/dist/applescript/executor.js +173 -0
- package/dist/applescript/executor.js.map +1 -0
- package/dist/applescript/index.d.ts +20 -0
- package/dist/applescript/index.d.ts.map +1 -0
- package/dist/applescript/index.js +29 -0
- package/dist/applescript/index.js.map +1 -0
- package/dist/applescript/mail-sender.d.ts +38 -0
- package/dist/applescript/mail-sender.d.ts.map +1 -0
- package/dist/applescript/mail-sender.js +67 -0
- package/dist/applescript/mail-sender.js.map +1 -0
- package/dist/applescript/parser.d.ts +235 -0
- package/dist/applescript/parser.d.ts.map +1 -0
- package/dist/applescript/parser.js +496 -0
- package/dist/applescript/parser.js.map +1 -0
- package/dist/applescript/repository.d.ts +64 -0
- package/dist/applescript/repository.d.ts.map +1 -0
- package/dist/applescript/repository.js +444 -0
- package/dist/applescript/repository.js.map +1 -0
- package/dist/applescript/scripts.d.ts +265 -0
- package/dist/applescript/scripts.d.ts.map +1 -0
- package/dist/applescript/scripts.js +1483 -0
- package/dist/applescript/scripts.js.map +1 -0
- package/dist/approval/hash.d.ts +87 -0
- package/dist/approval/hash.d.ts.map +1 -0
- package/dist/approval/hash.js +102 -0
- package/dist/approval/hash.js.map +1 -0
- package/dist/approval/index.d.ts +13 -0
- package/dist/approval/index.d.ts.map +1 -0
- package/dist/approval/index.js +7 -0
- package/dist/approval/index.js.map +1 -0
- package/dist/approval/token-manager.d.ts +51 -0
- package/dist/approval/token-manager.d.ts.map +1 -0
- package/dist/approval/token-manager.js +111 -0
- package/dist/approval/token-manager.js.map +1 -0
- package/dist/approval/types.d.ts +44 -0
- package/dist/approval/types.d.ts.map +1 -0
- package/dist/approval/types.js +6 -0
- package/dist/approval/types.js.map +1 -0
- package/dist/cli.d.ts +30 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +143 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +42 -0
- package/dist/config.js.map +1 -0
- package/dist/database/connection.d.ts +77 -0
- package/dist/database/connection.d.ts.map +1 -0
- package/dist/database/connection.js +130 -0
- package/dist/database/connection.js.map +1 -0
- package/dist/database/index.d.ts +11 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +11 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/queries.d.ts +93 -0
- package/dist/database/queries.d.ts.map +1 -0
- package/dist/database/queries.js +430 -0
- package/dist/database/queries.js.map +1 -0
- package/dist/database/repository.d.ts +198 -0
- package/dist/database/repository.d.ts.map +1 -0
- package/dist/database/repository.js +199 -0
- package/dist/database/repository.js.map +1 -0
- package/dist/graph/attachments.d.ts +72 -0
- package/dist/graph/attachments.d.ts.map +1 -0
- package/dist/graph/attachments.js +207 -0
- package/dist/graph/attachments.js.map +1 -0
- package/dist/graph/auth/config.d.ts +34 -0
- package/dist/graph/auth/config.d.ts.map +1 -0
- package/dist/graph/auth/config.js +78 -0
- package/dist/graph/auth/config.js.map +1 -0
- package/dist/graph/auth/device-code-flow.d.ts +55 -0
- package/dist/graph/auth/device-code-flow.d.ts.map +1 -0
- package/dist/graph/auth/device-code-flow.js +180 -0
- package/dist/graph/auth/device-code-flow.js.map +1 -0
- package/dist/graph/auth/index.d.ts +13 -0
- package/dist/graph/auth/index.d.ts.map +1 -0
- package/dist/graph/auth/index.js +13 -0
- package/dist/graph/auth/index.js.map +1 -0
- package/dist/graph/auth/token-cache.d.ts +41 -0
- package/dist/graph/auth/token-cache.d.ts.map +1 -0
- package/dist/graph/auth/token-cache.js +105 -0
- package/dist/graph/auth/token-cache.js.map +1 -0
- package/dist/graph/client/batch.d.ts +38 -0
- package/dist/graph/client/batch.d.ts.map +1 -0
- package/dist/graph/client/batch.js +33 -0
- package/dist/graph/client/batch.js.map +1 -0
- package/dist/graph/client/cache.d.ts +64 -0
- package/dist/graph/client/cache.d.ts.map +1 -0
- package/dist/graph/client/cache.js +108 -0
- package/dist/graph/client/cache.js.map +1 -0
- package/dist/graph/client/graph-client.d.ts +630 -0
- package/dist/graph/client/graph-client.d.ts.map +1 -0
- package/dist/graph/client/graph-client.js +1771 -0
- package/dist/graph/client/graph-client.js.map +1 -0
- package/dist/graph/client/index.d.ts +12 -0
- package/dist/graph/client/index.d.ts.map +1 -0
- package/dist/graph/client/index.js +12 -0
- package/dist/graph/client/index.js.map +1 -0
- package/dist/graph/content-readers.d.ts +106 -0
- package/dist/graph/content-readers.d.ts.map +1 -0
- package/dist/graph/content-readers.js +321 -0
- package/dist/graph/content-readers.js.map +1 -0
- package/dist/graph/index.d.ts +18 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +23 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/mailbox-adapter.d.ts +30 -0
- package/dist/graph/mailbox-adapter.d.ts.map +1 -0
- package/dist/graph/mailbox-adapter.js +59 -0
- package/dist/graph/mailbox-adapter.js.map +1 -0
- package/dist/graph/mappers/contact-mapper.d.ts +14 -0
- package/dist/graph/mappers/contact-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/contact-mapper.js +20 -0
- package/dist/graph/mappers/contact-mapper.js.map +1 -0
- package/dist/graph/mappers/email-mapper.d.ts +14 -0
- package/dist/graph/mappers/email-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/email-mapper.js +44 -0
- package/dist/graph/mappers/email-mapper.js.map +1 -0
- package/dist/graph/mappers/event-mapper.d.ts +14 -0
- package/dist/graph/mappers/event-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/event-mapper.js +31 -0
- package/dist/graph/mappers/event-mapper.js.map +1 -0
- package/dist/graph/mappers/folder-mapper.d.ts +22 -0
- package/dist/graph/mappers/folder-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/folder-mapper.js +51 -0
- package/dist/graph/mappers/folder-mapper.js.map +1 -0
- package/dist/graph/mappers/index.d.ts +16 -0
- package/dist/graph/mappers/index.d.ts.map +1 -0
- package/dist/graph/mappers/index.js +16 -0
- package/dist/graph/mappers/index.js.map +1 -0
- package/dist/graph/mappers/task-mapper.d.ts +20 -0
- package/dist/graph/mappers/task-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/task-mapper.js +27 -0
- package/dist/graph/mappers/task-mapper.js.map +1 -0
- package/dist/graph/mappers/utils.d.ts +97 -0
- package/dist/graph/mappers/utils.d.ts.map +1 -0
- package/dist/graph/mappers/utils.js +186 -0
- package/dist/graph/mappers/utils.js.map +1 -0
- package/dist/graph/repository.d.ts +1104 -0
- package/dist/graph/repository.d.ts.map +1 -0
- package/dist/graph/repository.js +2999 -0
- package/dist/graph/repository.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6052 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/html-stripper.d.ts +41 -0
- package/dist/parsers/html-stripper.d.ts.map +1 -0
- package/dist/parsers/html-stripper.js +179 -0
- package/dist/parsers/html-stripper.js.map +1 -0
- package/dist/parsers/index.d.ts +12 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +12 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/olk15.d.ts +87 -0
- package/dist/parsers/olk15.d.ts.map +1 -0
- package/dist/parsers/olk15.js +368 -0
- package/dist/parsers/olk15.js.map +1 -0
- package/dist/signature.d.ts +22 -0
- package/dist/signature.d.ts.map +1 -0
- package/dist/signature.js +89 -0
- package/dist/signature.js.map +1 -0
- package/dist/tools/calendar-permissions.d.ts +79 -0
- package/dist/tools/calendar-permissions.d.ts.map +1 -0
- package/dist/tools/calendar-permissions.js +121 -0
- package/dist/tools/calendar-permissions.js.map +1 -0
- package/dist/tools/calendar.d.ts +208 -0
- package/dist/tools/calendar.d.ts.map +1 -0
- package/dist/tools/calendar.js +247 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/categories.d.ts +94 -0
- package/dist/tools/categories.d.ts.map +1 -0
- package/dist/tools/categories.js +117 -0
- package/dist/tools/categories.js.map +1 -0
- package/dist/tools/checklist-items.d.ts +89 -0
- package/dist/tools/checklist-items.d.ts.map +1 -0
- package/dist/tools/checklist-items.js +140 -0
- package/dist/tools/checklist-items.js.map +1 -0
- package/dist/tools/contacts.d.ts +94 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +134 -0
- package/dist/tools/contacts.js.map +1 -0
- package/dist/tools/excel.d.ts +96 -0
- package/dist/tools/excel.d.ts.map +1 -0
- package/dist/tools/excel.js +165 -0
- package/dist/tools/excel.js.map +1 -0
- package/dist/tools/focused-overrides.d.ts +70 -0
- package/dist/tools/focused-overrides.d.ts.map +1 -0
- package/dist/tools/focused-overrides.js +117 -0
- package/dist/tools/focused-overrides.js.map +1 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +34 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/linked-resources.d.ts +74 -0
- package/dist/tools/linked-resources.d.ts.map +1 -0
- package/dist/tools/linked-resources.js +122 -0
- package/dist/tools/linked-resources.js.map +1 -0
- package/dist/tools/mail-rules.d.ts +98 -0
- package/dist/tools/mail-rules.d.ts.map +1 -0
- package/dist/tools/mail-rules.js +169 -0
- package/dist/tools/mail-rules.js.map +1 -0
- package/dist/tools/mail-send.d.ts +314 -0
- package/dist/tools/mail-send.d.ts.map +1 -0
- package/dist/tools/mail-send.js +555 -0
- package/dist/tools/mail-send.js.map +1 -0
- package/dist/tools/mail.d.ts +127 -0
- package/dist/tools/mail.d.ts.map +1 -0
- package/dist/tools/mail.js +311 -0
- package/dist/tools/mail.js.map +1 -0
- package/dist/tools/mailbox-organization.d.ts +301 -0
- package/dist/tools/mailbox-organization.d.ts.map +1 -0
- package/dist/tools/mailbox-organization.js +541 -0
- package/dist/tools/mailbox-organization.js.map +1 -0
- package/dist/tools/meetings.d.ts +114 -0
- package/dist/tools/meetings.d.ts.map +1 -0
- package/dist/tools/meetings.js +110 -0
- package/dist/tools/meetings.js.map +1 -0
- package/dist/tools/notes.d.ts +74 -0
- package/dist/tools/notes.d.ts.map +1 -0
- package/dist/tools/notes.js +136 -0
- package/dist/tools/notes.js.map +1 -0
- package/dist/tools/onedrive.d.ts +194 -0
- package/dist/tools/onedrive.d.ts.map +1 -0
- package/dist/tools/onedrive.js +257 -0
- package/dist/tools/onedrive.js.map +1 -0
- package/dist/tools/people.d.ts +129 -0
- package/dist/tools/people.d.ts.map +1 -0
- package/dist/tools/people.js +195 -0
- package/dist/tools/people.js.map +1 -0
- package/dist/tools/planner-visualization.d.ts +91 -0
- package/dist/tools/planner-visualization.d.ts.map +1 -0
- package/dist/tools/planner-visualization.js +192 -0
- package/dist/tools/planner-visualization.js.map +1 -0
- package/dist/tools/planner.d.ts +288 -0
- package/dist/tools/planner.d.ts.map +1 -0
- package/dist/tools/planner.js +368 -0
- package/dist/tools/planner.js.map +1 -0
- package/dist/tools/scheduling.d.ts +49 -0
- package/dist/tools/scheduling.d.ts.map +1 -0
- package/dist/tools/scheduling.js +115 -0
- package/dist/tools/scheduling.js.map +1 -0
- package/dist/tools/sharepoint.d.ts +115 -0
- package/dist/tools/sharepoint.d.ts.map +1 -0
- package/dist/tools/sharepoint.js +99 -0
- package/dist/tools/sharepoint.js.map +1 -0
- package/dist/tools/task-attachments.d.ts +74 -0
- package/dist/tools/task-attachments.d.ts.map +1 -0
- package/dist/tools/task-attachments.js +122 -0
- package/dist/tools/task-attachments.js.map +1 -0
- package/dist/tools/tasks.d.ts +74 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +126 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/teams.d.ts +389 -0
- package/dist/tools/teams.d.ts.map +1 -0
- package/dist/tools/teams.js +546 -0
- package/dist/tools/teams.js.map +1 -0
- package/dist/types/calendar.d.ts +60 -0
- package/dist/types/calendar.d.ts.map +1 -0
- package/dist/types/calendar.js +15 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/contacts.d.ts +96 -0
- package/dist/types/contacts.d.ts.map +1 -0
- package/dist/types/contacts.js +41 -0
- package/dist/types/contacts.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mail.d.ts +108 -0
- package/dist/types/mail.d.ts.map +1 -0
- package/dist/types/mail.js +40 -0
- package/dist/types/mail.js.map +1 -0
- package/dist/types/notes.d.ts +26 -0
- package/dist/types/notes.d.ts.map +1 -0
- package/dist/types/notes.js +6 -0
- package/dist/types/notes.js.map +1 -0
- package/dist/types/tasks.d.ts +31 -0
- package/dist/types/tasks.d.ts.map +1 -0
- package/dist/types/tasks.js +6 -0
- package/dist/types/tasks.js.map +1 -0
- package/dist/utils/dates.d.ts +66 -0
- package/dist/utils/dates.d.ts.map +1 -0
- package/dist/utils/dates.js +94 -0
- package/dist/utils/dates.js.map +1 -0
- package/dist/utils/errors.d.ts +218 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +306 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/visualization/html.d.ts +26 -0
- package/dist/visualization/html.d.ts.map +1 -0
- package/dist/visualization/html.js +306 -0
- package/dist/visualization/html.js.map +1 -0
- package/dist/visualization/markdown.d.ts +25 -0
- package/dist/visualization/markdown.d.ts.map +1 -0
- package/dist/visualization/markdown.js +186 -0
- package/dist/visualization/markdown.js.map +1 -0
- package/dist/visualization/mermaid.d.ts +25 -0
- package/dist/visualization/mermaid.d.ts.map +1 -0
- package/dist/visualization/mermaid.js +158 -0
- package/dist/visualization/mermaid.js.map +1 -0
- package/dist/visualization/svg.d.ts +25 -0
- package/dist/visualization/svg.d.ts.map +1 -0
- package/dist/visualization/svg.js +282 -0
- package/dist/visualization/svg.js.map +1 -0
- package/dist/visualization/types.d.ts +43 -0
- package/dist/visualization/types.d.ts.map +1 -0
- package/dist/visualization/types.js +34 -0
- package/dist/visualization/types.js.map +1 -0
- package/package.json +88 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* CLI command handlers for standalone authentication management.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx @jbctechsolutions/mcp-office365 auth # Authenticate
|
|
10
|
+
* npx @jbctechsolutions/mcp-office365 auth --status # Check status
|
|
11
|
+
* npx @jbctechsolutions/mcp-office365 auth --force # Re-authenticate (clears existing tokens)
|
|
12
|
+
* npx @jbctechsolutions/mcp-office365 auth --logout # Sign out
|
|
13
|
+
*/
|
|
14
|
+
import { getAccessToken, isAuthenticated, getAccount, signOut, getTokenCacheFile, } from './graph/index.js';
|
|
15
|
+
/**
|
|
16
|
+
* Parses CLI arguments to determine if a subcommand was invoked.
|
|
17
|
+
* Returns null if no subcommand (normal MCP server mode).
|
|
18
|
+
*/
|
|
19
|
+
export function parseCliCommand(args) {
|
|
20
|
+
if (args.length === 0)
|
|
21
|
+
return null;
|
|
22
|
+
const command = args[0];
|
|
23
|
+
if (command === 'auth') {
|
|
24
|
+
return { command: 'auth', flags: args.slice(1) };
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Handles the `auth` CLI subcommand.
|
|
30
|
+
*
|
|
31
|
+
* @param flags - CLI flags after "auth" (e.g., ["--status"])
|
|
32
|
+
* @param print - Output function (defaults to console.log)
|
|
33
|
+
* @returns Exit code (0 = success, 1 = failure)
|
|
34
|
+
*/
|
|
35
|
+
export async function handleAuthCommand(flags = [], print = console.log) {
|
|
36
|
+
if (flags.includes('--status')) {
|
|
37
|
+
return await handleStatus(print);
|
|
38
|
+
}
|
|
39
|
+
if (flags.includes('--logout')) {
|
|
40
|
+
return await handleLogout(print);
|
|
41
|
+
}
|
|
42
|
+
if (flags.includes('--force')) {
|
|
43
|
+
return await handleForceAuth(print);
|
|
44
|
+
}
|
|
45
|
+
return await handleAuth(print);
|
|
46
|
+
}
|
|
47
|
+
async function handleAuth(print) {
|
|
48
|
+
print('');
|
|
49
|
+
print('Microsoft Graph API Authentication');
|
|
50
|
+
print('='.repeat(40));
|
|
51
|
+
print('');
|
|
52
|
+
try {
|
|
53
|
+
await getAccessToken();
|
|
54
|
+
const account = await getAccount();
|
|
55
|
+
const username = account?.username ?? 'unknown';
|
|
56
|
+
print('');
|
|
57
|
+
print(`Authenticated as ${username}`);
|
|
58
|
+
print(`Tokens saved to ${getTokenCacheFile()}`);
|
|
59
|
+
print('You can now configure the MCP server in your client.');
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
64
|
+
print('');
|
|
65
|
+
print(`Authentication failed: ${message}`);
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function handleForceAuth(print) {
|
|
70
|
+
print('');
|
|
71
|
+
print('Microsoft Graph API Authentication (force re-auth)');
|
|
72
|
+
print('='.repeat(40));
|
|
73
|
+
print('');
|
|
74
|
+
try {
|
|
75
|
+
await signOut();
|
|
76
|
+
print('Cleared existing tokens.');
|
|
77
|
+
print('');
|
|
78
|
+
await getAccessToken();
|
|
79
|
+
const account = await getAccount();
|
|
80
|
+
const username = account?.username ?? 'unknown';
|
|
81
|
+
print('');
|
|
82
|
+
print(`Authenticated as ${username}`);
|
|
83
|
+
print(`Tokens saved to ${getTokenCacheFile()}`);
|
|
84
|
+
print('You can now configure the MCP server in your client.');
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
89
|
+
print('');
|
|
90
|
+
print(`Authentication failed: ${message}`);
|
|
91
|
+
return 1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function handleStatus(print) {
|
|
95
|
+
try {
|
|
96
|
+
const authenticated = await isAuthenticated();
|
|
97
|
+
if (authenticated) {
|
|
98
|
+
const account = await getAccount();
|
|
99
|
+
const username = account?.username ?? 'unknown';
|
|
100
|
+
print(`Authenticated as ${username}`);
|
|
101
|
+
print(`Token cache: ${getTokenCacheFile()}`);
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
print('Not authenticated');
|
|
105
|
+
print('Run: npx @jbctechsolutions/mcp-office365 auth');
|
|
106
|
+
return 1;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
110
|
+
print(`Error checking status: ${message}`);
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function handleLogout(print) {
|
|
115
|
+
try {
|
|
116
|
+
await signOut();
|
|
117
|
+
print('Signed out successfully');
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
122
|
+
print(`Sign out failed: ${message}`);
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a mutex that ensures only one auth flow runs at a time.
|
|
128
|
+
* Concurrent callers wait for the in-progress auth to complete.
|
|
129
|
+
* After completion (success or failure), the mutex resets for future calls.
|
|
130
|
+
*/
|
|
131
|
+
export function createAuthMutex(fn) {
|
|
132
|
+
let pending = null;
|
|
133
|
+
return () => {
|
|
134
|
+
if (pending != null) {
|
|
135
|
+
return pending;
|
|
136
|
+
}
|
|
137
|
+
pending = fn().finally(() => {
|
|
138
|
+
pending = null;
|
|
139
|
+
});
|
|
140
|
+
return pending;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,OAAO,EACP,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAO1B;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAc;IAC5C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC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rC,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAI,EAAoB;IACrD,IAAI,OAAO,GAAsB,IAAI,CAAC;IAEtC,OAAO,GAAG,EAAE;QACV,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1B,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for the Outlook MCP server.
|
|
7
|
+
*/
|
|
8
|
+
export interface OutlookConfig {
|
|
9
|
+
/** Name of the Outlook profile to use */
|
|
10
|
+
readonly profileName: string;
|
|
11
|
+
/** Base path for Outlook data */
|
|
12
|
+
readonly outlookBasePath: string;
|
|
13
|
+
/** Full path to the SQLite database */
|
|
14
|
+
readonly databasePath: string;
|
|
15
|
+
/** Path to the data directory containing olk15 files */
|
|
16
|
+
readonly dataPath: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates the configuration from environment variables.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createConfig(): OutlookConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Validates that the required paths exist.
|
|
24
|
+
* Throws if the database cannot be found.
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateConfig(config: OutlookConfig): void;
|
|
27
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,iCAAiC;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,uCAAuC;IACvC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAmBD;;GAEG;AACH,wBAAgB,YAAY,IAAI,aAAa,CAe5C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAM1D"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* Default Outlook data path on macOS.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_OUTLOOK_BASE_PATH = join(homedir(), 'Library', 'Group Containers', 'UBF8T346G9.Office', 'Outlook', 'Outlook 15 Profiles');
|
|
11
|
+
/**
|
|
12
|
+
* Default profile name.
|
|
13
|
+
*/
|
|
14
|
+
const DEFAULT_PROFILE_NAME = 'Main Profile';
|
|
15
|
+
/**
|
|
16
|
+
* Creates the configuration from environment variables.
|
|
17
|
+
*/
|
|
18
|
+
export function createConfig() {
|
|
19
|
+
const profileName = process.env['OUTLOOK_PROFILE'] ?? DEFAULT_PROFILE_NAME;
|
|
20
|
+
const outlookBasePath = process.env['OUTLOOK_BASE_PATH'] ?? DEFAULT_OUTLOOK_BASE_PATH;
|
|
21
|
+
const profilePath = join(outlookBasePath, profileName);
|
|
22
|
+
const dataPath = join(profilePath, 'Data');
|
|
23
|
+
const databasePath = join(dataPath, 'Outlook.sqlite');
|
|
24
|
+
return {
|
|
25
|
+
profileName,
|
|
26
|
+
outlookBasePath,
|
|
27
|
+
databasePath,
|
|
28
|
+
dataPath,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validates that the required paths exist.
|
|
33
|
+
* Throws if the database cannot be found.
|
|
34
|
+
*/
|
|
35
|
+
export function validateConfig(config) {
|
|
36
|
+
// Validation will be performed by the database connection
|
|
37
|
+
// This is a placeholder for any additional config validation
|
|
38
|
+
if (config.profileName.trim() === '') {
|
|
39
|
+
throw new Error('Profile name cannot be empty');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAgBjC;;GAEG;AACH,MAAM,yBAAyB,GAAG,IAAI,CACpC,OAAO,EAAE,EACT,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,qBAAqB,CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,oBAAoB,CAAC;IAC3E,MAAM,eAAe,GACnB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,yBAAyB,CAAC;IAEhE,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IAEtD,OAAO;QACL,WAAW;QACX,eAAe;QACf,YAAY;QACZ,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAqB;IAClD,0DAA0D;IAC1D,6DAA6D;IAC7D,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* SQLite database connection manager for Outlook database.
|
|
7
|
+
*
|
|
8
|
+
* Provides read-only access with retry logic for handling locked database.
|
|
9
|
+
*/
|
|
10
|
+
import { type Database as DatabaseType } from 'better-sqlite3';
|
|
11
|
+
/**
|
|
12
|
+
* Options for database connection.
|
|
13
|
+
*/
|
|
14
|
+
export interface ConnectionOptions {
|
|
15
|
+
/** Maximum number of retry attempts for locked database */
|
|
16
|
+
readonly maxRetries: number;
|
|
17
|
+
/** Initial delay in milliseconds between retries */
|
|
18
|
+
readonly retryDelayMs: number;
|
|
19
|
+
/** Busy timeout in milliseconds */
|
|
20
|
+
readonly busyTimeoutMs: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Default connection options.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEFAULT_CONNECTION_OPTIONS: ConnectionOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Interface for database connection (for dependency injection).
|
|
28
|
+
*/
|
|
29
|
+
export interface IConnection {
|
|
30
|
+
/**
|
|
31
|
+
* Executes a function with a database connection.
|
|
32
|
+
* Handles connection lifecycle and error handling.
|
|
33
|
+
*/
|
|
34
|
+
execute<T>(fn: (db: DatabaseType) => T): T;
|
|
35
|
+
/**
|
|
36
|
+
* Closes any open connections.
|
|
37
|
+
*/
|
|
38
|
+
close(): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Manages read-only connections to the Outlook SQLite database.
|
|
42
|
+
*/
|
|
43
|
+
export declare class OutlookConnection implements IConnection {
|
|
44
|
+
private readonly dbPath;
|
|
45
|
+
private db;
|
|
46
|
+
private readonly options;
|
|
47
|
+
constructor(dbPath: string, options?: Partial<ConnectionOptions>);
|
|
48
|
+
/**
|
|
49
|
+
* Validates that the database file exists.
|
|
50
|
+
*/
|
|
51
|
+
private validateDatabase;
|
|
52
|
+
/**
|
|
53
|
+
* Opens a connection to the database.
|
|
54
|
+
*/
|
|
55
|
+
private open;
|
|
56
|
+
/**
|
|
57
|
+
* Handles database errors, converting them to appropriate error types.
|
|
58
|
+
*/
|
|
59
|
+
private handleError;
|
|
60
|
+
/**
|
|
61
|
+
* Sleeps for the specified duration.
|
|
62
|
+
*/
|
|
63
|
+
private sleep;
|
|
64
|
+
/**
|
|
65
|
+
* Executes a function with a database connection, with retry logic.
|
|
66
|
+
*/
|
|
67
|
+
execute<T>(fn: (db: DatabaseType) => T): T;
|
|
68
|
+
/**
|
|
69
|
+
* Closes the database connection.
|
|
70
|
+
*/
|
|
71
|
+
close(): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a connection to the Outlook database.
|
|
75
|
+
*/
|
|
76
|
+
export declare function createConnection(dbPath: string, options?: Partial<ConnectionOptions>): IConnection;
|
|
77
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/database/connection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAiB,EAAE,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQzE;;GAEG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MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* SQLite database connection manager for Outlook database.
|
|
7
|
+
*
|
|
8
|
+
* Provides read-only access with retry logic for handling locked database.
|
|
9
|
+
*/
|
|
10
|
+
import Database from 'better-sqlite3';
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
import { DatabaseNotFoundError, DatabaseLockedError, DatabaseError, } from '../utils/errors.js';
|
|
13
|
+
/**
|
|
14
|
+
* Default connection options.
|
|
15
|
+
*/
|
|
16
|
+
export const DEFAULT_CONNECTION_OPTIONS = {
|
|
17
|
+
maxRetries: 3,
|
|
18
|
+
retryDelayMs: 500,
|
|
19
|
+
busyTimeoutMs: 5000,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Manages read-only connections to the Outlook SQLite database.
|
|
23
|
+
*/
|
|
24
|
+
export class OutlookConnection {
|
|
25
|
+
dbPath;
|
|
26
|
+
db = null;
|
|
27
|
+
options;
|
|
28
|
+
constructor(dbPath, options = {}) {
|
|
29
|
+
this.dbPath = dbPath;
|
|
30
|
+
this.options = { ...DEFAULT_CONNECTION_OPTIONS, ...options };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Validates that the database file exists.
|
|
34
|
+
*/
|
|
35
|
+
validateDatabase() {
|
|
36
|
+
if (!existsSync(this.dbPath)) {
|
|
37
|
+
throw new DatabaseNotFoundError(this.dbPath);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Opens a connection to the database.
|
|
42
|
+
*/
|
|
43
|
+
open() {
|
|
44
|
+
if (this.db !== null) {
|
|
45
|
+
return this.db;
|
|
46
|
+
}
|
|
47
|
+
this.validateDatabase();
|
|
48
|
+
try {
|
|
49
|
+
this.db = new Database(this.dbPath, {
|
|
50
|
+
readonly: true,
|
|
51
|
+
fileMustExist: true,
|
|
52
|
+
});
|
|
53
|
+
// Set pragmas for safe read-only access
|
|
54
|
+
this.db.pragma(`busy_timeout = ${this.options.busyTimeoutMs}`);
|
|
55
|
+
return this.db;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
throw this.handleError(error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Handles database errors, converting them to appropriate error types.
|
|
63
|
+
*/
|
|
64
|
+
handleError(error) {
|
|
65
|
+
if (error instanceof Error) {
|
|
66
|
+
const message = error.message.toLowerCase();
|
|
67
|
+
if (message.includes('database is locked')) {
|
|
68
|
+
return new DatabaseLockedError();
|
|
69
|
+
}
|
|
70
|
+
if (message.includes('no such file') ||
|
|
71
|
+
message.includes('unable to open')) {
|
|
72
|
+
return new DatabaseNotFoundError(this.dbPath);
|
|
73
|
+
}
|
|
74
|
+
return new DatabaseError(error.message, error);
|
|
75
|
+
}
|
|
76
|
+
return new DatabaseError('Unknown database error');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Sleeps for the specified duration.
|
|
80
|
+
*/
|
|
81
|
+
sleep(ms) {
|
|
82
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Executes a function with a database connection, with retry logic.
|
|
86
|
+
*/
|
|
87
|
+
execute(fn) {
|
|
88
|
+
let lastError = null;
|
|
89
|
+
for (let attempt = 0; attempt < this.options.maxRetries; attempt++) {
|
|
90
|
+
try {
|
|
91
|
+
const db = this.open();
|
|
92
|
+
return fn(db);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
96
|
+
// Only retry on locked database
|
|
97
|
+
if (!(error instanceof DatabaseLockedError)) {
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
// Don't sleep on last attempt
|
|
101
|
+
if (attempt < this.options.maxRetries - 1) {
|
|
102
|
+
// Synchronous sleep using busy-wait for simplicity
|
|
103
|
+
// In production, you might want to make execute async
|
|
104
|
+
const delay = this.options.retryDelayMs * Math.pow(2, attempt);
|
|
105
|
+
const end = Date.now() + delay;
|
|
106
|
+
while (Date.now() < end) {
|
|
107
|
+
// Busy wait
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
throw lastError ?? new DatabaseLockedError();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Closes the database connection.
|
|
116
|
+
*/
|
|
117
|
+
close() {
|
|
118
|
+
if (this.db !== null) {
|
|
119
|
+
this.db.close();
|
|
120
|
+
this.db = null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates a connection to the Outlook database.
|
|
126
|
+
*/
|
|
127
|
+
export function createConnection(dbPath, options) {
|
|
128
|
+
return new OutlookConnection(dbPath, options);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/database/connection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,QAA2C,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAc5B;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,GAAG;IACjB,aAAa,EAAE,IAAI;CACpB,CAAC;AAkBF;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAKT;IAJX,EAAE,GAAwB,IAAI,CAAC;IACtB,OAAO,CAAoB;IAE5C,YACmB,MAAc,EAC/B,UAAsC,EAAE;QADvB,WAAM,GAAN,MAAM,CAAQ;QAG/B,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,0BAA0B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;oBAC/B,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;wBACxB,YAAY;oBACd,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,SAAS,IAAI,IAAI,mBAAmB,EAAE,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;CACF;AAKD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAc,EACd,OAAoC;IAEpC,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Database module for Outlook MCP server.
|
|
7
|
+
*/
|
|
8
|
+
export { type IConnection, type ConnectionOptions, DEFAULT_CONNECTION_OPTIONS, OutlookConnection, createConnection, } from './connection.js';
|
|
9
|
+
export * as queries from './queries.js';
|
|
10
|
+
export { type IRepository, type IWriteableRepository, type IMailboxRepository, type MaybePromise, type FolderRow, type EmailRow, type EventRow, type ContactRow, type TaskRow, type NoteRow, OutlookRepository, createRepository, } from './repository.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Database module for Outlook MCP server.
|
|
7
|
+
*/
|
|
8
|
+
export { DEFAULT_CONNECTION_OPTIONS, OutlookConnection, createConnection, } from './connection.js';
|
|
9
|
+
export * as queries from './queries.js';
|
|
10
|
+
export { OutlookRepository, createRepository, } from './repository.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EAGL,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,EAWL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* SQL query definitions for Outlook database.
|
|
7
|
+
*
|
|
8
|
+
* All queries are read-only SELECT statements.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Lists all mail folders with message and unread counts.
|
|
12
|
+
*/
|
|
13
|
+
export declare const LIST_FOLDERS = "\nSELECT\n f.Record_RecordID as id,\n f.Folder_Name as name,\n f.Folder_ParentID as parentId,\n f.Folder_SpecialFolderType as specialType,\n f.Folder_FolderType as folderType,\n f.Record_AccountUID as accountId,\n (SELECT COUNT(*) FROM Mail m WHERE m.Record_FolderID = f.Record_RecordID) as messageCount,\n (SELECT COUNT(*) FROM Mail m WHERE m.Record_FolderID = f.Record_RecordID AND m.Message_ReadFlag = 0) as unreadCount\nFROM Folders f\nWHERE f.Folder_FolderClass = 0\nORDER BY f.Folder_FolderOrder, f.Folder_Name\n";
|
|
14
|
+
/**
|
|
15
|
+
* Gets a single folder by ID.
|
|
16
|
+
*/
|
|
17
|
+
export declare const GET_FOLDER = "\nSELECT\n f.Record_RecordID as id,\n f.Folder_Name as name,\n f.Folder_ParentID as parentId,\n f.Folder_SpecialFolderType as specialType,\n f.Folder_FolderType as folderType,\n f.Record_AccountUID as accountId,\n (SELECT COUNT(*) FROM Mail m WHERE m.Record_FolderID = f.Record_RecordID) as messageCount,\n (SELECT COUNT(*) FROM Mail m WHERE m.Record_FolderID = f.Record_RecordID AND m.Message_ReadFlag = 0) as unreadCount\nFROM Folders f\nWHERE f.Record_RecordID = ?\n";
|
|
18
|
+
/**
|
|
19
|
+
* Lists emails in a folder with pagination.
|
|
20
|
+
*/
|
|
21
|
+
export declare const LIST_EMAILS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Message_NormalizedSubject as subject,\n Message_SenderList as sender,\n Message_SenderAddressList as senderAddress,\n Message_RecipientList as recipients,\n Message_DisplayTo as displayTo,\n Message_ToRecipientAddressList as toAddresses,\n Message_CCRecipientAddressList as ccAddresses,\n Message_Preview as preview,\n Message_ReadFlag as isRead,\n Message_TimeReceived as timeReceived,\n Message_TimeSent as timeSent,\n Message_HasAttachment as hasAttachment,\n Message_Size as size,\n Record_Priority as priority,\n Record_FlagStatus as flagStatus,\n PathToDataFile as dataFilePath\nFROM Mail\nWHERE Record_FolderID = ?\nORDER BY Message_TimeReceived DESC\nLIMIT ? OFFSET ?\n";
|
|
22
|
+
/**
|
|
23
|
+
* Lists unread emails in a folder with pagination.
|
|
24
|
+
*/
|
|
25
|
+
export declare const LIST_UNREAD_EMAILS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Message_NormalizedSubject as subject,\n Message_SenderList as sender,\n Message_SenderAddressList as senderAddress,\n Message_RecipientList as recipients,\n Message_DisplayTo as displayTo,\n Message_Preview as preview,\n Message_ReadFlag as isRead,\n Message_TimeReceived as timeReceived,\n Message_TimeSent as timeSent,\n Message_HasAttachment as hasAttachment,\n Message_Size as size,\n Record_Priority as priority,\n Record_FlagStatus as flagStatus,\n PathToDataFile as dataFilePath\nFROM Mail\nWHERE Record_FolderID = ? AND Message_ReadFlag = 0\nORDER BY Message_TimeReceived DESC\nLIMIT ? OFFSET ?\n";
|
|
26
|
+
/**
|
|
27
|
+
* Searches emails by subject, sender, or preview.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SEARCH_EMAILS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Message_NormalizedSubject as subject,\n Message_SenderList as sender,\n Message_SenderAddressList as senderAddress,\n Message_RecipientList as recipients,\n Message_Preview as preview,\n Message_ReadFlag as isRead,\n Message_TimeReceived as timeReceived,\n Message_HasAttachment as hasAttachment,\n PathToDataFile as dataFilePath\nFROM Mail\nWHERE (\n Message_NormalizedSubject LIKE ?\n OR Message_SenderList LIKE ?\n OR Message_Preview LIKE ?\n)\nORDER BY Message_TimeReceived DESC\nLIMIT ?\n";
|
|
30
|
+
/**
|
|
31
|
+
* Searches emails within a specific folder.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SEARCH_EMAILS_IN_FOLDER = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Message_NormalizedSubject as subject,\n Message_SenderList as sender,\n Message_SenderAddressList as senderAddress,\n Message_RecipientList as recipients,\n Message_Preview as preview,\n Message_ReadFlag as isRead,\n Message_TimeReceived as timeReceived,\n Message_HasAttachment as hasAttachment,\n PathToDataFile as dataFilePath\nFROM Mail\nWHERE Record_FolderID = ? AND (\n Message_NormalizedSubject LIKE ?\n OR Message_SenderList LIKE ?\n OR Message_Preview LIKE ?\n)\nORDER BY Message_TimeReceived DESC\nLIMIT ?\n";
|
|
34
|
+
/**
|
|
35
|
+
* Gets a single email by ID.
|
|
36
|
+
*/
|
|
37
|
+
export declare const GET_EMAIL = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Message_NormalizedSubject as subject,\n Message_SenderList as sender,\n Message_SenderAddressList as senderAddress,\n Message_RecipientList as recipients,\n Message_DisplayTo as displayTo,\n Message_ToRecipientAddressList as toAddresses,\n Message_CCRecipientAddressList as ccAddresses,\n Message_Preview as preview,\n Message_ReadFlag as isRead,\n Message_TimeReceived as timeReceived,\n Message_TimeSent as timeSent,\n Message_HasAttachment as hasAttachment,\n Message_Size as size,\n Record_Priority as priority,\n Record_FlagStatus as flagStatus,\n Record_Categories as categories,\n Message_MessageID as messageId,\n Conversation_ConversationID as conversationId,\n PathToDataFile as dataFilePath\nFROM Mail\nWHERE Record_RecordID = ?\n";
|
|
38
|
+
/**
|
|
39
|
+
* Gets unread count for all folders or a specific folder.
|
|
40
|
+
*/
|
|
41
|
+
export declare const GET_UNREAD_COUNT = "\nSELECT COUNT(*) as count\nFROM Mail\nWHERE Message_ReadFlag = 0\n";
|
|
42
|
+
export declare const GET_UNREAD_COUNT_BY_FOLDER = "\nSELECT COUNT(*) as count\nFROM Mail\nWHERE Message_ReadFlag = 0 AND Record_FolderID = ?\n";
|
|
43
|
+
/**
|
|
44
|
+
* Lists calendar folders.
|
|
45
|
+
*/
|
|
46
|
+
export declare const LIST_CALENDARS = "\nSELECT\n f.Record_RecordID as id,\n f.Folder_Name as name,\n f.Record_AccountUID as accountId\nFROM Folders f\nWHERE f.Folder_SpecialFolderType = 4\nORDER BY f.Folder_Name\n";
|
|
47
|
+
/**
|
|
48
|
+
* Lists events with optional date range and folder filter.
|
|
49
|
+
*/
|
|
50
|
+
export declare const LIST_EVENTS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n NULL as subject,\n Calendar_StartDateUTC as startDate,\n Calendar_EndDateUTC as endDate,\n Calendar_IsRecurring as isRecurring,\n Calendar_HasReminder as hasReminder,\n Calendar_AttendeeCount as attendeeCount,\n Calendar_UID as uid,\n PathToDataFile as dataFilePath\nFROM CalendarEvents\nORDER BY Calendar_StartDateUTC\nLIMIT ?\n";
|
|
51
|
+
export declare const LIST_EVENTS_BY_FOLDER = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n NULL as subject,\n Calendar_StartDateUTC as startDate,\n Calendar_EndDateUTC as endDate,\n Calendar_IsRecurring as isRecurring,\n Calendar_HasReminder as hasReminder,\n Calendar_AttendeeCount as attendeeCount,\n Calendar_UID as uid,\n PathToDataFile as dataFilePath\nFROM CalendarEvents\nWHERE Record_FolderID = ?\nORDER BY Calendar_StartDateUTC\nLIMIT ?\n";
|
|
52
|
+
export declare const LIST_EVENTS_BY_DATE_RANGE = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n NULL as subject,\n Calendar_StartDateUTC as startDate,\n Calendar_EndDateUTC as endDate,\n Calendar_IsRecurring as isRecurring,\n Calendar_HasReminder as hasReminder,\n Calendar_AttendeeCount as attendeeCount,\n Calendar_UID as uid,\n PathToDataFile as dataFilePath\nFROM CalendarEvents\nWHERE Calendar_StartDateUTC >= ? AND Calendar_EndDateUTC <= ?\nORDER BY Calendar_StartDateUTC\nLIMIT ?\n";
|
|
53
|
+
/**
|
|
54
|
+
* Gets a single event by ID.
|
|
55
|
+
*/
|
|
56
|
+
export declare const GET_EVENT = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n NULL as subject,\n Calendar_StartDateUTC as startDate,\n Calendar_EndDateUTC as endDate,\n Calendar_IsRecurring as isRecurring,\n Calendar_HasReminder as hasReminder,\n Calendar_AttendeeCount as attendeeCount,\n Calendar_UID as uid,\n Calendar_MasterRecordID as masterRecordId,\n Calendar_RecurrenceID as recurrenceId,\n PathToDataFile as dataFilePath\nFROM CalendarEvents\nWHERE Record_RecordID = ?\n";
|
|
57
|
+
/**
|
|
58
|
+
* Lists contacts with pagination.
|
|
59
|
+
*/
|
|
60
|
+
export declare const LIST_CONTACTS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Contact_DisplayName as displayName,\n Contact_DisplayNameSort as sortName,\n Contact_ContactRecType as contactType,\n PathToDataFile as dataFilePath\nFROM Contacts\nORDER BY Contact_DisplayNameSort\nLIMIT ? OFFSET ?\n";
|
|
61
|
+
/**
|
|
62
|
+
* Searches contacts by name.
|
|
63
|
+
*/
|
|
64
|
+
export declare const SEARCH_CONTACTS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Contact_DisplayName as displayName,\n Contact_DisplayNameSort as sortName,\n PathToDataFile as dataFilePath\nFROM Contacts\nWHERE Contact_DisplayName LIKE ? OR Contact_DisplayNameSort LIKE ?\nORDER BY Contact_DisplayNameSort\nLIMIT ?\n";
|
|
65
|
+
/**
|
|
66
|
+
* Gets a single contact by ID.
|
|
67
|
+
*/
|
|
68
|
+
export declare const GET_CONTACT = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Contact_DisplayName as displayName,\n Contact_DisplayNameSort as sortName,\n Contact_ContactRecType as contactType,\n PathToDataFile as dataFilePath\nFROM Contacts\nWHERE Record_RecordID = ?\n";
|
|
69
|
+
/**
|
|
70
|
+
* Lists tasks with pagination.
|
|
71
|
+
*/
|
|
72
|
+
export declare const LIST_TASKS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Task_Name as name,\n Task_Completed as isCompleted,\n Record_DueDate as dueDate,\n Record_StartDate as startDate,\n Record_Priority as priority,\n PathToDataFile as dataFilePath\nFROM Tasks\nORDER BY Record_DueDate, Task_Name\nLIMIT ? OFFSET ?\n";
|
|
73
|
+
/**
|
|
74
|
+
* Lists incomplete tasks only.
|
|
75
|
+
*/
|
|
76
|
+
export declare const LIST_INCOMPLETE_TASKS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Task_Name as name,\n Task_Completed as isCompleted,\n Record_DueDate as dueDate,\n Record_StartDate as startDate,\n Record_Priority as priority,\n PathToDataFile as dataFilePath\nFROM Tasks\nWHERE Task_Completed = 0\nORDER BY Record_DueDate, Task_Name\nLIMIT ? OFFSET ?\n";
|
|
77
|
+
/**
|
|
78
|
+
* Searches tasks by name.
|
|
79
|
+
*/
|
|
80
|
+
export declare const SEARCH_TASKS = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Task_Name as name,\n Task_Completed as isCompleted,\n Record_DueDate as dueDate,\n Record_Priority as priority,\n PathToDataFile as dataFilePath\nFROM Tasks\nWHERE Task_Name LIKE ?\nORDER BY Record_DueDate, Task_Name\nLIMIT ?\n";
|
|
81
|
+
/**
|
|
82
|
+
* Gets a single task by ID.
|
|
83
|
+
*/
|
|
84
|
+
export declare const GET_TASK = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Task_Name as name,\n Task_Completed as isCompleted,\n Record_DueDate as dueDate,\n Record_StartDate as startDate,\n Record_Priority as priority,\n Record_HasReminder as hasReminder,\n PathToDataFile as dataFilePath\nFROM Tasks\nWHERE Record_RecordID = ?\n";
|
|
85
|
+
/**
|
|
86
|
+
* Lists notes with pagination.
|
|
87
|
+
*/
|
|
88
|
+
export declare const LIST_NOTES = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Record_ModDate as modifiedDate,\n PathToDataFile as dataFilePath\nFROM Notes\nORDER BY Record_ModDate DESC\nLIMIT ? OFFSET ?\n";
|
|
89
|
+
/**
|
|
90
|
+
* Gets a single note by ID.
|
|
91
|
+
*/
|
|
92
|
+
export declare const GET_NOTE = "\nSELECT\n Record_RecordID as id,\n Record_FolderID as folderId,\n Record_ModDate as modifiedDate,\n PathToDataFile as dataFilePath\nFROM Notes\nWHERE Record_RecordID = ?\n";
|
|
93
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/database/queries.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAMH;;GAEG;AACH,eAAO,MAAM,YAAY,mhBAaxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,keAYtB,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,WAAW,+vBAwBvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,orBAsB9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,mkBAqBzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,2lBAqBnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,k0BAyBrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,wEAI5B,CAAC;AAEF,eAAO,MAAM,0BAA0B,gGAItC,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,cAAc,uLAQ1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,2ZAevB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sbAgBjC,CAAC;AAEF,eAAO,MAAM,yBAAyB,0dAgBrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,qeAgBrB,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,aAAa,uSAWzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,wTAW3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,8QAUvB,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,UAAU,qUAatB,CAAC;AAEF;;GAEG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