/** * Configuration options for the B44 client */ interface ClientConfig { /** * Base URL of the B44 server * @default "https://b44.app" */ serverUrl?: string; /** * Application ID for the B44 app */ appId: string | number; /** * Environment to use * @default "prod" */ env?: "prod" | "dev"; /** * Authentication token */ token?: string; /** * Whether authentication is required * @default false */ requiresAuth?: boolean; /** * Optional API key for app-level authentication */ apiKey?: string; } /** * Base entity interface */ interface Entity { /** * Unique identifier for the entity */ id: string; /** * Additional properties */ [key: string]: any; } /** * Methods available for entity operations */ interface EntityMethods { /** * List entities with optional sorting, pagination, and field selection * @param sort Optional sorting parameter * @param limit Optional limit for pagination * @param skip Optional skip for pagination * @param fields Optional fields to include */ list(sort?: string, limit?: number, skip?: number, fields?: string[] | string): Promise; /** * Filter entities by query with optional sorting, pagination, and field selection * @param query Filter query * @param sort Optional sorting parameter * @param limit Optional limit for pagination * @param skip Optional skip for pagination * @param fields Optional fields to include */ filter(query: any, sort?: string, limit?: number, skip?: number, fields?: string[] | string): Promise; /** * Get a single entity by ID * @param id Entity ID */ get(id: string): Promise; /** * Create a new entity * @param data Entity data */ create(data: Record): Promise; /** * Update an existing entity * @param id Entity ID * @param data Updated entity data */ update(id: string, data: Record): Promise; /** * Delete an entity * @param id Entity ID */ delete(id: string): Promise; /** * Delete multiple entities matching a query * @param query Filter query for entities to delete */ deleteMany(query: Record): Promise; /** * Create multiple entities in a single operation * @param data Array of entity data */ bulkCreate(data: Record[]): Promise; /** * Import entities from a file * @param file File containing entity data */ importEntities(file: File): Promise; } /** * Module for accessing entities */ interface EntitiesModule { /** * Dynamic access to entity methods by entity name */ [entityName: string]: EntityMethods; } /** * Authentication module interface */ interface AuthModule { /** * Get the current authenticated user * @returns Promise resolving to the user entity */ me(): Promise; /** * Update the current authenticated user * @param data Updated user data * @returns Promise resolving to the updated user entity */ updateMe(data: Record): Promise; /** * Redirect to the login page * @param nextUrl Optional URL to redirect to after successful login */ login(nextUrl?: string): void; /** * Log out the current user * @param redirectUrl Optional URL to redirect to after logout * @returns Promise that resolves when logout is complete */ logout(redirectUrl?: string): Promise; /** * Set the authentication token * @param token Authentication token * @param saveToStorage Whether to save the token to localStorage */ setToken(token: string, saveToStorage?: boolean): void; /** * Check if the user is authenticated * @returns Promise resolving to authentication status */ isAuthenticated(): Promise; } /** * Options for token management */ interface TokenOptions { /** * Key to use for storing the token in localStorage * @default "b44_access_token" */ storageKey?: string; /** * Parameter name to look for in URL * @default "access_token" */ paramName?: string; /** * Whether to save the token to localStorage * @default true */ saveToStorage?: boolean; /** * Whether to remove the token from URL after retrieval * @default true */ removeFromUrl?: boolean; } /** * Options for constructing a login URL */ interface LoginUrlOptions { /** * Base URL of the server */ serverUrl: string; /** * Application ID */ appId: string | number; /** * Path to the login endpoint * @default "/login" */ loginPath?: string; } /** * Main client interface */ interface B44Client { /** * Entities module for accessing entity operations */ entities: EntitiesModule; /** * Authentication module for user authentication */ auth: AuthModule; /** * Set the authentication token * @param token Authentication token */ setToken(token: string): void; /** * Get the current client configuration * @returns Client configuration */ getConfig(): ClientConfig; integrations: { Core: any; InvokeLLM: any; SendEmail: any; SendSMS: any; UploadFile: any; GenerateImage: any; ExtractDataFromUploadedFile: any; }; } /** * Create a B44 client instance * @param config Client configuration * @returns B44 client */ declare function createClient(config: ClientConfig): B44Client; /** * Custom error class for B44 SDK */ declare class B44Error extends Error { /** * HTTP status code */ status?: number; /** * Error code */ code?: string; /** * Additional error data */ data?: any; /** * Original error that caused this error */ originalError?: Error; /** * Create a new B44Error * @param message Error message * @param status HTTP status code * @param code Error code * @param data Additional error data * @param originalError Original error that caused this error */ constructor(message: string, status?: number, code?: string, data?: any, originalError?: Error); /** * Convert the error to a JSON object * @returns JSON representation of the error */ toJSON(): { name: string; message: string; status: number | undefined; code: string | undefined; data: any; }; } /** * Get the access token from URL parameters or localStorage * @param options Token options * @returns Access token or null if not found */ declare function getAccessToken(options?: TokenOptions): string | null; /** * Save the access token to localStorage * @param token Access token * @param options Token options * @returns Whether the token was successfully saved */ declare function saveAccessToken(token: string, options?: TokenOptions): boolean; /** * Remove the access token from localStorage * @param options Token options * @returns Whether the token was successfully removed */ declare function removeAccessToken(options?: TokenOptions): boolean; /** * Get the login URL for the specified return URL and configuration * @param returnUrl URL to return to after login * @param options Login URL options * @returns Login URL */ declare function getLoginUrl(returnUrl: string | undefined, options: LoginUrlOptions): string; export { B44Error, createClient, getAccessToken, getLoginUrl, removeAccessToken, saveAccessToken }; export type { AuthModule, B44Client, ClientConfig, EntitiesModule, Entity, EntityMethods, LoginUrlOptions, TokenOptions };