cre-sync/types/api.ts
BusyBee3333 4e6467ffb0 Add CRESync CRM application with Setup page
- Build complete Next.js CRM for commercial real estate
- Add authentication with JWT sessions and role-based access
- Add GoHighLevel API integration for contacts, conversations, opportunities
- Add AI-powered Control Center with tool calling
- Add Setup page with onboarding checklist (/setup)
- Add sidebar navigation with Setup menu item
- Fix type errors in onboarding API, GHL services, and control center tools
- Add Prisma schema with SQLite for local development
- Add UI components with clay morphism design system

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 17:30:55 -05:00

181 lines
4.2 KiB
TypeScript

/**
* API Request/Response Types
* CRESyncFlow - Commercial Real Estate CRM
*
* Generic types for API communication
*/
// =============================================================================
// Generic API Response Types
// =============================================================================
export interface APIResponse<T = any> {
success: boolean;
data?: T;
error?: string;
message?: string;
statusCode?: number;
}
export interface APIErrorResponse {
success: false;
error: string;
message?: string;
statusCode: number;
details?: Record<string, string[]>;
}
export interface APISuccessResponse<T> {
success: true;
data: T;
message?: string;
}
// =============================================================================
// Pagination Types
// =============================================================================
export interface PaginationParams {
page?: number;
limit?: number;
search?: string;
sortBy?: string;
sortOrder?: 'asc' | 'desc';
}
export interface PaginatedResponse<T> {
items: T[];
total: number;
page: number;
limit: number;
totalPages: number;
hasNextPage: boolean;
hasPrevPage: boolean;
}
export interface CursorPaginationParams {
cursor?: string;
limit?: number;
direction?: 'forward' | 'backward';
}
export interface CursorPaginatedResponse<T> {
items: T[];
nextCursor?: string;
prevCursor?: string;
hasMore: boolean;
}
// =============================================================================
// Filter and Search Types
// =============================================================================
export type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin' | 'contains' | 'startsWith' | 'endsWith';
export interface FilterCondition {
field: string;
operator: FilterOperator;
value: any;
}
export interface SearchParams extends PaginationParams {
filters?: FilterCondition[];
dateFrom?: string;
dateTo?: string;
}
// =============================================================================
// Batch Operation Types
// =============================================================================
export interface BatchOperationResult<T = any> {
successful: T[];
failed: Array<{
item: any;
error: string;
}>;
totalProcessed: number;
totalSuccessful: number;
totalFailed: number;
}
export interface BulkDeleteRequest {
ids: string[];
}
export interface BulkUpdateRequest<T> {
ids: string[];
updates: Partial<T>;
}
// =============================================================================
// File Upload Types
// =============================================================================
export interface FileUploadResponse {
url: string;
filename: string;
size: number;
mimeType: string;
uploadedAt: string;
}
export interface FileUploadProgress {
loaded: number;
total: number;
percentage: number;
}
// =============================================================================
// Webhook Types
// =============================================================================
export interface WebhookPayload<T = any> {
event: string;
timestamp: string;
data: T;
signature?: string;
}
export interface WebhookRegistration {
id: string;
url: string;
events: string[];
secret: string;
isActive: boolean;
createdAt: string;
}
// =============================================================================
// Rate Limiting Types
// =============================================================================
export interface RateLimitInfo {
limit: number;
remaining: number;
reset: number;
retryAfter?: number;
}
// =============================================================================
// Health Check Types
// =============================================================================
export interface HealthCheckResponse {
status: 'healthy' | 'degraded' | 'unhealthy';
timestamp: string;
version: string;
services: {
database: ServiceStatus;
ghl: ServiceStatus;
redis?: ServiceStatus;
stripe?: ServiceStatus;
};
}
export interface ServiceStatus {
status: 'up' | 'down' | 'degraded';
latency?: number;
message?: string;
}