Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kentcdodds/google

src/index.ts

58 lines · 2.3 KB · TypeScript
export * from './accounts.ts'
export * from './core.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 youtube from './youtube.ts'
export * as youtubeAnalytics from './youtube-analytics.ts'
export * as youtubeChannels from './youtube-channels.ts'
import { listGoogleAccounts } from './accounts.ts'
import { getUserInfo } from './core.ts'
import type { SmokeTestResult, UserInfo } from './types.ts'

/**
 * Run a read-only OAuth smoke test that returns the signed-in Google profile for an account alias.
 * @example
 * import { smokeTest } from 'kody:@kentcdodds/google'
 * const result = await smokeTest({ account: 'personal' })
 * // => { account: 'personal', profile: { email: '...', name: '...', emailVerified: true } }
 */
export async function smokeTest(params: { account: string }): Promise<SmokeTestResult> {
	const profile = (await getUserInfo(params)) as UserInfo
	return {
		account: params.account,
		profile: { email: profile.email, name: profile.name, emailVerified: profile.email_verified },
	}
}

/** Package overview: account aliases, export map, and safety notes for Google product helpers. */
export default function googleProducts() {
	return {
		package: '@kentcdodds/google',
		description:
			'Account-aware Google helpers for Gmail, Calendar, Drive, People, YouTube, and YouTube Analytics.',
		whenToUse:
			'Use when a Kody workflow needs Google products and must choose the correct Google account explicitly.',
		accounts: listGoogleAccounts(),
		safety: [
			'Pass account explicitly.',
			'Use dryRun before Gmail or Calendar mutations.',
			'Use dryRun before YouTube uploads or status updates when validating inputs.',
			'Prefer product helpers over raw OAuth/fetch code.',
			'Treat 403 errors as possible scope/API setup issues.',
		],
		exports: {
			accounts: 'kody:@kentcdodds/google/accounts',
			core: 'kody:@kentcdodds/google/core',
			gmail: 'kody:@kentcdodds/google/gmail',
			calendar: 'kody:@kentcdodds/google/calendar',
			drive: 'kody:@kentcdodds/google/drive',
			people: 'kody:@kentcdodds/google/people',
			youtube: 'kody:@kentcdodds/google/youtube',
			youtubeAnalytics: 'kody:@kentcdodds/google/youtube-analytics',
			youtubeChannels: 'kody:@kentcdodds/google/youtube-channels',
			types: 'kody:@kentcdodds/google/types',
		},
	}
}