import { createAuthenticatedFetch } from 'kody:runtime' import { type GoogleAccountInfo, resolveGoogleAccount, } from './accounts.ts' /** * Literal-name authenticated fetch for a resolved Google account alias. * Publish stamps each `createAuthenticatedFetch("…")` call site. */ export async function createGoogleAuthenticatedFetch( account: GoogleAccountInfo | string | { account?: string }, ): Promise { const resolved = typeof account === 'object' && account !== null && 'integrationName' in account && 'account' in account ? (account as GoogleAccountInfo) : resolveGoogleAccount(account) switch (resolved.account) { case 'personal': return await createAuthenticatedFetch('google') case 'business': return await createAuthenticatedFetch('google-business') case 'youtube-brand': return await createAuthenticatedFetch('google-youtube-brand') case 'youtube-plus': return await createAuthenticatedFetch('google-youtube-plus') default: { const exhaustive: never = resolved.account throw new Error(`Unhandled Google account: ${String(exhaustive)}`) } } }