/** * API Client Layer - Main Barrel Exports * * Centralized export point for all API modules in the dashboard. * Provides domain-driven API access - UI layer works with domain objects exclusively. * * Architecture Pattern: * - UI Layer → Domain Objects → API Client → Schemas (internal) → HTTP * - All schema mapping is handled internally by module mappers * - Public API surface exposes only domain objects and shared types * * @layer Infrastructure - API Client * * @example * ```typescript * // Import API modules * import { authApi, companiesApi, tenantsApi, usersApi } from '@/infrastructure/http/api'; * import { Tenant } from '@/domain/entities/Tenant'; * * // Use with domain objects * const tenant = new Tenant({ name: 'Acme Corp', ... }); * const created = await tenantsApi.createTenant(companyId, tenant); * ``` */ // ============================================================================ // Module APIs // ============================================================================ /** * Authentication API * Login, registration, session management, 2FA */ export { authApi } from './auth'; export type { LoginCredentials, UserRegistrationData } from './auth'; /** * Tenant API * Tenant CRUD operations, hierarchy management */ export { TenantsApi, createTenantsApi } from './tenant'; /** * Company API * Company CRUD operations, member management */ export { companiesApi } from './company'; /** * Integration Keys API * API key creation, listing, revocation */ export { integrationKeysApi } from './integration-keys'; /** * Info Center API * Discovered pages, page analysis, stats */ export { InfoCenterApi, createInfoCenterApi } from './info-center'; /** * Upload API * File upload operations with progress tracking */ export { uploadApi } from './upload'; export type { UploadResult, FileMetadata } from './upload'; /** * Subscription API * Subscription management, billing, usage quota */ export { subscriptionApi } from './subscription'; export type { SubscriptionResponse, AvailablePlanResponse, UsageResponse, InvoiceResponse, CheckoutResponse, } from './subscription'; /** * WordPress API * WP plugin sync binding, sync trigger, sync status */ export { WordpressApi, wordpressApi, type WordpressTriggerSyncResponse, type WordpressDisconnectResponse, } from './wordpress'; /** * Profile API * User profile management, password change */ export { profileApi } from './profile'; export type { ProfileFormData } from './profile'; // ============================================================================ // Shared Types // ============================================================================ /** * Error Types * ApiError class and error factory functions */ export { ApiError, ApiErrorCode, createNetworkError, createAuthError, createValidationError, createNotFoundError, createForbiddenError, createConflictError, createServerError, createTimeoutError, mapStatusToErrorCode, } from './shared/errors'; /** * Common Types * Pagination, responses, query parameters, auth session */ export type { PaginationMeta, PaginatedResponse, ApiResponse, PaginationParams, FilterParams, ListParams, IdParam, BulkOperationResult, UploadProgress, UploadProgressCallback, ApiRequestOptions, AuthSession, TokenStorage, } from './shared/types'; // ============================================================================ // API Client Instance // ============================================================================ /** * HTTP Client * Base ApiClient instance for direct usage (advanced cases) * Most use cases should use module APIs above */ export { apiClient, ApiClient } from '../ApiClient'; // ============================================================================ // Usage Notes // ============================================================================ /** * DOMAIN-DRIVEN PATTERN: * * 1. UI Layer works ONLY with domain objects: * - Import from '@/domain/entities/...' * - Never import from '@archer/api-interface/schemas' * * 2. API Client handles schema mapping internally: * - Domain → Request Schema (via request mappers) * - Response Schema → Domain (via response mappers) * * 3. Type Safety: * - All API methods are fully typed with domain objects * - Compile-time checking via TypeScript * - Runtime validation via Zod (internal to mappers) * * 4. Error Handling: * - All API methods throw ApiError on failure * - Use try/catch or .catch() to handle errors * - Check error.code for specific error types * * @example * ```typescript * import { authApi, companiesApi, ApiError, ApiErrorCode } from '@/infrastructure/http/api'; * * try { * // Login with plain credentials * const { user, session } = await authApi.login({ * email: 'user@example.com', * password: 'password123' * }); * * // Store tokens * localStorage.setItem('accessToken', session.accessToken); * * // Fetch companies (returns domain objects) * const { companies, pagination } = await companiesApi.listCompanies(); * * } catch (error) { * if (error instanceof ApiError) { * if (error.code === ApiErrorCode.AUTH_ERROR) { * console.error('Authentication failed:', error.message); * } else if (error.code === ApiErrorCode.NETWORK_ERROR) { * console.error('Network error:', error.message); * } else { * console.error('API error:', error.message); * } * } * } * ``` */