import { AxiError } from "axi-sdk-js"; import { type calendar_v3, type docs_v1, type drive_v3, type gmail_v1, type sheets_v4, type slides_v1 } from "googleapis"; import { OAuth2Client } from "google-auth-library"; /** * Build an OAuth2Client seeded with the stored tokens for `email`. Uses * google-auth-library's refresh mechanism via the refresh_token so the * client auto-refreshes mid-request if the access token hits 401. We also * set expiry_date so the library proactively refreshes before 401s. */ export declare function oauthClientForAccount(email: string): Promise; export declare function calendarClient(email: string): Promise; export declare function gmailClient(email: string): Promise; export declare function docsClient(email: string): Promise; export declare function driveClient(email: string): Promise; export declare function slidesClient(email: string): Promise; export declare function sheetsClient(email: string): Promise; /** * Translate a Google API error into an AxiError with actionable suggestions. * Caller context (account, operation name) improves the suggestions. */ export declare function translateGoogleError(err: unknown, context: { account: string; operation: string; }): AxiError; /** * Convenience wrapper: run a Google API call for `email` and translate any * thrown error. Callers pass the operation name (e.g. "calendar.events.list") * so error messages are specific. */ export declare function runGoogleApi(email: string, operation: string, fn: (auth: OAuth2Client) => Promise): Promise; /** * Retry a function that may hit Gmail/Drive rate limits. Naive fixed * backoff: wait 1s, 2s, then 4s before giving up. Only retries on * RATE_LIMITED (HTTP 429) — 5xx and other transient errors aren't * retried here because the right behavior varies per operation. * * Errors from `fn` are expected to be raw Google API errors (not yet * translated). Final errors are always returned translated so callers * can handle them uniformly. */ export declare function withRateLimitRetry(context: { account: string; operation: string; }, fn: () => Promise): Promise;