xpeditis2.0/apps/frontend/src/lib/api/index.ts
2026-01-20 11:28:54 +01:00

181 lines
4.0 KiB
TypeScript

/**
* API Client - Central Export
*
* This file exports all API services for easy import throughout the application.
* All 60 backend endpoints are now connected to the frontend.
*
* Usage:
* import { login, searchCsvRates, createBooking } from '@/lib/api';
*/
// Base client utilities
export {
getAuthToken,
setAuthTokens,
clearAuthTokens,
createHeaders,
apiRequest,
get,
post,
patch,
del,
upload,
download,
ApiError,
} from './client';
// Authentication (5 endpoints)
export { register, login, refreshToken, logout, getCurrentUser } from './auth';
// Rates (4 endpoints)
export { searchRates, searchCsvRates, getAvailableCompanies, getFilterOptions } from './rates';
// Bookings (7 endpoints)
export {
createBooking,
getBooking,
getBookingByNumber,
listBookings,
fuzzySearchBookings,
advancedSearchBookings,
exportBookings,
updateBookingStatus,
// CSV Bookings
createCsvBooking,
getCsvBooking,
listCsvBookings,
getCsvBookingStats,
cancelCsvBooking,
acceptCsvBooking,
rejectCsvBooking,
type CsvBookingResponse,
type CsvBookingListResponse,
type CsvBookingStatsResponse,
} from './bookings';
// Users (7 endpoints)
export {
listUsers,
getUser,
createUser,
updateUser,
deleteUser,
restoreUser,
changePassword,
} from './users';
// Organizations (4 endpoints)
export {
listOrganizations,
getOrganization,
createOrganization,
updateOrganization,
} from './organizations';
// Notifications (7 endpoints)
export {
listNotifications,
getNotification,
createNotification,
markNotificationAsRead,
markAllNotificationsAsRead,
deleteNotification,
getNotificationPreferences,
updateNotificationPreferences,
} from './notifications';
// Audit Logs (5 endpoints)
export {
listAuditLogs,
getEntityAuditLogs,
getUserAuditLogs,
getAuditStats,
exportAuditLogs,
} from './audit';
// Webhooks (7 endpoints)
export {
listWebhooks,
getWebhook,
createWebhook,
updateWebhook,
deleteWebhook,
testWebhook,
listWebhookEvents,
} from './webhooks';
// GDPR (6 endpoints)
export {
requestDataExport,
downloadDataExport,
requestAccountDeletion,
cancelAccountDeletion,
getConsentPreferences,
updateConsentPreferences,
} from './gdpr';
// Admin CSV Rates (5 endpoints) - already exists
export {
uploadCsvRates,
listCsvFiles,
deleteCsvFile,
getCsvFileStats,
convertCsvFormat,
} from './admin/csv-rates';
// Dashboard (4 endpoints)
export {
getKPIs,
getBookingsChart,
getTopTradeLanes,
getAlerts,
dashboardApi,
type DashboardKPIs,
type BookingsChartData,
type TradeLane,
type DashboardAlert,
} from './dashboard';
// Subscriptions (5 endpoints)
export {
getSubscriptionOverview,
getAllPlans,
canInviteUser,
createCheckoutSession,
createPortalSession,
formatPrice,
getPlanBadgeColor,
getStatusBadgeColor,
type SubscriptionPlan,
type SubscriptionStatus,
type BillingInterval,
type PlanDetails,
type LicenseResponse,
type SubscriptionOverviewResponse,
type CanInviteResponse,
type AllPlansResponse,
} from './subscriptions';
// Re-export as API objects for backward compatibility
import * as bookingsModule from './bookings';
import * as ratesModule from './rates';
import * as usersModule from './users';
import * as authModule from './auth';
import * as organizationsModule from './organizations';
import * as notificationsModule from './notifications';
import * as auditModule from './audit';
import * as webhooksModule from './webhooks';
import * as gdprModule from './gdpr';
import * as subscriptionsModule from './subscriptions';
export const bookingsApi = bookingsModule;
export const ratesApi = ratesModule;
export const usersApi = usersModule;
export const authApi = authModule;
export const organizationsApi = organizationsModule;
export const notificationsApi = notificationsModule;
export const auditApi = auditModule;
export const webhooksApi = webhooksModule;
export const gdprApi = gdprModule;
export const subscriptionsApi = subscriptionsModule;