← Public packages
@kody/google
Call Gmail, Calendar, Tasks, Drive, Docs, Sheets, People, YouTube, and Analytics through saved Google OAuth.
src/index.ts
74 lines · 3.0 KB · TypeScriptexport * from './accounts.ts'
export * from './core.ts'
export * from './scopes.ts'
export * as calendar from './calendar.ts'
export * as drive from './drive.ts'
export * as gmail from './gmail.ts'
export * as people from './people.ts'
export * as tasks from './tasks.ts'
export * as docs from './docs.ts'
export * as sheets from './sheets.ts'
export * as youtube from './youtube.ts'
export * as youtubeAnalytics from './youtube-analytics.ts'
export * as analytics from './analytics.ts'
import { resolveGoogleAccount } from './accounts.ts'
import { getUserInfo } from './core.ts'
import type { GoogleAuthParams } from './accounts.ts'
import type { SmokeTestResult, UserInfo } from './types.ts'
/**
* Run a read-only OAuth smoke test that returns the signed-in Google profile.
* Defaults to the `google` integration.
* @example
* import { smokeTest } from 'kody:@kody/google'
* const result = await smokeTest()
* // => { integration: 'google', profile: { email: '...', name: '...', emailVerified: true } }
*/
export async function smokeTest(params: GoogleAuthParams = {}): Promise<SmokeTestResult> {
const account = resolveGoogleAccount(params)
const profile = (await getUserInfo({ integration: account.integrationName })) as UserInfo
return {
account: account.account,
integration: account.integrationName,
profile: { email: profile.email, name: profile.name, emailVerified: profile.email_verified },
}
}
/** Package overview: OAuth lanes, export map, and safety notes for Google product helpers. */
export default function googleProducts() {
return {
package: '@kody/google',
description:
'Google helpers for Gmail (including inbox), Calendar, Tasks, Drive, Docs, Sheets, People, YouTube, and Analytics.',
whenToUse:
'Use when a Kody workflow needs Google products. One package covers every Google surface; do not split Tasks or Gmail into other packages.',
auth: {
type: 'oauth',
defaultIntegration: 'google',
connect:
'Register a Google OAuth Web client and connect at /connect/oauth. Inbox and Drive-wide access need gmail.readonly / drive.readonly on that client.',
reconnect: 'https://kody.codes/connect/oauth?provider=google',
},
safety: [
'Mutations accept dryRun: true — preview before sending mail, writing calendar events, or changing Docs/Sheets/Tasks.',
'A 403 names the missing scope and the next setup step.',
'Do not hide inbox or Drive-wide exports; they stay here and need those scopes on the Google client you register.',
],
exports: {
accounts: 'kody:@kody/google/accounts',
core: 'kody:@kody/google/core',
gmail: 'kody:@kody/google/gmail',
calendar: 'kody:@kody/google/calendar',
tasks: 'kody:@kody/google/tasks',
drive: 'kody:@kody/google/drive',
docs: 'kody:@kody/google/docs',
sheets: 'kody:@kody/google/sheets',
people: 'kody:@kody/google/people',
youtube: 'kody:@kody/google/youtube',
youtubeAnalytics: 'kody:@kody/google/youtube-analytics',
analytics: 'kody:@kody/google/analytics',
smokeTest: 'kody:@kody/google/smoke-test',
types: 'kody:@kody/google/types',
},
}
}