import { QueryClient } from '@tanstack/react-query'; import { QueryParams } from '../types'; interface FastfoldClientConfig { baseUrl: string; headers?: Record; logging?: { enabled: boolean; logEndpoint?: string; }; } /** * Configure the Fastfold client */ export declare function configureFastfold(config: Partial): void; /** * Forward errors to parent window for development debugging */ export declare function forwardErrorToParent(category: 'network' | 'react' | 'js', error: any, errorInfo?: any): void; /** * Generate consistent query keys for React Query */ export declare const queryKeys: { all: (tableName: string) => readonly [string]; lists: (tableName: string) => readonly [string, "list"]; list: (tableName: string, params: QueryParams) => readonly [string, "list", QueryParams]; details: (tableName: string) => readonly [string, "detail"]; detail: (tableName: string, id: string | number) => readonly [string, "detail", string | number]; }; interface UseQueryOptions { enabled?: boolean; staleTime?: number; cacheTime?: number; refetchOnWindowFocus?: boolean; refetchInterval?: number; } /** * 📋 QUERY HOOK - Fetch multiple records with React Query * * @param tableName The table to query * @param params Query parameters (where, orderBy, limit, with, etc.) * @param options React Query options * * @example * const { data: posts, isLoading, error } = useQuery('posts', { * where: { published: true }, * with: { author: true } * }); */ export declare function useFastfoldQuery(tableName: string, params?: QueryParams, options?: UseQueryOptions): import("@tanstack/react-query").UseQueryResult; /** * 🎯 QUERY ONE HOOK - Fetch single record by ID with React Query * * @param tableName The table to query * @param id The record ID * @param params Additional query parameters (with, etc.) * @param options React Query options * * @example * const { data: post } = useQueryOne('posts', '123', { * with: { author: true, comments: true } * }); */ export declare function useFastfoldQueryOne(tableName: string, id: string | number, params?: Omit, options?: UseQueryOptions): import("@tanstack/react-query").UseQueryResult, Error>; interface UseMutationOptions { onSuccess?: (data: TData, variables: TVariables) => void; onError?: (error: Error, variables: TVariables) => void; onSettled?: (data: TData | undefined, error: Error | null, variables: TVariables) => void; /** Optimistic updates: apply cache changes immediately and rollback on error. Default true for useUpdate/useDelete. Pass false to wait for server before updating UI. */ optimistic?: boolean; invalidateQueries?: boolean; updateCache?: (data: TData, variables: TVariables, queryClient: QueryClient) => void; } type OptimisticRollbackContext = { listSnapshots: [unknown[], unknown][]; detailSnapshot: unknown; }; /** * ✏️ CREATE HOOK - Create new records with automatic cache invalidation * * @param tableName The table to create records in * @param options Mutation options * * @example * const createPost = useCreate('posts', { * onSuccess: (newPost) => console.log('Created:', newPost) * }); * * await createPost.mutateAsync({ title: 'Hello', content: 'World' }); */ export declare function useFastfoldCreate(tableName: string, options?: UseMutationOptions): import("@tanstack/react-query").UseMutationResult; /** * 🔄 UPDATE HOOK - Update existing records with automatic cache invalidation * * @param tableName The table to update records in * @param options Mutation options * * @example * const updatePost = useUpdate('posts', { * onSuccess: (updatedPost) => console.log('Updated:', updatedPost) * }); * * await updatePost.mutateAsync({ id: '123', data: { title: 'New Title' } }); */ export declare function useFastfoldUpdate(tableName: string, options?: UseMutationOptions): import("@tanstack/react-query").UseMutationResult; /** * 🗑️ DELETE HOOK - Delete records with automatic cache invalidation * * @param tableName The table to delete records from * @param options Mutation options * * @example * const deletePost = useDelete('posts', { * onSuccess: () => console.log('Deleted successfully') * }); * * await deletePost.mutateAsync('123'); */ export declare function useFastfoldDelete(tableName: string, options?: UseMutationOptions): import("@tanstack/react-query").UseMutationResult; export declare const useQuery: typeof useFastfoldQuery; export declare const useQueryOne: typeof useFastfoldQueryOne; export declare const useCreate: typeof useFastfoldCreate; export declare const useUpdate: typeof useFastfoldUpdate; export declare const useDelete: typeof useFastfoldDelete; /** * 🔄 INVALIDATE CACHE - Manually invalidate queries * * @example * const invalidate = useInvalidateCache(); * invalidate.table('posts'); // Invalidate all posts queries * invalidate.record('posts', '123'); // Invalidate specific post */ export declare function useInvalidateCache(): { table: (tableName: string) => void; lists: (tableName: string) => void; record: (tableName: string, id: string | number) => void; all: () => void; }; /** * 📝 UPDATE CACHE - Manually update cached data * * @example * const updateCache = useUpdateCache(); * updateCache.record('posts', '123', updatedPost); * updateCache.addToList('posts', {}, newPost); */ export declare function useUpdateCache(): { record: (tableName: string, id: string | number, data: T) => void; addToList: (tableName: string, params: QueryParams, newItem: T) => void; removeFromList: (tableName: string, params: QueryParams, id: string | number) => void; updateInList: (tableName: string, params: QueryParams, id: string | number, data: T) => void; }; export { FastfoldProvider, createFastfoldQueryClient } from './provider'; export * from '../types'; //# sourceMappingURL=react-query.d.ts.map