UNPKG

livesheets-sdk

Version:

LiveSheets SDK for Google Sheets integration with Lovable apps. OAuth onboarding URL: https://livesheets-backend-624058308714.europe-north1.run.app/onboarding

102 lines (101 loc) 2.59 kB
export interface SheetRow { [key: string]: any; } export interface SheetSchema { name: string; type: string; } export interface SheetMetadata { spreadsheetId: string; sheetName: string; rowCount: number; columnCount: number; } export interface AuthConfig { backendUrl?: string; storageKey?: string; userIdKey?: string; } export interface SheetPickerConfig { jwt: string; onSuccess?: (result: { spreadsheetId: string; sheetName: string; }) => void; onCancel?: () => void; width?: number; height?: number; } /** * LiveSheetsAuth - Helper class for OAuth authentication */ export declare class LiveSheetsAuth { private static readonly DEFAULT_BACKEND_URL; private static readonly DEFAULT_JWT_KEY; private static readonly DEFAULT_USER_KEY; private backendUrl; private jwtKey; private userIdKey; constructor(config?: AuthConfig); /** * Start OAuth flow * @param returnUrl - Optional return URL after OAuth completion */ startOAuth(returnUrl?: string): void; /** * Get JWT from storage or URL hash */ getJWT(): string | null; /** * Check if user is authenticated */ isAuthenticated(): boolean; /** * Clear authentication data */ logout(): void; /** * Get or generate user ID */ private getUserId; } /** * LiveSheetsClient SDK * * Example usage: * * import { LiveSheetsClient } from "livesheets-sdk"; * const client = new LiveSheetsClient("<your_jwt>"); * const rows = await client.listRows(); * const schema = await client.getSchema(); * const metadata = await client.getMetadata(); */ export declare class LiveSheetsClient { private baseUrl; private jwt; private static auth; constructor(jwt?: string | null, baseUrl?: string); /** * Get or create auth helper instance */ static getAuth(config?: AuthConfig): LiveSheetsAuth; /** * Open sheet picker in popup window */ static openSheetPicker(config: SheetPickerConfig): Promise<void>; private request; listRows(): Promise<SheetRow[]>; getSchema(): Promise<SheetSchema[]>; getMetadata(): Promise<SheetMetadata>; } export declare function readSheet(jwtOrParams?: string | { jwt?: string; sheetId?: string; sheet?: string; }, sheetIdOrOptions?: string | { sheetId?: string; sheet?: string; }): Promise<SheetRow[]>; export declare const auth: LiveSheetsAuth; export { LiveSheetsClient as livesheets }; export default LiveSheetsClient;