import { SheetClient } from './sheetClient'; import { CRUDOperations } from './crud'; import type { DatabaseAdapter } from './types'; import { TableSchema, UserContext, SchemaMismatchBehaviour, ActorPermission, DriveFolderConfig, TokenStore, StorageAdapter, UploadOptions, CreateUserSheetOptions, SheetStyleConfig, SheetReadCacheConfig } from '../schema/types'; export interface SheetAdapterConfig { adminSheetId: string; credentials: { clientId: string; clientSecret: string; redirectUri: string; }; tokens: unknown; onSchemaMismatch?: SchemaMismatchBehaviour; permissions?: Record; /** Place sheets in this Drive folder hierarchy. */ driveFolder?: DriveFolderConfig; /** When set, all Drive file operations target this Shared Drive. */ sharedDriveId?: string; /** Per-actor token store. Adapter calls get(userId) in createUserSheet when actorTokens not passed directly. */ tokenStore?: TokenStore; /** File upload provider. Pass new DriveStorageAdapter() for built-in Drive upload. */ storage?: StorageAdapter; /** Header fill color, frozen rows/columns. Auto-resize and boolean/enum dropdowns are always applied. */ sheetStyle?: SheetStyleConfig; /** In-memory read cache for values.get() calls — smooths out Sheets API read-quota (429) errors. Enabled by default with a 2s TTL. */ cache?: SheetReadCacheConfig; } export declare class SheetAdapter implements DatabaseAdapter { private client; private credentials; private adminSheetId; private schemas; private context?; private onSchemaMismatch?; private permissions?; private driveFolder?; private sharedDriveId?; private tokenStore?; private storage?; private sheetStyle; private cacheConfig?; /** Cached Drive folder IDs: role -> folderId */ private _folderCache; /** Pending schema version check promise set by withContext() */ private _pendingSchemaCheck?; constructor(config: SheetAdapterConfig); registerSchema(schema: TableSchema): void; registerSchemas(schemas: TableSchema[]): void; withContext(context: UserContext): SheetAdapter; asActor(targetActor: string, targetSheetId: string): SheetAdapter; table(tableName: string): CRUDOperations; createUserSheet(userId: string, role: string, email: string, options?: CreateUserSheetOptions): Promise; /** * The current withContext() actor, forwarded to the storage adapter so a file upload/delete can * follow the same per-actor Drive placement as that actor's sheet (see driveTenancy.ts). undefined * when called without withContext() — the storage adapter falls back to its pre-Phase-23 flat, * single-Drive behavior in that case. */ private currentActorContext; upload(file: Buffer, options: UploadOptions): Promise; deleteFile(url: string): Promise; syncSchema(schema: TableSchema): Promise; upsertSchemaVersion(actorSheetId: string, tableName: string, schemaHash: string, columnCount: number): Promise; getSchemaVersion(actorSheetId: string, tableName: string): Promise<{ schema_hash: string; synced_at: string; column_count: number; } | null>; private _applySheetFormatting; private _svCrud; private _ensureSchemaVersionsSheet; private _doSchemaVersionCheck; private resolveFolderForRole; private createFKResolver; private detectCircularRefs; private resolveSpreadsheetId; private hasPermission; private sheetExists; getClient(): SheetClient; } export declare function createSheetAdapter(config: SheetAdapterConfig): SheetAdapter; //# sourceMappingURL=sheetAdapter.d.ts.map