import { Databases } from 'appwrite'; import { DatabaseSchema } from './types'; type InferFieldType = T extends { type: infer U; required: true; } ? U extends 'string' ? string : U extends 'number' ? number : U extends 'boolean' ? boolean : U extends 'Date' ? Date : U extends string[] ? U[number] : unknown : T extends { type: infer U; } ? U extends 'string' ? string | undefined : U extends 'number' ? number | undefined : U extends 'boolean' ? boolean | undefined : U extends 'Date' ? Date | undefined : U extends string[] ? U[number] | undefined : unknown : unknown; export type SchemaToType = { [K in keyof T]: InferFieldType; } & { $id: string; }; export interface QueryOptions { limit?: number; offset?: number; orderBy?: string[]; select?: string[]; } export interface FilterOptions { [key: string]: unknown; } export declare abstract class BaseTable> { protected databases: Databases; protected databaseId: string; protected collectionId: string; protected schema: T; protected client?: any; protected config?: any; private cache; private updated; private realtimeUnsubscribe?; private manualListeners; private messages; constructor(databases: Databases, databaseId: string, collectionId: string, schema: T, client?: any, config?: any); /** * Get a single document by ID (similar to SQLAlchemy's get) */ get(id: string): Promise; /** * Get a single document by ID, throw error if not found (similar to SQLAlchemy's get_or_404) */ getOrFail(id: string): Promise; /** * Query documents with filters (similar to SQLAlchemy's filter) */ query(filters?: FilterOptions, options?: QueryOptions): Promise; /** * Get all documents (similar to SQLAlchemy's all()) */ all(options?: QueryOptions): Promise; /** * Get first document matching filters (similar to SQLAlchemy's first()) */ first(filters?: FilterOptions): Promise; /** * Get first document or fail (similar to SQLAlchemy's first_or_404()) */ firstOrFail(filters?: FilterOptions): Promise; /** * Count documents matching filters (similar to SQLAlchemy's count()) */ count(filters?: FilterOptions): Promise; /** * Create a new document (similar to SQLAlchemy's create) */ create(data: Partial, '$id'>>): Promise; /** * Update a document by ID */ update(id: string, data: Partial, '$id'>>): Promise; /** * Delete a document by ID */ delete(id: string): Promise; /** * Find documents with more complex queries */ find(queries: string[]): Promise; /** * Find one document with complex queries */ findOne(queries: string[]): Promise; /** * Set up automatic realtime tracking for cache invalidation */ private setupRealtimeTracking; /** * Handle realtime events for cache invalidation */ private handleRealtimeEvent; /** * Generate a cache key for a query */ private generateCacheKey; /** * Get data from cache if available and valid */ private getFromCache; /** * Store data in cache */ private setCache; /** * Clear all cache entries */ private clearCache; /** * Get the current updated status */ isUpdated(): boolean; /** Return collected internal messages (warnings, diagnostics) */ getMessages(): string[]; /** * Manually mark data as updated or not updated */ setUpdated(updated: boolean): void; /** * Listen to realtime events for this collection * @param channel - The channel to listen to (e.g., 'documents', 'documents.{documentId}') * @param onEvent - Callback function to handle events * @returns A function to unsubscribe from the channel */ listen(channel: string, onEvent: (event: any) => void): () => void; /** * Listen to all document events in this collection * @param onEvent - Callback function to handle events * @returns A function to unsubscribe from the channel */ listenToDocuments(onEvent: (event: any) => void): () => void; /** * Listen to events for a specific document in this collection * @param documentId - The ID of the document to listen to * @param onEvent - Callback function to handle events * @returns A function to unsubscribe from the channel */ listenToDocument(documentId: string, onEvent: (event: any) => void): () => void; /** * Listen to database-level events * @param onEvent - Callback function to handle events * @returns A function to unsubscribe from the channel */ listenToDatabase(onEvent: (event: any) => void): () => void; /** * Listen to collection-level events * @param onEvent - Callback function to handle events * @returns A function to unsubscribe from the channel */ listenToCollection(onEvent: (event: any) => void): () => void; /** * Close all manual listeners (for cleanup in tests) */ closeListeners(): void; /** * Clean up realtime subscriptions */ destroy(): void; /** * Validate data against schema */ protected validateData(data: Record, requireAll?: boolean): void; } export {}; //# sourceMappingURL=table.d.ts.map