/** * Base API Client * * Weniger, aber besser: One HTTP request implementation for all integrations. * Eliminates ~120-180 lines of duplicate code across integrations. * * Now extends SDK's AuthenticatedHTTPClient - eliminates duplicate AbortController logic. */ import { AuthenticatedHTTPClient, type TokenRefreshHandler, buildQueryString } from '@workwayco/sdk'; /** * Configuration for BaseAPIClient */ export interface BaseClientConfig { /** API URL */ apiUrl: string; /** OAuth access token */ accessToken: string; /** Request timeout in ms */ timeout?: number; /** Error context for better error messages */ errorContext?: { integration: string; }; /** OAuth token refresh configuration */ tokenRefresh?: TokenRefreshHandler; /** Token expiration timestamp (Unix ms) for proactive refresh */ tokenExpiresAt?: number; } export { TokenRefreshHandler }; /** * Base API client with standardized HTTP request handling * * Extends AuthenticatedHTTPClient from SDK, providing: * - Automatic AbortController timeout handling (no manual fetch) * - Automatic token refresh on 401 * - Proactive token refresh before expiration * - Unified error handling via IntegrationError * - JSON-parsing helpers (getJson, postJson, etc.) * * Integration-specific behavior (like custom headers) is added via * wrapper methods that preserve the simple API. */ export declare class BaseAPIClient extends AuthenticatedHTTPClient { constructor(config: BaseClientConfig); /** * Get the API URL (alias for baseUrl from parent) */ get apiUrl(): string; /** * Make a low-level HTTP request (old signature for backwards compatibility) * * This method provides the old request() signature that integrations expect. * It converts RequestInit-style options to the new signature. * * @param path - API endpoint path * @param options - RequestInit options (method, headers, body, etc.) * @param additionalHeaders - Extra headers (e.g., API version headers) * @deprecated Use get(), post(), patch(), etc. methods instead */ request(path: string, options?: RequestInit, additionalHeaders?: Record): Promise; /** * GET request with optional additional headers */ get(path: string, additionalHeaders?: Record): Promise; /** * POST request with JSON body and optional additional headers */ post(path: string, body?: unknown, additionalHeaders?: Record): Promise; /** * PATCH request with JSON body and optional additional headers */ patch(path: string, body?: unknown, additionalHeaders?: Record): Promise; /** * PUT request with JSON body and optional additional headers */ put(path: string, body?: unknown, additionalHeaders?: Record): Promise; /** * DELETE request with optional additional headers */ delete(path: string, additionalHeaders?: Record): Promise; /** * GET request with automatic JSON parsing */ getJson(path: string, additionalHeaders?: Record): Promise; /** * POST request with automatic JSON parsing */ postJson(path: string, body?: unknown, additionalHeaders?: Record): Promise; /** * PATCH request with automatic JSON parsing */ patchJson(path: string, body?: unknown, additionalHeaders?: Record): Promise; /** * PUT request with automatic JSON parsing */ putJson(path: string, body?: unknown, additionalHeaders?: Record): Promise; /** * DELETE request with automatic JSON parsing */ deleteJson(path: string, additionalHeaders?: Record): Promise; /** * Assert response is OK, throw if not * * Alias for SDK's assertResponseOk for backwards compatibility. */ assertOk(response: Response): Promise; } export { buildQueryString }; //# sourceMappingURL=base-client.d.ts.map