@mindstone/mcp-server-google-workspace 0.1.5 → 0.3.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 +28 -9
- package/dist/modules/accounts/manager.js +20 -2
- package/dist/modules/accounts/token.d.ts +13 -0
- package/dist/modules/accounts/token.js +73 -58
- package/dist/modules/accounts/types.d.ts +1 -0
- package/dist/modules/calendar/service.js +9 -0
- package/dist/modules/chat/index.d.ts +12 -0
- package/dist/modules/chat/index.js +18 -0
- package/dist/modules/chat/scopes.d.ts +14 -0
- package/dist/modules/chat/scopes.js +32 -0
- package/dist/modules/chat/types.d.ts +88 -0
- package/dist/modules/chat/types.js +14 -0
- package/dist/modules/comments/service.js +26 -5
- package/dist/modules/contacts/scopes.d.ts +1 -0
- package/dist/modules/contacts/scopes.js +2 -2
- package/dist/modules/contacts/types.d.ts +34 -0
- package/dist/modules/docs/index.js +2 -1
- package/dist/modules/docs/service.js +36 -7
- package/dist/modules/drive/activity-service.d.ts +45 -0
- package/dist/modules/drive/activity-service.js +114 -0
- package/dist/modules/drive/index.d.ts +4 -0
- package/dist/modules/drive/index.js +12 -0
- package/dist/modules/drive/scopes.d.ts +1 -0
- package/dist/modules/drive/scopes.js +3 -0
- package/dist/modules/drive/service.d.ts +2 -1
- package/dist/modules/drive/service.js +29 -0
- package/dist/modules/drive/types.d.ts +8 -0
- package/dist/modules/forms/service.js +16 -3
- package/dist/modules/gmail/services/attachment.js +2 -1
- package/dist/modules/gmail/services/base.d.ts +5 -1
- package/dist/modules/gmail/services/base.js +10 -1
- package/dist/modules/gmail/services/draft.js +13 -7
- package/dist/modules/gmail/services/email.js +4 -3
- package/dist/modules/gmail/services/label.js +10 -9
- package/dist/modules/gmail/services/settings.d.ts +14 -1
- package/dist/modules/gmail/services/settings.js +96 -1
- package/dist/modules/gmail/types.d.ts +36 -0
- package/dist/modules/meet/index.d.ts +12 -0
- package/dist/modules/meet/index.js +18 -0
- package/dist/modules/meet/scopes.d.ts +9 -0
- package/dist/modules/meet/scopes.js +25 -0
- package/dist/modules/meet/types.d.ts +97 -0
- package/dist/modules/meet/types.js +14 -0
- package/dist/modules/sheets/service.js +49 -0
- package/dist/modules/slides/service.js +31 -6
- package/dist/modules/tasks/service.js +31 -6
- package/dist/resources/compose-email-template.d.ts +1 -1
- package/dist/resources/compose-email-template.js +388 -19
- package/dist/services/base/BaseGoogleService.d.ts +9 -1
- package/dist/services/base/BaseGoogleService.js +33 -1
- package/dist/services/chat/index.d.ts +34 -0
- package/dist/services/chat/index.js +120 -0
- package/dist/services/contacts/index.d.ts +19 -1
- package/dist/services/contacts/index.js +124 -0
- package/dist/services/meet/index.d.ts +35 -0
- package/dist/services/meet/index.js +116 -0
- package/dist/tools/calendar-handlers.js +28 -23
- package/dist/tools/chat-handlers.d.ts +14 -0
- package/dist/tools/chat-handlers.js +126 -0
- package/dist/tools/contacts-handlers.d.ts +31 -0
- package/dist/tools/contacts-handlers.js +96 -23
- package/dist/tools/definitions/account.js +8 -1
- package/dist/tools/definitions/chat.d.ts +3 -0
- package/dist/tools/definitions/chat.js +137 -0
- package/dist/tools/definitions/contacts.js +82 -0
- package/dist/tools/definitions/destructive-overrides.json +12 -0
- package/dist/tools/definitions/drive.js +132 -6
- package/dist/tools/definitions/gmail.js +94 -0
- package/dist/tools/definitions/index.d.ts +2 -0
- package/dist/tools/definitions/index.js +6 -0
- package/dist/tools/definitions/meet.d.ts +3 -0
- package/dist/tools/definitions/meet.js +149 -0
- package/dist/tools/definitions/open-world-overrides.json +12 -0
- package/dist/tools/drive-handlers.d.ts +27 -0
- package/dist/tools/drive-handlers.js +93 -2
- package/dist/tools/forms-handlers.js +5 -12
- package/dist/tools/gmail-handlers.d.ts +31 -1
- package/dist/tools/gmail-handlers.js +167 -35
- package/dist/tools/meet-handlers.d.ts +42 -0
- package/dist/tools/meet-handlers.js +144 -0
- package/dist/tools/server.js +67 -5
- package/dist/tools/tasks-handlers.js +7 -18
- package/dist/tools/type-guards.d.ts +3 -1
- package/dist/tools/type-guards.js +22 -2
- package/dist/tools/types.d.ts +13 -0
- package/dist/utils/apiError.d.ts +49 -0
- package/dist/utils/apiError.js +96 -0
- package/dist/utils/scope-hierarchy.js +10 -0
- package/dist/utils/service-initializer.js +9 -0
- package/dist/utils/untrusted-content.d.ts +37 -1
- package/dist/utils/untrusted-content.js +61 -6
- package/package.json +5 -1
- package/dist/services/calendar/index.d.ts +0 -27
- package/dist/services/calendar/index.js +0 -146
- package/dist/services/gmail/index.d.ts +0 -39
- package/dist/services/gmail/index.js +0 -337
|
@@ -8,6 +8,8 @@ import { initializeCommentsModule } from '../modules/comments/index.js';
|
|
|
8
8
|
import { initializeSlidesModule } from '../modules/slides/index.js';
|
|
9
9
|
import { initializeSheetsModule } from '../modules/sheets/index.js';
|
|
10
10
|
import { initializeContactsModule } from '../modules/contacts/index.js';
|
|
11
|
+
import { initializeChatModule } from '../modules/chat/index.js';
|
|
12
|
+
import { initializeMeetModule } from '../modules/meet/index.js';
|
|
11
13
|
import { initializeTasksModule } from '../modules/tasks/index.js';
|
|
12
14
|
import { initializeFormsModule } from '../modules/forms/index.js';
|
|
13
15
|
import { registerGmailScopes } from '../modules/gmail/scopes.js';
|
|
@@ -16,6 +18,8 @@ import { registerDriveScopes } from '../modules/drive/scopes.js';
|
|
|
16
18
|
import { registerDocsScopes } from '../modules/docs/scopes.js';
|
|
17
19
|
import { registerSlidesScopes } from '../modules/slides/scopes.js';
|
|
18
20
|
import { registerSheetsScopes } from '../modules/sheets/scopes.js';
|
|
21
|
+
import { registerChatScopes } from '../modules/chat/scopes.js';
|
|
22
|
+
import { registerMeetScopes } from '../modules/meet/scopes.js';
|
|
19
23
|
import { registerTasksScopes } from '../modules/tasks/scopes.js';
|
|
20
24
|
import { registerFormsScopes } from '../modules/forms/scopes.js';
|
|
21
25
|
import { CONTACTS_SCOPES } from '../modules/contacts/scopes.js';
|
|
@@ -34,6 +38,7 @@ export const TASKS_FORMS_ENABLED = process.env.ENABLE_GOOGLE_TASKS_FORMS === 'tr
|
|
|
34
38
|
// Function to register contacts scopes
|
|
35
39
|
function registerContactsScopes() {
|
|
36
40
|
scopeRegistry.registerScope("contacts", CONTACTS_SCOPES.READONLY);
|
|
41
|
+
scopeRegistry.registerScope("contacts", CONTACTS_SCOPES.CONTACTS);
|
|
37
42
|
logger.info('Contacts scopes registered');
|
|
38
43
|
}
|
|
39
44
|
export async function initializeAllServices() {
|
|
@@ -48,6 +53,8 @@ export async function initializeAllServices() {
|
|
|
48
53
|
registerSlidesScopes();
|
|
49
54
|
registerSheetsScopes();
|
|
50
55
|
registerContactsScopes();
|
|
56
|
+
registerChatScopes();
|
|
57
|
+
registerMeetScopes();
|
|
51
58
|
// Tasks and Forms require additional OAuth scopes - only register if enabled
|
|
52
59
|
if (TASKS_FORMS_ENABLED) {
|
|
53
60
|
registerTasksScopes();
|
|
@@ -71,6 +78,8 @@ export async function initializeAllServices() {
|
|
|
71
78
|
initializeGmailModule().then(() => logger.info('Gmail module initialized')),
|
|
72
79
|
initializeCalendarModule().then(() => logger.info('Calendar module initialized')),
|
|
73
80
|
initializeContactsModule().then(() => logger.info('Contacts module initialized')),
|
|
81
|
+
initializeChatModule().then(() => logger.info('Chat module initialized')),
|
|
82
|
+
initializeMeetModule().then(() => logger.info('Meet module initialized')),
|
|
74
83
|
];
|
|
75
84
|
// Only initialize Tasks and Forms if enabled
|
|
76
85
|
if (TASKS_FORMS_ENABLED) {
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* AGENTS.md security invariant #6 — content fetched from an external system
|
|
3
|
+
* MUST be wrapped in an `<untrusted-content source="…">…</untrusted-content>`
|
|
4
|
+
* envelope (with close-tag breakout escaping) before it is returned to the
|
|
5
|
+
* LLM, so the model treats third-party / attacker-controllable text as DATA,
|
|
6
|
+
* not as instructions.
|
|
7
|
+
*
|
|
8
|
+
* This is the canonical implementation a new connector ships with. It is a
|
|
9
|
+
* VENDORED copy of the shared reference in `test-harness/src/untrusted-content.ts`
|
|
10
|
+
* — connectors cannot `import` the test-harness at runtime (it is a
|
|
11
|
+
* test/dev-only `file:` dependency that is never published into a connector's
|
|
12
|
+
* `dist/`), so the helper lives in the connector's own runtime source. Keep
|
|
13
|
+
* this byte-for-byte in sync with the shared reference; do NOT weaken the
|
|
14
|
+
* escaping back to a simple `replaceAll` (that family misses whitespace / case
|
|
15
|
+
* close-tag variants like `</untrusted-content >` / `</UNTRUSTED-CONTENT>`).
|
|
16
|
+
*
|
|
17
|
+
* `scripts/check-untrusted-coverage.mjs` greps for a reference to
|
|
18
|
+
* `untrusted-content` in any connector that talks to an external system; this
|
|
19
|
+
* file (and the call sites that import from it) is what satisfies that gate.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Wrap a single untrusted string in an `<untrusted-content source="…">`
|
|
23
|
+
* envelope, escaping any embedded close-tag variant so the envelope cannot be
|
|
24
|
+
* broken out of. `undefined` passes through untouched. Idempotent for the same
|
|
25
|
+
* `source`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function wrapUntrusted(text: string | undefined, source: string): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Recursively wrap every string value reachable inside `value`. Object keys are
|
|
30
|
+
* structural and NOT wrapped; non-string leaves pass through unchanged.
|
|
31
|
+
*/
|
|
2
32
|
export declare function wrapUntrustedJsonStrings<T>(value: T, source: string): T;
|
|
33
|
+
/**
|
|
34
|
+
* Connector-local alias for `wrapUntrusted` under the name the existing call
|
|
35
|
+
* sites were written against. `content` is required (never `undefined`), so
|
|
36
|
+
* the result is always a string.
|
|
37
|
+
*/
|
|
38
|
+
export declare function wrapUntrustedContent(content: string, source: string): string;
|
|
3
39
|
//# sourceMappingURL=untrusted-content.d.ts.map
|
|
@@ -1,10 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* AGENTS.md security invariant #6 — content fetched from an external system
|
|
3
|
+
* MUST be wrapped in an `<untrusted-content source="…">…</untrusted-content>`
|
|
4
|
+
* envelope (with close-tag breakout escaping) before it is returned to the
|
|
5
|
+
* LLM, so the model treats third-party / attacker-controllable text as DATA,
|
|
6
|
+
* not as instructions.
|
|
7
|
+
*
|
|
8
|
+
* This is the canonical implementation a new connector ships with. It is a
|
|
9
|
+
* VENDORED copy of the shared reference in `test-harness/src/untrusted-content.ts`
|
|
10
|
+
* — connectors cannot `import` the test-harness at runtime (it is a
|
|
11
|
+
* test/dev-only `file:` dependency that is never published into a connector's
|
|
12
|
+
* `dist/`), so the helper lives in the connector's own runtime source. Keep
|
|
13
|
+
* this byte-for-byte in sync with the shared reference; do NOT weaken the
|
|
14
|
+
* escaping back to a simple `replaceAll` (that family misses whitespace / case
|
|
15
|
+
* close-tag variants like `</untrusted-content >` / `</UNTRUSTED-CONTENT>`).
|
|
16
|
+
*
|
|
17
|
+
* `scripts/check-untrusted-coverage.mjs` greps for a reference to
|
|
18
|
+
* `untrusted-content` in any connector that talks to an external system; this
|
|
19
|
+
* file (and the call sites that import from it) is what satisfies that gate.
|
|
20
|
+
*/
|
|
21
|
+
const UNTRUSTED_CLOSE_TAG_VARIANT = /<\/untrusted-content\s*>/gi;
|
|
22
|
+
const ESCAPED_UNTRUSTED_CLOSE_TAG = '<\\/untrusted-content>';
|
|
23
|
+
function escapeAttr(s) {
|
|
24
|
+
return s.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>');
|
|
4
25
|
}
|
|
26
|
+
function escapeCloseTagSentinels(s) {
|
|
27
|
+
return s.replace(UNTRUSTED_CLOSE_TAG_VARIANT, ESCAPED_UNTRUSTED_CLOSE_TAG);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Wrap a single untrusted string in an `<untrusted-content source="…">`
|
|
31
|
+
* envelope, escaping any embedded close-tag variant so the envelope cannot be
|
|
32
|
+
* broken out of. `undefined` passes through untouched. Idempotent for the same
|
|
33
|
+
* `source`.
|
|
34
|
+
*/
|
|
35
|
+
export function wrapUntrusted(text, source) {
|
|
36
|
+
if (text === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
const open = `<untrusted-content source="${escapeAttr(source)}">`;
|
|
39
|
+
const close = '</untrusted-content>';
|
|
40
|
+
if (text.startsWith(open) && text.endsWith(close) && text.length >= open.length + close.length) {
|
|
41
|
+
const inner = text.slice(open.length, text.length - close.length);
|
|
42
|
+
if (!UNTRUSTED_CLOSE_TAG_VARIANT.test(inner)) {
|
|
43
|
+
UNTRUSTED_CLOSE_TAG_VARIANT.lastIndex = 0;
|
|
44
|
+
return text;
|
|
45
|
+
}
|
|
46
|
+
UNTRUSTED_CLOSE_TAG_VARIANT.lastIndex = 0;
|
|
47
|
+
}
|
|
48
|
+
return `${open}${escapeCloseTagSentinels(text)}${close}`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Recursively wrap every string value reachable inside `value`. Object keys are
|
|
52
|
+
* structural and NOT wrapped; non-string leaves pass through unchanged.
|
|
53
|
+
*/
|
|
5
54
|
export function wrapUntrustedJsonStrings(value, source) {
|
|
6
55
|
if (typeof value === 'string') {
|
|
7
|
-
return
|
|
56
|
+
return wrapUntrusted(value, source);
|
|
8
57
|
}
|
|
9
58
|
if (Array.isArray(value)) {
|
|
10
59
|
return value.map((item) => wrapUntrustedJsonStrings(item, source));
|
|
@@ -14,7 +63,13 @@ export function wrapUntrustedJsonStrings(value, source) {
|
|
|
14
63
|
}
|
|
15
64
|
return value;
|
|
16
65
|
}
|
|
17
|
-
|
|
18
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Connector-local alias for `wrapUntrusted` under the name the existing call
|
|
68
|
+
* sites were written against. `content` is required (never `undefined`), so
|
|
69
|
+
* the result is always a string.
|
|
70
|
+
*/
|
|
71
|
+
export function wrapUntrustedContent(content, source) {
|
|
72
|
+
// wrapUntrusted returns undefined only for undefined input.
|
|
73
|
+
return wrapUntrusted(content, source);
|
|
19
74
|
}
|
|
20
75
|
//# sourceMappingURL=untrusted-content.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindstone/mcp-server-google-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"mcpName": "io.github.mindstone/mcp-server-google-workspace",
|
|
5
5
|
"description": "Google Workspace MCP server for Gmail, Calendar, Drive, Docs, Sheets, Slides, Contacts, Tasks, and Forms",
|
|
6
6
|
"license": "FSL-1.1-MIT",
|
|
@@ -30,9 +30,12 @@
|
|
|
30
30
|
"prepublishOnly": "npm run build && npm test",
|
|
31
31
|
"watch": "tsc --watch",
|
|
32
32
|
"start": "node dist/index.js",
|
|
33
|
+
"pretest": "npm run compose:template:check",
|
|
33
34
|
"test": "vitest run",
|
|
34
35
|
"test:watch": "vitest",
|
|
35
36
|
"test:coverage": "vitest run --coverage",
|
|
37
|
+
"compose:template": "node scripts/gen-compose-html.mjs",
|
|
38
|
+
"compose:template:check": "node scripts/gen-compose-html.mjs --check",
|
|
36
39
|
"tools:inventory": "node scripts/generate-tools-inventory.mjs",
|
|
37
40
|
"tools:annotations": "node scripts/check-tool-annotations.mjs",
|
|
38
41
|
"request:manifest": "node scripts/generate-request-manifest.mjs",
|
|
@@ -46,6 +49,7 @@
|
|
|
46
49
|
"uuid": "^11.1.0"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
52
|
+
"@mindstone/mcp-app-compose": "file:../../packages/mcp-app-compose",
|
|
49
53
|
"@types/node": "^22",
|
|
50
54
|
"@types/uuid": "^10.0.0",
|
|
51
55
|
"@vitest/coverage-v8": "^4.1.3",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { google } from 'googleapis';
|
|
2
|
-
import { BaseGoogleService } from '../base/BaseGoogleService.js';
|
|
3
|
-
import { GetEventsParams, CreateEventParams, EventResponse, CreateEventResponse, CalendarModuleConfig } from '../../modules/calendar/types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Google Calendar Service Implementation extending BaseGoogleService.
|
|
6
|
-
* Provides calendar functionality while leveraging common Google API patterns.
|
|
7
|
-
*/
|
|
8
|
-
export declare class CalendarService extends BaseGoogleService<ReturnType<typeof google.calendar>> {
|
|
9
|
-
constructor(config?: CalendarModuleConfig);
|
|
10
|
-
/**
|
|
11
|
-
* Get an authenticated Calendar client
|
|
12
|
-
*/
|
|
13
|
-
private getCalendarClient;
|
|
14
|
-
/**
|
|
15
|
-
* Retrieve calendar events with optional filtering
|
|
16
|
-
*/
|
|
17
|
-
getEvents({ email, query, maxResults, timeMin, timeMax }: GetEventsParams): Promise<EventResponse[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve a single calendar event by ID
|
|
20
|
-
*/
|
|
21
|
-
getEvent(email: string, eventId: string): Promise<EventResponse>;
|
|
22
|
-
/**
|
|
23
|
-
* Create a new calendar event
|
|
24
|
-
*/
|
|
25
|
-
createEvent({ email, summary, description, start, end, attendees }: CreateEventParams): Promise<CreateEventResponse>;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { google } from 'googleapis';
|
|
2
|
-
import { BaseGoogleService, GoogleServiceError } from '../base/BaseGoogleService.js';
|
|
3
|
-
/**
|
|
4
|
-
* Google Calendar Service Implementation extending BaseGoogleService.
|
|
5
|
-
* Provides calendar functionality while leveraging common Google API patterns.
|
|
6
|
-
*/
|
|
7
|
-
export class CalendarService extends BaseGoogleService {
|
|
8
|
-
constructor(config) {
|
|
9
|
-
super({
|
|
10
|
-
serviceName: 'calendar',
|
|
11
|
-
version: 'v3'
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get an authenticated Calendar client
|
|
16
|
-
*/
|
|
17
|
-
async getCalendarClient(email) {
|
|
18
|
-
return this.getAuthenticatedClient(email, (auth) => google.calendar({ version: 'v3', auth }));
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Retrieve calendar events with optional filtering
|
|
22
|
-
*/
|
|
23
|
-
async getEvents({ email, query, maxResults = 10, timeMin, timeMax }) {
|
|
24
|
-
try {
|
|
25
|
-
const calendar = await this.getCalendarClient(email);
|
|
26
|
-
// Prepare search parameters
|
|
27
|
-
const params = {
|
|
28
|
-
calendarId: 'primary',
|
|
29
|
-
maxResults,
|
|
30
|
-
singleEvents: true,
|
|
31
|
-
orderBy: 'startTime'
|
|
32
|
-
};
|
|
33
|
-
if (query) {
|
|
34
|
-
params.q = query;
|
|
35
|
-
}
|
|
36
|
-
if (timeMin) {
|
|
37
|
-
params.timeMin = new Date(timeMin).toISOString();
|
|
38
|
-
}
|
|
39
|
-
if (timeMax) {
|
|
40
|
-
params.timeMax = new Date(timeMax).toISOString();
|
|
41
|
-
}
|
|
42
|
-
// List events matching criteria
|
|
43
|
-
const { data } = await calendar.events.list(params);
|
|
44
|
-
if (!data.items || data.items.length === 0) {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
// Map response to our EventResponse type
|
|
48
|
-
return data.items.map(event => ({
|
|
49
|
-
id: event.id,
|
|
50
|
-
summary: event.summary || '',
|
|
51
|
-
description: event.description || undefined,
|
|
52
|
-
start: {
|
|
53
|
-
dateTime: event.start?.dateTime || event.start?.date || '',
|
|
54
|
-
timeZone: event.start?.timeZone || 'UTC'
|
|
55
|
-
},
|
|
56
|
-
end: {
|
|
57
|
-
dateTime: event.end?.dateTime || event.end?.date || '',
|
|
58
|
-
timeZone: event.end?.timeZone || 'UTC'
|
|
59
|
-
},
|
|
60
|
-
attendees: event.attendees?.map(attendee => ({
|
|
61
|
-
email: attendee.email,
|
|
62
|
-
responseStatus: attendee.responseStatus || undefined
|
|
63
|
-
})),
|
|
64
|
-
organizer: event.organizer ? {
|
|
65
|
-
email: event.organizer.email,
|
|
66
|
-
self: event.organizer.self || false
|
|
67
|
-
} : undefined
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
throw this.handleError(error, 'Failed to get events');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Retrieve a single calendar event by ID
|
|
76
|
-
*/
|
|
77
|
-
async getEvent(email, eventId) {
|
|
78
|
-
try {
|
|
79
|
-
const calendar = await this.getCalendarClient(email);
|
|
80
|
-
const { data: event } = await calendar.events.get({
|
|
81
|
-
calendarId: 'primary',
|
|
82
|
-
eventId
|
|
83
|
-
});
|
|
84
|
-
if (!event) {
|
|
85
|
-
throw new GoogleServiceError('Event not found', 'NOT_FOUND', `No event found with ID: ${eventId}`);
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
id: event.id,
|
|
89
|
-
summary: event.summary || '',
|
|
90
|
-
description: event.description || undefined,
|
|
91
|
-
start: {
|
|
92
|
-
dateTime: event.start?.dateTime || event.start?.date || '',
|
|
93
|
-
timeZone: event.start?.timeZone || 'UTC'
|
|
94
|
-
},
|
|
95
|
-
end: {
|
|
96
|
-
dateTime: event.end?.dateTime || event.end?.date || '',
|
|
97
|
-
timeZone: event.end?.timeZone || 'UTC'
|
|
98
|
-
},
|
|
99
|
-
attendees: event.attendees?.map(attendee => ({
|
|
100
|
-
email: attendee.email,
|
|
101
|
-
responseStatus: attendee.responseStatus || undefined
|
|
102
|
-
})),
|
|
103
|
-
organizer: event.organizer ? {
|
|
104
|
-
email: event.organizer.email,
|
|
105
|
-
self: event.organizer.self || false
|
|
106
|
-
} : undefined
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
throw this.handleError(error, 'Failed to get event');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Create a new calendar event
|
|
115
|
-
*/
|
|
116
|
-
async createEvent({ email, summary, description, start, end, attendees }) {
|
|
117
|
-
try {
|
|
118
|
-
const calendar = await this.getCalendarClient(email);
|
|
119
|
-
const eventData = {
|
|
120
|
-
summary,
|
|
121
|
-
description,
|
|
122
|
-
start,
|
|
123
|
-
end,
|
|
124
|
-
attendees: attendees?.map(attendee => ({ email: attendee.email }))
|
|
125
|
-
};
|
|
126
|
-
const { data: event } = await calendar.events.insert({
|
|
127
|
-
calendarId: 'primary',
|
|
128
|
-
requestBody: eventData,
|
|
129
|
-
sendUpdates: 'all' // Send emails to attendees
|
|
130
|
-
});
|
|
131
|
-
if (!event.id || !event.summary) {
|
|
132
|
-
throw new GoogleServiceError('Failed to create event', 'CREATE_ERROR', 'Event creation response was incomplete');
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
id: event.id,
|
|
136
|
-
summary: event.summary,
|
|
137
|
-
htmlLink: event.htmlLink || '',
|
|
138
|
-
scheduledFor: '' // Legacy service - not actively used
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
throw this.handleError(error, 'Failed to create event');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { google } from 'googleapis';
|
|
2
|
-
import { BaseGoogleService } from '../base/BaseGoogleService.js';
|
|
3
|
-
import { GetEmailsParams, SendEmailParams, SendEmailResponse, GetGmailSettingsParams, GetGmailSettingsResponse, GetEmailsResponse } from '../../modules/gmail/types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Gmail service implementation extending BaseGoogleService.
|
|
6
|
-
* Handles Gmail-specific operations while leveraging common Google API functionality.
|
|
7
|
-
*/
|
|
8
|
-
export declare class GmailService extends BaseGoogleService<ReturnType<typeof google.gmail>> {
|
|
9
|
-
constructor();
|
|
10
|
-
/**
|
|
11
|
-
* Gets an authenticated Gmail client
|
|
12
|
-
*/
|
|
13
|
-
private getGmailClient;
|
|
14
|
-
/**
|
|
15
|
-
* Extracts all headers into a key-value map
|
|
16
|
-
*/
|
|
17
|
-
private extractHeaders;
|
|
18
|
-
/**
|
|
19
|
-
* Groups emails by thread ID and extracts thread information
|
|
20
|
-
*/
|
|
21
|
-
private groupEmailsByThread;
|
|
22
|
-
/**
|
|
23
|
-
* Builds a Gmail search query string from SearchCriteria
|
|
24
|
-
*/
|
|
25
|
-
private buildSearchQuery;
|
|
26
|
-
/**
|
|
27
|
-
* Gets emails with proper scope handling for search and content access.
|
|
28
|
-
*/
|
|
29
|
-
getEmails({ email, search, options, messageIds }: GetEmailsParams): Promise<GetEmailsResponse>;
|
|
30
|
-
/**
|
|
31
|
-
* Sends an email from the specified account
|
|
32
|
-
*/
|
|
33
|
-
sendEmail({ email, to, subject, body, cc, bcc }: SendEmailParams): Promise<SendEmailResponse>;
|
|
34
|
-
/**
|
|
35
|
-
* Gets Gmail settings and profile information
|
|
36
|
-
*/
|
|
37
|
-
getWorkspaceGmailSettings({ email }: GetGmailSettingsParams): Promise<GetGmailSettingsResponse>;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=index.d.ts.map
|