@plosson/agentio 0.5.3 → 0.5.5
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/package.json +8 -2
- package/src/auth/oauth.ts +2 -2
- package/src/auth/token-manager.ts +25 -3
- package/src/commands/gcal.ts +7 -9
- package/src/commands/gchat.ts +5 -10
- package/src/commands/gdocs.ts +2 -9
- package/src/commands/gdrive.ts +2 -9
- package/src/commands/gmail.ts +5 -8
- package/src/commands/gsheets.ts +2 -9
- package/src/commands/gtasks.ts +6 -9
- package/src/services/gcal/client.ts +2 -2
- package/src/services/gchat/client.ts +8 -8
- package/src/services/gdocs/client.ts +4 -4
- package/src/services/gdrive/client.ts +4 -4
- package/src/services/gmail/client.ts +2 -2
- package/src/services/gsheets/client.ts +6 -5
- package/src/services/gtasks/client.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plosson/agentio",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "CLI for LLM agents to interact with communication and tracking services",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,10 +46,16 @@
|
|
|
46
46
|
"typescript": "^5.9.3"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
+
"@googleapis/calendar": "^14.2.0",
|
|
50
|
+
"@googleapis/chat": "^44.6.0",
|
|
51
|
+
"@googleapis/drive": "^20.0.1",
|
|
52
|
+
"@googleapis/gmail": "^16.1.1",
|
|
53
|
+
"@googleapis/sheets": "^13.0.1",
|
|
54
|
+
"@googleapis/tasks": "^12.0.0",
|
|
49
55
|
"@inquirer/prompts": "^8.2.0",
|
|
50
56
|
"@whiskeysockets/baileys": "^7.0.0-rc.9",
|
|
51
57
|
"commander": "^14.0.2",
|
|
52
|
-
"
|
|
58
|
+
"google-auth-library": "^9.0.0",
|
|
53
59
|
"libsodium-wrappers": "^0.8.1",
|
|
54
60
|
"qrcode-terminal": "^0.12.0",
|
|
55
61
|
"rss-parser": "^3.13.0"
|
package/src/auth/oauth.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
2
2
|
import { GOOGLE_OAUTH_CONFIG } from '../config/credentials';
|
|
3
3
|
import { findAvailablePort, startOAuthCallbackServer, launchBrowser } from './oauth-server';
|
|
4
4
|
import type { OAuthTokens } from '../types/tokens';
|
|
@@ -70,7 +70,7 @@ export async function performOAuthFlow(
|
|
|
70
70
|
const port = await findAvailablePort();
|
|
71
71
|
const redirectUri = `http://localhost:${port}/callback`;
|
|
72
72
|
|
|
73
|
-
const oauth2Client = new
|
|
73
|
+
const oauth2Client = new OAuth2Client(
|
|
74
74
|
GOOGLE_OAUTH_CONFIG.clientId,
|
|
75
75
|
GOOGLE_OAUTH_CONFIG.clientSecret,
|
|
76
76
|
redirectUri
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
2
2
|
import { getCredentials, setCredentials } from './token-store';
|
|
3
3
|
import { resolveProfile } from '../config/config-manager';
|
|
4
4
|
import { GOOGLE_OAUTH_CONFIG } from '../config/credentials';
|
|
@@ -56,7 +56,7 @@ async function refreshTokens(
|
|
|
56
56
|
profileName: string,
|
|
57
57
|
tokens: OAuthTokens
|
|
58
58
|
): Promise<OAuthTokens> {
|
|
59
|
-
const oauth2Client = new
|
|
59
|
+
const oauth2Client = new OAuth2Client(
|
|
60
60
|
GOOGLE_OAUTH_CONFIG.clientId,
|
|
61
61
|
GOOGLE_OAUTH_CONFIG.clientSecret
|
|
62
62
|
);
|
|
@@ -89,7 +89,7 @@ async function refreshTokens(
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export function createGoogleAuth(tokens: OAuthTokens) {
|
|
92
|
-
const oauth2Client = new
|
|
92
|
+
const oauth2Client = new OAuth2Client(
|
|
93
93
|
GOOGLE_OAUTH_CONFIG.clientId,
|
|
94
94
|
GOOGLE_OAUTH_CONFIG.clientSecret
|
|
95
95
|
);
|
|
@@ -102,3 +102,25 @@ export function createGoogleAuth(tokens: OAuthTokens) {
|
|
|
102
102
|
|
|
103
103
|
return oauth2Client;
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Fetch user email from Google's userinfo endpoint
|
|
108
|
+
*/
|
|
109
|
+
export async function fetchGoogleUserEmail(accessToken: string): Promise<string> {
|
|
110
|
+
const response = await fetch('https://www.googleapis.com/oauth2/v2/userinfo', {
|
|
111
|
+
headers: {
|
|
112
|
+
Authorization: `Bearer ${accessToken}`,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (!response.ok) {
|
|
117
|
+
throw new Error(`Failed to fetch user info: ${response.status}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const data = await response.json() as { email?: string };
|
|
121
|
+
if (!data.email) {
|
|
122
|
+
throw new Error('No email returned from userinfo endpoint');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return data.email;
|
|
126
|
+
}
|
package/src/commands/gcal.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
3
|
-
import { getValidTokens, createGoogleAuth } from '../auth/token-manager';
|
|
2
|
+
import { calendar } from '@googleapis/calendar';
|
|
3
|
+
import { getValidTokens, createGoogleAuth, fetchGoogleUserEmail } from '../auth/token-manager';
|
|
4
4
|
import { setCredentials } from '../auth/token-store';
|
|
5
5
|
import { setProfile } from '../config/config-manager';
|
|
6
6
|
import { createProfileCommands } from '../utils/profile-commands';
|
|
@@ -365,13 +365,11 @@ export function registerGCalCommands(program: Command): void {
|
|
|
365
365
|
|
|
366
366
|
const tokens = await performOAuthFlow('gcal');
|
|
367
367
|
|
|
368
|
-
// Fetch the user's email
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (!email) {
|
|
368
|
+
// Fetch the user's email
|
|
369
|
+
let email: string;
|
|
370
|
+
try {
|
|
371
|
+
email = await fetchGoogleUserEmail(tokens.access_token);
|
|
372
|
+
} catch (error) {
|
|
375
373
|
throw new CliError('AUTH_FAILED', 'Could not fetch email from Calendar', 'Try again or specify --profile manually');
|
|
376
374
|
}
|
|
377
375
|
|
package/src/commands/gchat.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import { chat as gchat } from '@googleapis/chat';
|
|
3
3
|
import { readFile } from 'fs/promises';
|
|
4
4
|
import { setCredentials } from '../auth/token-store';
|
|
5
5
|
import { setProfile } from '../config/config-manager';
|
|
6
6
|
import { createProfileCommands } from '../utils/profile-commands';
|
|
7
7
|
import { createClientGetter } from '../utils/client-factory';
|
|
8
8
|
import { performOAuthFlow } from '../auth/oauth';
|
|
9
|
-
import { createGoogleAuth } from '../auth/token-manager';
|
|
9
|
+
import { createGoogleAuth, fetchGoogleUserEmail } from '../auth/token-manager';
|
|
10
10
|
import { GChatClient } from '../services/gchat/client';
|
|
11
11
|
import { CliError, handleError } from '../utils/errors';
|
|
12
12
|
import { readStdin, prompt } from '../utils/stdin';
|
|
@@ -286,12 +286,7 @@ async function setupOAuthProfile(profileNameOverride?: string, readOnly?: boolea
|
|
|
286
286
|
// Fetch user email for profile naming
|
|
287
287
|
let userEmail: string;
|
|
288
288
|
try {
|
|
289
|
-
|
|
290
|
-
const userInfo = await oauth2.userinfo.get();
|
|
291
|
-
userEmail = userInfo.data.email || '';
|
|
292
|
-
if (!userEmail) {
|
|
293
|
-
throw new Error('No email returned');
|
|
294
|
-
}
|
|
289
|
+
userEmail = await fetchGoogleUserEmail(tokens.access_token);
|
|
295
290
|
} catch (error) {
|
|
296
291
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
297
292
|
throw new CliError(
|
|
@@ -303,8 +298,8 @@ async function setupOAuthProfile(profileNameOverride?: string, readOnly?: boolea
|
|
|
303
298
|
|
|
304
299
|
// Validate the token works with Chat API
|
|
305
300
|
try {
|
|
306
|
-
const
|
|
307
|
-
await
|
|
301
|
+
const chatApi = gchat({ version: 'v1', auth: auth as any });
|
|
302
|
+
await chatApi.spaces.list({ pageSize: 1 });
|
|
308
303
|
} catch (error) {
|
|
309
304
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
310
305
|
throw new CliError(
|
package/src/commands/gdocs.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { writeFile } from 'fs/promises';
|
|
3
|
-
import {
|
|
4
|
-
import { createGoogleAuth } from '../auth/token-manager';
|
|
3
|
+
import { createGoogleAuth, fetchGoogleUserEmail } from '../auth/token-manager';
|
|
5
4
|
import { setCredentials } from '../auth/token-store';
|
|
6
5
|
import { setProfile } from '../config/config-manager';
|
|
7
6
|
import { createProfileCommands } from '../utils/profile-commands';
|
|
@@ -146,17 +145,11 @@ Query Syntax Examples:
|
|
|
146
145
|
console.error('Starting OAuth flow for Google Docs...\n');
|
|
147
146
|
|
|
148
147
|
const tokens = await performOAuthFlow('gdocs');
|
|
149
|
-
const auth = createGoogleAuth(tokens);
|
|
150
148
|
|
|
151
149
|
// Fetch user email for profile naming
|
|
152
150
|
let userEmail: string;
|
|
153
151
|
try {
|
|
154
|
-
|
|
155
|
-
const userInfo = await oauth2.userinfo.get();
|
|
156
|
-
userEmail = userInfo.data.email || '';
|
|
157
|
-
if (!userEmail) {
|
|
158
|
-
throw new Error('No email returned');
|
|
159
|
-
}
|
|
152
|
+
userEmail = await fetchGoogleUserEmail(tokens.access_token);
|
|
160
153
|
} catch (error) {
|
|
161
154
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
162
155
|
throw new CliError(
|
package/src/commands/gdrive.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
3
|
-
import { createGoogleAuth } from '../auth/token-manager';
|
|
2
|
+
import { createGoogleAuth, fetchGoogleUserEmail } from '../auth/token-manager';
|
|
4
3
|
import { setCredentials } from '../auth/token-store';
|
|
5
4
|
import { setProfile } from '../config/config-manager';
|
|
6
5
|
import { createProfileCommands } from '../utils/profile-commands';
|
|
@@ -246,16 +245,10 @@ Examples:
|
|
|
246
245
|
console.error(`\nStarting OAuth flow (${accessLevel} access)...\n`);
|
|
247
246
|
|
|
248
247
|
const tokens = await performOAuthFlow(oauthService);
|
|
249
|
-
const auth = createGoogleAuth(tokens);
|
|
250
248
|
|
|
251
249
|
let userEmail: string;
|
|
252
250
|
try {
|
|
253
|
-
|
|
254
|
-
const userInfo = await oauth2.userinfo.get();
|
|
255
|
-
userEmail = userInfo.data.email || '';
|
|
256
|
-
if (!userEmail) {
|
|
257
|
-
throw new Error('No email returned');
|
|
258
|
-
}
|
|
251
|
+
userEmail = await fetchGoogleUserEmail(tokens.access_token);
|
|
259
252
|
} catch (error) {
|
|
260
253
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
261
254
|
throw new CliError(
|
package/src/commands/gmail.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { basename, join } from 'path';
|
|
3
3
|
import { tmpdir } from 'os';
|
|
4
|
-
import {
|
|
5
|
-
import { getValidTokens, createGoogleAuth } from '../auth/token-manager';
|
|
4
|
+
import { getValidTokens, createGoogleAuth, fetchGoogleUserEmail } from '../auth/token-manager';
|
|
6
5
|
import { setCredentials } from '../auth/token-store';
|
|
7
6
|
import { setProfile } from '../config/config-manager';
|
|
8
7
|
import { createProfileCommands } from '../utils/profile-commands';
|
|
@@ -471,12 +470,10 @@ ${emailHeader}
|
|
|
471
470
|
const tokens = await performOAuthFlow('gmail');
|
|
472
471
|
|
|
473
472
|
// Fetch the user's email to store with the profile
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if (!email) {
|
|
473
|
+
let email: string;
|
|
474
|
+
try {
|
|
475
|
+
email = await fetchGoogleUserEmail(tokens.access_token);
|
|
476
|
+
} catch (error) {
|
|
480
477
|
throw new CliError('AUTH_FAILED', 'Could not fetch email from Gmail', 'Try again or specify --profile manually');
|
|
481
478
|
}
|
|
482
479
|
|
package/src/commands/gsheets.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { writeFile } from 'fs/promises';
|
|
3
|
-
import {
|
|
4
|
-
import { createGoogleAuth } from '../auth/token-manager';
|
|
3
|
+
import { createGoogleAuth, fetchGoogleUserEmail } from '../auth/token-manager';
|
|
5
4
|
import { setCredentials } from '../auth/token-store';
|
|
6
5
|
import { setProfile } from '../config/config-manager';
|
|
7
6
|
import { createProfileCommands } from '../utils/profile-commands';
|
|
@@ -332,17 +331,11 @@ Examples:
|
|
|
332
331
|
console.error('Starting OAuth flow for Google Sheets...\n');
|
|
333
332
|
|
|
334
333
|
const tokens = await performOAuthFlow('gsheets');
|
|
335
|
-
const auth = createGoogleAuth(tokens);
|
|
336
334
|
|
|
337
335
|
// Fetch user email for profile naming
|
|
338
336
|
let userEmail: string;
|
|
339
337
|
try {
|
|
340
|
-
|
|
341
|
-
const userInfo = await oauth2.userinfo.get();
|
|
342
|
-
userEmail = userInfo.data.email || '';
|
|
343
|
-
if (!userEmail) {
|
|
344
|
-
throw new Error('No email returned');
|
|
345
|
-
}
|
|
338
|
+
userEmail = await fetchGoogleUserEmail(tokens.access_token);
|
|
346
339
|
} catch (error) {
|
|
347
340
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
348
341
|
throw new CliError('AUTH_FAILED', `Failed to fetch user email: ${errorMessage}`, 'Ensure the account has an email address');
|
package/src/commands/gtasks.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
3
|
-
import { getValidTokens, createGoogleAuth } from '../auth/token-manager';
|
|
2
|
+
import { getValidTokens, createGoogleAuth, fetchGoogleUserEmail } from '../auth/token-manager';
|
|
4
3
|
import { setCredentials } from '../auth/token-store';
|
|
5
4
|
import { setProfile } from '../config/config-manager';
|
|
6
5
|
import { createProfileCommands } from '../utils/profile-commands';
|
|
@@ -313,13 +312,11 @@ export function registerGTasksCommands(program: Command): void {
|
|
|
313
312
|
|
|
314
313
|
const tokens = await performOAuthFlow('gtasks');
|
|
315
314
|
|
|
316
|
-
// Fetch user email
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (!email) {
|
|
315
|
+
// Fetch user email
|
|
316
|
+
let email: string;
|
|
317
|
+
try {
|
|
318
|
+
email = await fetchGoogleUserEmail(tokens.access_token);
|
|
319
|
+
} catch (error) {
|
|
323
320
|
throw new CliError('AUTH_FAILED', 'Could not fetch email', 'Try again or specify --profile manually');
|
|
324
321
|
}
|
|
325
322
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { calendar, type calendar_v3 } from '@googleapis/calendar';
|
|
2
2
|
import type { OAuth2Client } from 'google-auth-library';
|
|
3
3
|
import type {
|
|
4
4
|
GCalCalendar,
|
|
@@ -18,7 +18,7 @@ export class GCalClient implements ServiceClient {
|
|
|
18
18
|
private userEmail: string | null = null;
|
|
19
19
|
|
|
20
20
|
constructor(auth: OAuth2Client) {
|
|
21
|
-
this.calendar =
|
|
21
|
+
this.calendar = calendar({ version: 'v3', auth: auth as any });
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async validate(): Promise<ValidationResult> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { chat as gchat, type chat_v1 } from '@googleapis/chat';
|
|
2
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
3
3
|
import { CliError, httpStatusToErrorCode, type ErrorCode } from '../../utils/errors';
|
|
4
4
|
import type { ServiceClient, ValidationResult } from '../../types/service';
|
|
5
5
|
import { GOOGLE_OAUTH_CONFIG } from '../../config/credentials';
|
|
@@ -31,7 +31,7 @@ export class GChatClient implements ServiceClient {
|
|
|
31
31
|
try {
|
|
32
32
|
const oauthCreds = this.credentials as GChatOAuthCredentials;
|
|
33
33
|
const auth = this.createOAuthClient(oauthCreds);
|
|
34
|
-
const chat =
|
|
34
|
+
const chat = gchat({ version: 'v1', auth: auth as any });
|
|
35
35
|
await chat.spaces.list({ pageSize: 1 });
|
|
36
36
|
return { valid: true, info: 'oauth' };
|
|
37
37
|
} catch (error) {
|
|
@@ -161,7 +161,7 @@ export class GChatClient implements ServiceClient {
|
|
|
161
161
|
private async sendViaOAuth(options: GChatSendOptions & { spaceId?: string }): Promise<GChatSendResult> {
|
|
162
162
|
const oauthCreds = this.credentials as GChatOAuthCredentials;
|
|
163
163
|
const auth = this.createOAuthClient(oauthCreds);
|
|
164
|
-
const chat =
|
|
164
|
+
const chat = gchat({ version: 'v1', auth: auth as any });
|
|
165
165
|
|
|
166
166
|
if (!options.spaceId) {
|
|
167
167
|
throw new CliError(
|
|
@@ -202,7 +202,7 @@ export class GChatClient implements ServiceClient {
|
|
|
202
202
|
private async listViaOAuth(options: GChatListOptions): Promise<GChatMessage[]> {
|
|
203
203
|
const oauthCreds = this.credentials as GChatOAuthCredentials;
|
|
204
204
|
const auth = this.createOAuthClient(oauthCreds);
|
|
205
|
-
const chat =
|
|
205
|
+
const chat = gchat({ version: 'v1', auth: auth as any });
|
|
206
206
|
|
|
207
207
|
try {
|
|
208
208
|
// Build filter from options
|
|
@@ -258,7 +258,7 @@ export class GChatClient implements ServiceClient {
|
|
|
258
258
|
private async getViaOAuth(options: GChatGetOptions): Promise<GChatMessage> {
|
|
259
259
|
const oauthCreds = this.credentials as GChatOAuthCredentials;
|
|
260
260
|
const auth = this.createOAuthClient(oauthCreds);
|
|
261
|
-
const chat =
|
|
261
|
+
const chat = gchat({ version: 'v1', auth: auth as any });
|
|
262
262
|
|
|
263
263
|
try {
|
|
264
264
|
const response = await chat.spaces.messages.get({
|
|
@@ -303,7 +303,7 @@ export class GChatClient implements ServiceClient {
|
|
|
303
303
|
private async listSpacesViaOAuth(): Promise<GChatSpace[]> {
|
|
304
304
|
const oauthCreds = this.credentials as GChatOAuthCredentials;
|
|
305
305
|
const auth = this.createOAuthClient(oauthCreds);
|
|
306
|
-
const chat =
|
|
306
|
+
const chat = gchat({ version: 'v1', auth: auth as any });
|
|
307
307
|
|
|
308
308
|
try {
|
|
309
309
|
const response = await chat.spaces.list({});
|
|
@@ -353,7 +353,7 @@ export class GChatClient implements ServiceClient {
|
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
private createOAuthClient(credentials: GChatOAuthCredentials) {
|
|
356
|
-
const oauth2Client = new
|
|
356
|
+
const oauth2Client = new OAuth2Client(
|
|
357
357
|
GOOGLE_OAUTH_CONFIG.clientId,
|
|
358
358
|
GOOGLE_OAUTH_CONFIG.clientSecret
|
|
359
359
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'stream';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { drive, type drive_v3 } from '@googleapis/drive';
|
|
3
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
4
4
|
import { CliError, httpStatusToErrorCode, type ErrorCode } from '../../utils/errors';
|
|
5
5
|
import type { ServiceClient, ValidationResult } from '../../types/service';
|
|
6
6
|
import { GOOGLE_OAUTH_CONFIG } from '../../config/credentials';
|
|
@@ -13,7 +13,7 @@ export class GDocsClient implements ServiceClient {
|
|
|
13
13
|
constructor(credentials: GDocsCredentials) {
|
|
14
14
|
this.credentials = credentials;
|
|
15
15
|
const auth = this.createOAuthClient();
|
|
16
|
-
this.drive =
|
|
16
|
+
this.drive = drive({ version: 'v3', auth: auth as any });
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async validate(): Promise<ValidationResult> {
|
|
@@ -121,7 +121,7 @@ export class GDocsClient implements ServiceClient {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
private createOAuthClient() {
|
|
124
|
-
const oauth2Client = new
|
|
124
|
+
const oauth2Client = new OAuth2Client(
|
|
125
125
|
GOOGLE_OAUTH_CONFIG.clientId,
|
|
126
126
|
GOOGLE_OAUTH_CONFIG.clientSecret
|
|
127
127
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, writeFile, stat } from 'fs/promises';
|
|
2
2
|
import { basename } from 'path';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { drive, type drive_v3 } from '@googleapis/drive';
|
|
4
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
5
5
|
import { CliError, httpStatusToErrorCode, type ErrorCode } from '../../utils/errors';
|
|
6
6
|
import type { ServiceClient, ValidationResult } from '../../types/service';
|
|
7
7
|
import { GOOGLE_OAUTH_CONFIG } from '../../config/credentials';
|
|
@@ -97,7 +97,7 @@ export class GDriveClient implements ServiceClient {
|
|
|
97
97
|
constructor(credentials: GDriveCredentials) {
|
|
98
98
|
this.credentials = credentials;
|
|
99
99
|
const auth = this.createOAuthClient();
|
|
100
|
-
this.drive =
|
|
100
|
+
this.drive = drive({ version: 'v3', auth: auth as any });
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
async validate(): Promise<ValidationResult> {
|
|
@@ -375,7 +375,7 @@ export class GDriveClient implements ServiceClient {
|
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
private createOAuthClient() {
|
|
378
|
-
const oauth2Client = new
|
|
378
|
+
const oauth2Client = new OAuth2Client(
|
|
379
379
|
GOOGLE_OAUTH_CONFIG.clientId,
|
|
380
380
|
GOOGLE_OAUTH_CONFIG.clientSecret
|
|
381
381
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { gmail, type gmail_v1 } from '@googleapis/gmail';
|
|
2
2
|
import type { OAuth2Client } from 'google-auth-library';
|
|
3
3
|
import { basename } from 'path';
|
|
4
4
|
import type { GmailMessage, GmailListOptions, GmailSendOptions, GmailReplyOptions, GmailAttachment, GmailAttachmentInfo } from '../../types/gmail';
|
|
@@ -44,7 +44,7 @@ export class GmailClient implements ServiceClient {
|
|
|
44
44
|
private userEmail: string | null = null;
|
|
45
45
|
|
|
46
46
|
constructor(auth: OAuth2Client) {
|
|
47
|
-
this.gmail =
|
|
47
|
+
this.gmail = gmail({ version: 'v1', auth: auth as any });
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
async validate(): Promise<ValidationResult> {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { sheets, type sheets_v4 } from '@googleapis/sheets';
|
|
2
|
+
import { drive, type drive_v3 } from '@googleapis/drive';
|
|
3
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
3
4
|
import { CliError, httpStatusToErrorCode, type ErrorCode } from '../../utils/errors';
|
|
4
5
|
import type { ServiceClient, ValidationResult } from '../../types/service';
|
|
5
6
|
import { GOOGLE_OAUTH_CONFIG } from '../../config/credentials';
|
|
@@ -27,8 +28,8 @@ export class GSheetsClient implements ServiceClient {
|
|
|
27
28
|
constructor(credentials: GSheetsCredentials) {
|
|
28
29
|
this.credentials = credentials;
|
|
29
30
|
const auth = this.createOAuthClient();
|
|
30
|
-
this.sheets =
|
|
31
|
-
this.drive =
|
|
31
|
+
this.sheets = sheets({ version: 'v4', auth: auth as any });
|
|
32
|
+
this.drive = drive({ version: 'v3', auth: auth as any });
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
async validate(): Promise<ValidationResult> {
|
|
@@ -318,7 +319,7 @@ export class GSheetsClient implements ServiceClient {
|
|
|
318
319
|
}
|
|
319
320
|
|
|
320
321
|
private createOAuthClient() {
|
|
321
|
-
const oauth2Client = new
|
|
322
|
+
const oauth2Client = new OAuth2Client(
|
|
322
323
|
GOOGLE_OAUTH_CONFIG.clientId,
|
|
323
324
|
GOOGLE_OAUTH_CONFIG.clientSecret
|
|
324
325
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tasks, type tasks_v1 } from '@googleapis/tasks';
|
|
2
2
|
import type { OAuth2Client } from 'google-auth-library';
|
|
3
3
|
import type {
|
|
4
4
|
GTaskList,
|
|
@@ -15,7 +15,7 @@ export class GTasksClient implements ServiceClient {
|
|
|
15
15
|
private userEmail: string | null = null;
|
|
16
16
|
|
|
17
17
|
constructor(auth: OAuth2Client) {
|
|
18
|
-
this.tasks =
|
|
18
|
+
this.tasks = tasks({ version: 'v1', auth: auth as any });
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async validate(): Promise<ValidationResult> {
|