/** * Base Sunsama client * * Provides core HTTP infrastructure, authentication, session management, * and task ID generation. Extended by domain-specific method classes. */ import type { GraphQLRequest, GraphQLResponse, SunsamaClientConfig } from '../types/index.js'; export declare abstract class SunsamaClientBase { protected static readonly BASE_URL = "https://api.sunsama.com"; private readonly config; private readonly cookieJar; protected userId?: string; protected groupId?: string; protected timezone?: string; /** * Creates a new Sunsama client instance * * @param config - Client configuration options (optional) */ constructor(config?: SunsamaClientConfig); /** * Gets the current client configuration */ getConfig(): SunsamaClientConfig; /** * Checks if the client is authenticated * * @returns True if a session cookie is present in the jar */ isAuthenticated(): Promise; /** * Returns the current session token, or undefined if not authenticated * * @returns The session token string, or undefined */ getSessionToken(): Promise; /** * Authenticates with email and password * * @param email - User email address * @param password - User password * @throws SunsamaAuthError if login fails */ login(email: string, password: string): Promise; /** * Clears all cookies from the jar and cached user data */ logout(): void; /** * Makes an authenticated request to the Sunsama API * * @param path - The API endpoint path (e.g., '/graphql') * @param options - Request options * @returns The response from the API * @internal */ private request; /** * Makes a GraphQL request to the Sunsama API * * @param request - The GraphQL request * @returns The GraphQL response * @internal */ protected graphqlRequest>(request: GraphQLRequest): Promise>; /** * Sets a session token as a cookie in the jar * * @param token - The session token to set * @internal */ private setSessionTokenAsCookie; /** * Generates a unique task ID in MongoDB ObjectId format * * This method creates a 24-character hexadecimal string following MongoDB ObjectId conventions: * - First 8 chars: Unix timestamp (4 bytes) * - Next 10 chars: Random value (5 bytes) * - Last 6 chars: Incrementing counter (3 bytes) * * @returns A 24-character hexadecimal string compatible with Sunsama's task ID format * @example * ```typescript * const taskId = SunsamaClient.generateTaskId(); * console.log(taskId); // "507f1f77bcf86cd799439011" * ``` */ static generateTaskId(): string; private static _counter; /** * Gets a random value for ObjectId generation (5 bytes = 10 hex chars) * @internal */ private static getRandomValue; /** * Gets the next counter value for ID generation (3 bytes = 6 hex chars) * @internal */ private static getNextCounter; } //# sourceMappingURL=base.d.ts.map