/**
 * Zapier API Client Module
 *
 * This module provides a centralized API layer for all HTTP interactions
 * with Zapier's various APIs. It handles authentication, error handling,
 * polling, and provides consistent patterns across all services.
 */
import { ZAPIER_BASE_URL } from "../constants";
// Re-export authentication utilities
export { isJwt, getAuthorizationHeader, extractUserIdsFromJwt } from "./auth";
// Re-export debug utilities
export { createDebugLogger, createDebugFetch } from "./debug";
// Re-export polling utilities
export { pollUntilComplete } from "./polling";
// Re-export the main client factory
export { createZapierApi } from "./client";
// Import for local use
import { createZapierApi } from "./client";
// Utility Functions
export function generateRequestId() {
    return Math.random().toString(36).substring(2) + Date.now().toString(36);
}
/**
 * Utility function to get or create an API client for standalone functions
 *
 * @param config - Configuration that may include an existing API client
 * @returns ApiClient instance
 */
export function getOrCreateApiClient(config) {
    const { baseUrl = ZAPIER_BASE_URL, credentials, token, api: providedApi, debug = false, fetch: customFetch, } = config;
    // Use provided API client or create a new one
    if (providedApi) {
        return providedApi;
    }
    return createZapierApi({
        baseUrl,
        credentials,
        token,
        debug,
        fetch: customFetch,
    });
}
