/** * @file API Module Index * @description Comprehensive API infrastructure providing type-safe HTTP clients, * request building, response handling, React Query integration, and mock capabilities. * * This module serves as the central export point for all API-related functionality: * * - **API Client**: Enterprise-grade HTTP client with retry, interceptors, and deduplication * - **Request Builder**: Fluent API for constructing type-safe requests * - **Response Handler**: Typed parsing, error normalization, and streaming support * - **Hooks Factory**: Generate typed query/mutation hooks from endpoint definitions * - **Mock System**: Development mock server with delay and error simulation * - **React Hooks**: useApiClient, useApiRequest, useApiMutation, useApiCache, useApiHealth * * @example Quick Start * ```typescript * import { * // Client * apiClient, * createApiClient, * * // Request building * RequestBuilder, * get, * post, * * // Response handling * parseResponse, * normalizeError, * * // Hooks * useApiRequest, * useApiMutation, * useApiHealth, * * // Mock * mockServer, * createMockServer, * } from '@/lib/api'; * * // Make a typed request * const users = await apiClient.get('/users'); * * // Use hooks in components * const { data, isLoading } = useApiRequest({ * url: '/users/123', * queryKey: ['users', '123'], * }); * * // Build complex requests * const config = get('/search') * .query({ q: 'term', page: 1 }) * .timeout(5000) * .build(); * ``` * * @example Mock Server Setup * ```typescript * import { mockServer, mockHandlers, mockData } from '@/lib/api'; * * // Register mock routes * mockServer.get('/users', mockHandlers.success([ * { id: mockData.uuid(), name: mockData.name() }, * ])); * * // Enable mocking * mockServer.start(); * ``` * * @module @/lib/api */ export type { HttpMethod, HttpMethodWithBody, HttpMethodWithoutBody, ContentType, ResponseType, PathParams, QueryParamValue, QueryParams, RequestHeaders, RequestConfig, RequestPriority, RequestMeta, RetryConfig, ResponseHeaders, ApiResponse, ResponseTiming, CacheInfo, CursorPaginationParams, OffsetPaginationParams, PaginationParams, PaginationMeta, PaginatedResponse, ErrorSeverity, ErrorCategory, FieldError, ApiError, ServerErrorResponse, ApiEndpoint, EndpointCacheConfig, ApiContract, InferEndpointRequest, InferEndpointResponse, InferEndpointPathParams, InferEndpointQueryParams, TokenProvider, ApiClientConfig, RequestInterceptor, ResponseInterceptor, ErrorInterceptor, UseApiRequestOptions, UseApiMutationOptions, ApiRequestResult, ApiMutationResult, MockHandler, MockRequest, MockResponse, MockRoute, MockServerConfig, HealthStatus, HealthCheckResult, HealthMonitorConfig, CacheEntry, CacheStats, CacheConfig, StreamEventType, StreamEvent, StreamController, StreamOptions, DeepPartial, RequiredFields, NonNullableFields, Merge, Brand, RequestId, CorrelationId, } from './types'; export { ApiClient, createApiClient, apiClient, createApiError, isRetryable, getErrorCategory, getErrorSeverity, } from './api-client'; export { RequestBuilder, createRequest, get, post, put, patch, del, serializeQueryParams, parseQueryParams, buildUrl, joinUrl, type QuerySerializationOptions, } from './request-builder'; export { parseResponse, createResponseParser, type ResponseParserConfig, normalizeError, isApiError, type ErrorNormalizationConfig, extractCacheHints, buildCacheInfo, generateCacheControl, type CacheHints, streamResponse, extractPagination, createPaginatedResponse, mergePaginatedResponses, type PaginationConfig, createTransformPipeline, transformers, type ResponseTransformer, } from './response-handler'; export { createApiHooks, createQueryKeyFactory, type HooksFactoryConfig, type ApiHooks, type QueryHookConfig, type QueryRequestParams, type GeneratedQueryHook, type MutationHookConfig, type MutationRequestParams, type GeneratedMutationHook, createInfiniteQueryHook, type InfiniteQueryHookConfig, createOptimisticMutation, createOptimisticListMutation, type OptimisticUpdateConfig, createErrorHandler, type ErrorHandlerConfig, createPrefetch, toHookName, extractPaginationFromResponse, mergeInfinitePages, useStableQueryKey, useMutationLoadingState, useCombinedMutationError, } from './api-hooks-factory'; export { MockServer, createMockServer, mockServer, mockHandlers, mockData, createCrudHandlers, type MockRequestLog, } from './mock-api'; export { useApiClient, useApiClientInstance, useApiClientStatus, useApiInterceptors, ApiClientProvider, type ApiClientContextValue, type ApiClientProviderProps, useApiRequest, useGet, useGetById, useGetList, useParallelRequests, useDependentRequest, usePolling, usePrefetch, useLazyQuery, type ApiRequestConfig, type ApiRequestOptions, type UseApiRequestResult, useApiMutation, usePost, usePut, usePatch, useDelete, useBatchMutation, createOptimisticAdd, createOptimisticUpdate, createOptimisticRemove, type MutationVariables, type ApiMutationConfig, type UseApiMutationResult, useApiCache, useCacheMonitor, useCacheEntry, useBulkCacheOperations, type CacheFilterOptions, type CacheEntryInfo, type UseApiCacheResult, useApiHealth, useApiConnectivity, useNetworkAware, useMultiApiHealth, type UseApiHealthConfig, type UseApiHealthResult, } from './hooks'; export * as advanced from './advanced'; export { APIGateway, createAPIGateway, loggingMiddleware, correlationIdMiddleware, type HttpMethod as GatewayHttpMethod, type GatewayRequest, type GatewayResponse, type GatewayError, type RetryConfig as GatewayRetryConfig, type CacheConfig as GatewayCacheConfig, type GatewayMiddleware, type RequestInterceptor as GatewayRequestInterceptor, type ResponseInterceptor as GatewayResponseInterceptor, type ErrorInterceptor as GatewayErrorInterceptor, type GatewayConfig, RequestOrchestrator, createRequestOrchestrator, type OrchestratedRequest, type OrchestrationResult, type BatchConfig, type ChainConfig, type WaterfallStep, type WaterfallContext, ResponseNormalizer, createResponseNormalizer, normalizeResponse, normalizeErrors, type NormalizedResponse, type NormalizedPagination, type NormalizedLinks, type NormalizedError, type ResponseFormatConfig, type ResponseFormat, VersionManager, createVersionManager, parseSemver, formatVersion, type VersioningStrategy, type VersionFormat, type VersionStatus, type APIVersion, type VersionManagerConfig, type VersionTransform, type ResponseMigration, RateLimiter, RateLimitError, createRateLimiter, RATE_LIMIT_PRESETS, type RateLimitConfig, type RateLimitStatus, type RateLimitHeaders, RequestDeduplicator, createRequestDeduplicator, createDeduplicatedFetch, deduplicateFunction, ReactQueryDeduplicator, createReactQueryDeduplicator, type DeduplicationConfig, type DeduplicationRequest, type DeduplicationStats, APIMetricsCollector, createMetricsCollector, consoleReporter, createBatchedReporter, type RequestMetric, type EndpointMetrics, type OverallMetrics, type MetricsConfig, type MetricsReporter, } from './advanced'; export { API_CONFIG, API_ENDPOINTS, QUERY_KEYS, ENDPOINT_REGISTRY, buildApiUrl, buildApiUrlWithParams, isRetryableStatus, isNetworkError, getEnvironmentApiConfig, buildListParams, API_VERSION, SUPPORTED_API_VERSIONS, getVersionedApiUrl, buildVersionedUrl, type ApiEndpoints, type ApiConfig, type QueryKeyFactory, type EndpointDefinition, type EndpointRegistry, type EnvironmentApiConfig, type ApiSuccessResponse, type ApiErrorResponse, type ApiPaginatedResponse, type ListRequestParams, type ApiVersion, } from '../../config/api.config';