@gohighlevel/api-client
Version:
Official SDK for HighLevel Public APIs
102 lines • 3.66 kB
TypeScript
import { SessionStorage } from './session-storage';
import { ISessionData } from './interfaces';
import { Logger } from '../logging';
/**
* In-memory implementation of SessionStorage
* Provides fast, non-persistent storage for sessions, tokens, and related data
* Data is lost when the application restarts
*/
export declare class MemorySessionStorage extends SessionStorage {
private sessions;
private clientId;
private isInitialized;
constructor(logger?: Logger);
/**
* Set the client ID (called automatically by HighLevel class)
* @param clientId - The client ID from HighLevel configuration
*/
setClientId(clientId: string): void;
/**
* Extract applicationId from clientId (first part before "-")
* @returns Application ID extracted from clientId
*/
private getApplicationId;
/**
* Generate a unique key combining applicationId and resourceId
* @param resourceId - The resource identifier (companyId or locationId)
* @returns Unique composite key
*/
private generateUniqueKey;
/**
* Initialize the memory storage (no-op for memory storage)
*/
init(): Promise<void>;
/**
* Close the memory storage (clears all data)
*/
disconnect(): Promise<void>;
/**
* Create a collection (no-op for memory storage)
* @param collectionName - Name of the collection (ignored in memory storage)
*/
createCollection(collectionName: string): Promise<void>;
/**
* Get a collection reference (returns collection name for memory storage)
* @param collectionName - Name of the collection
*/
getCollection(collectionName: string): Promise<string>;
/**
* Store a session in memory
* @param resourceId - Unique identifier: it can be a companyId or a locationId
* @param sessionData - Session data to store
*/
setSession(resourceId: string, sessionData: ISessionData): Promise<void>;
/**
* Retrieve a session from memory
* @param resourceId - Unique identifier: it can be a companyId or a locationId
* @returns Session data or null if not found
*/
getSession(resourceId: string): Promise<ISessionData | null>;
/**
* Delete a session from memory
* @param resourceId - Unique identifier: it can be a companyId or a locationId
*/
deleteSession(resourceId: string): Promise<void>;
/**
* Get only the access token for a resource
* @param resourceId - Unique identifier for the resource (companyId or locationId)
* @returns Access token or null if not found
*/
getAccessToken(resourceId: string): Promise<string | null>;
/**
* Get only the refresh token for a resource
* @param resourceId - Unique identifier for the resource (companyId or locationId)
* @returns Refresh token or null if not found
*/
getRefreshToken(resourceId: string): Promise<string | null>;
/**
* Get all sessions for this application
* @returns Array of session data for the application
*/
getSessionsByApplication(): Promise<ISessionData[]>;
/**
* Check if the storage is initialized
* @returns Initialization status
*/
isStorageActive(): boolean;
/**
* Get current session count
* @returns Number of sessions stored in memory
*/
getSessionCount(): number;
/**
* Get all session keys (for debugging)
* @returns Array of all session keys
*/
getAllSessionKeys(): string[];
/**
* Clear all sessions (useful for testing)
*/
clearAllSessions(): void;
}
//# sourceMappingURL=memory-session-storage.d.ts.map