breezi-shared
Version:
Shared types and utilities for Breezi SDK
63 lines • 2.05 kB
TypeScript
import { BreeziError, BreeziConfig } from './types';
/**
* Creates a standardized Breezi error with type information
*/
export declare const createBreeziError: (message: string, type: BreeziError["type"], code?: string, details?: any) => BreeziError;
/**
* Handles API response and converts to standardized format
*/
export declare const handleApiResponse: <T>(response: Response) => Promise<T>;
/**
* Gets the default API URL based on environment
*/
export declare const getDefaultApiUrl: (environment: string) => string;
/**
* Validates Breezi configuration
*/
export declare const validateConfig: (config: BreeziConfig) => void;
/**
* Validates payment amount and currency
*/
export declare const validatePayment: (amount: number, currency: string) => void;
/**
* Debounce function for API calls
*/
export declare const debounce: <T extends (...args: any[]) => any>(func: T, delay: number) => ((...args: Parameters<T>) => void);
/**
* Sleep utility for retries
*/
export declare const sleep: (ms: number) => Promise<void>;
/**
* Retry utility for API calls
*/
export declare const retry: <T>(fn: () => Promise<T>, maxRetries?: number, delay?: number) => Promise<T>;
/**
* Format currency amount for display
*/
export declare const formatCurrency: (amount: number, currency: string) => string;
/**
* Generate a unique ID for tracking
*/
export declare const generateId: () => string;
/**
* Check if we're running in a browser environment
*/
export declare const isBrowser: () => boolean;
/**
* Check if we're running in a Node.js environment
*/
export declare const isNode: () => boolean;
/**
* Safe JSON parse with error handling
*/
export declare const safeJsonParse: <T>(json: string, fallback: T) => T;
/**
* Logger utility with different levels
*/
export declare const logger: {
debug: (message: string, data?: any) => void;
info: (message: string, data?: any) => void;
warn: (message: string, data?: any) => void;
error: (message: string, error?: any) => void;
};
//# sourceMappingURL=utils.d.ts.map