@olakai/sdk
Version:
This document demonstrates how to use the Olakai SDK with all its features.
48 lines • 1.82 kB
TypeScript
import type { SDKConfig, MonitorPayload, ControlPayload, ControlAPIResponse } from "./types";
/**
* Initialize the SDK
* @param apiKey - The API key
* @param domainUrl - The domain URL
* @param options - The extra options for the SDKConfig
* @default options - {
* enableBatching: false,
* batchSize: 10,
* batchTime: 300,
* retries: 4,
* timeout: 30000,
* enableStorage: false,
* storageType: StorageType.AUTO,
* debug: false,
* verbose: false,
* storageKey: "olakai-sdk-queue",
* maxStorageSize: 1000000,
* sanitizePatterns: [],
* version: packageJson.version,
* }
* @throws {URLConfigurationError} if the API URL is not set
* @throws {APIKeyMissingError} if the API key is not set
*/
export declare function initClient(apiKey: string, domainUrl: string, options?: Partial<SDKConfig>): Promise<void>;
/**
* Get the current configuration
* @returns The current configuration
* @throws {ConfigNotInitializedError} if the config is not initialized
*/
export declare function getConfig(): SDKConfig;
/**
* Send a payload to the API
* Adds the payload to the queue and processes it
* Persists queue to localStorage (for offline support)
* Schedules batch processing for normal requests
* Processes immediately for high priority requests
* @param payload - The payload to send to the endpoint
* @param options - The options for the API call
* @returns A promise that resolves when the payload is sent
*/
export declare function sendToAPI(payload: MonitorPayload | ControlPayload, role?: "monitoring" | "control", options?: {
retries?: number;
timeout?: number;
priority?: "low" | "normal" | "high";
}): Promise<ControlAPIResponse | undefined>;
export { getQueueSize, clearQueue, flushQueue, getQueueManager } from './queue';
//# sourceMappingURL=client.d.ts.map