Files
skybridge/web-components/dist/hooks/useApiService.d.ts
2025-08-31 23:27:52 -04:00

26 lines
826 B
TypeScript

import { AxiosInstance } from 'axios';
import { FilterOptions } from '../types';
export interface ApiServiceConfig {
baseURL: string;
defaultHeaders?: Record<string, string>;
timeout?: number;
}
export interface UseApiServiceReturn<T> {
data: T[];
loading: boolean;
error: string | null;
total: number;
hasMore: boolean;
client: AxiosInstance;
getAll: (filters?: FilterOptions) => Promise<T[]>;
getById: (id: string) => Promise<T>;
create: (data: Partial<T>) => Promise<T>;
update: (id: string, data: Partial<T>) => Promise<T>;
delete: (id: string) => Promise<void>;
clearError: () => void;
refresh: () => Promise<void>;
}
export declare const useApiService: <T extends {
id: string;
}>(config: ApiServiceConfig, endpoint: string) => UseApiServiceReturn<T>;