UNPKG

@srfoster/one-backend-react

Version:

React components and hooks for One Backend authentication and data management

44 lines (43 loc) 1.93 kB
import { OneBackendConfig, LoginCredentials, RegisterData, AuthTokens, ApiResponse, DataRecord, PaginatedResponse, CreateRecordRequest, UpdateRecordRequest, FileUploadResponse, User } from '../types'; export declare class OneBackendClient { private api; private config; private token; private static readonly API_URL; constructor(config: OneBackendConfig); setToken(token: string | null): void; getToken(): string | null; private decodeJWT; private isTokenExpired; getCurrentUser(): User | null; register(data: RegisterData): Promise<ApiResponse<AuthTokens>>; login(credentials: Omit<LoginCredentials, 'appId'>): Promise<ApiResponse<AuthTokens>>; logout(): Promise<ApiResponse>; refreshToken(): Promise<ApiResponse<AuthTokens>>; getRecords(resourceType: string, options?: { page?: number; limit?: number; filters?: Record<string, any>; }): Promise<ApiResponse<PaginatedResponse<DataRecord>>>; getRecord(resourceType: string, id: string): Promise<ApiResponse<DataRecord>>; createRecord(resourceType: string, request: CreateRecordRequest): Promise<ApiResponse<DataRecord>>; updateRecord(resourceType: string, id: string, request: UpdateRecordRequest): Promise<ApiResponse<DataRecord>>; deleteRecord(resourceType: string, id: string): Promise<ApiResponse>; deleteRecords(resourceType: string, ids: string[]): Promise<ApiResponse<{ deleted: number; failed: number; details: { deletedIds: string[]; failedIds: string[]; }; }>>; getUploadUrl(fileName: string, fileType: string): Promise<ApiResponse<FileUploadResponse>>; getDownloadUrl(fileId: string): Promise<ApiResponse<{ downloadUrl: string; }>>; deleteFile(fileId: string): Promise<ApiResponse>; uploadFile(file: File): Promise<{ fileId: string; key: string; }>; }