UNPKG

@dbs-portal/core-api

Version:

HTTP client and API utilities for DBS Portal

93 lines 3.66 kB
/** * TanStack Query client configuration and setup */ import { QueryClient, type QueryClientConfig } from '@tanstack/react-query'; import type { ApiClient } from '../client/api-client'; /** * Create a configured QueryClient instance */ export declare function createQueryClient(apiClient?: ApiClient, config?: QueryClientConfig): QueryClient; /** * Default query client instance */ export declare const queryClient: QueryClient; /** * Query key factory for consistent key generation */ export declare const queryKeys: { all: readonly ["api"]; users: () => readonly ["api", "users"]; user: (id: string) => readonly ["api", "users", string]; userProfile: (id: string) => readonly ["api", "users", string, "profile"]; posts: () => readonly ["api", "posts"]; post: (id: string) => readonly ["api", "posts", string]; postComments: (id: string) => readonly ["api", "posts", string, "comments"]; search: (query: string) => readonly ["api", "search", string]; filtered: (resource: string, filters: Record<string, any>) => readonly ["api", string, "filtered", Record<string, any>]; paginated: (resource: string, page: number, limit: number) => readonly ["api", string, "paginated", { readonly page: number; readonly limit: number; }]; infinite: (resource: string, filters?: Record<string, any>) => readonly ["api", string, "infinite", Record<string, any> | undefined]; custom: (key: string, ...params: any[]) => readonly ["api", string, ...any[]]; }; /** * Query options factory for common patterns */ export declare const queryOptions: { standard: <T>(key: readonly unknown[], fetcher: () => Promise<T>) => { queryKey: readonly unknown[]; queryFn: () => Promise<T>; staleTime: number; gcTime: number; }; realtime: <T>(key: readonly unknown[], fetcher: () => Promise<T>) => { queryKey: readonly unknown[]; queryFn: () => Promise<T>; staleTime: number; gcTime: number; refetchInterval: number; }; static: <T>(key: readonly unknown[], fetcher: () => Promise<T>) => { queryKey: readonly unknown[]; queryFn: () => Promise<T>; staleTime: number; gcTime: number; }; user: <T>(key: readonly unknown[], fetcher: () => Promise<T>) => { queryKey: readonly unknown[]; queryFn: () => Promise<T>; staleTime: number; gcTime: number; }; background: <T>(key: readonly unknown[], fetcher: () => Promise<T>) => { queryKey: readonly unknown[]; queryFn: () => Promise<T>; staleTime: number; gcTime: number; refetchOnWindowFocus: boolean; refetchOnReconnect: boolean; }; }; /** * Mutation options factory */ export declare const mutationOptions: { standard: <TData, TVariables>(mutationFn: (variables: TVariables) => Promise<TData>) => { mutationFn: (variables: TVariables) => Promise<TData>; retry: number; retryDelay: number; }; optimistic: <TData, TVariables>(mutationFn: (variables: TVariables) => Promise<TData>, optimisticUpdate?: (variables: TVariables) => TData) => { onMutate?: (variables: TVariables) => TData; mutationFn: (variables: TVariables) => Promise<TData>; retry: number; retryDelay: number; }; critical: <TData, TVariables>(mutationFn: (variables: TVariables) => Promise<TData>) => { mutationFn: (variables: TVariables) => Promise<TData>; retry: (failureCount: number, error: any) => boolean; retryDelay: number; }; }; //# sourceMappingURL=query-client.d.ts.map