UNPKG

ai-sync

Version:

AI-native sync infrastructure SDK - Your code gains conversational intelligence

198 lines 4.76 kB
/** * TypeScript definitions for the SyncAPIs SDK * These types transform technical API responses into paradigm-first developer experience */ /** * Main SDK client configuration */ export interface SyncClientConfig { apiKey: string; baseUrl?: string; environment?: 'sandbox' | 'production'; tenantId?: string; } /** * AI Response - Paradigm-first messaging */ export interface AIResponse { explanation: string; codeSnippet: string; timeToSetup: string; syncConfig: SyncConfiguration; alternatives?: AIAlternative[]; recommendations?: AIRecommendations; metadata: { cached: boolean; processingTimeMs: number; confidence: number; }; } /** * Sync Configuration - What gets executed */ export interface SyncConfiguration { source: { type: 'stripe' | 'hubspot' | 'postgres' | string; tenantId: string; }; target: { type: 'stripe' | 'hubspot' | 'postgres' | string; tenantId: string; }; entity: 'customer' | 'contact' | 'invoice' | string; bidirectional: boolean; conflictStrategy: 'last-write-wins' | 'field-level-merge' | 'prefer-source' | 'prefer-target'; options?: { fieldMappings?: Record<string, FieldMapping>; filters?: SyncFilter[]; batchSize?: number; }; } /** * Field mapping configuration */ export interface FieldMapping { sourceField: string; targetField: string; conflictResolution: 'prefer-source' | 'prefer-target' | 'last-write-wins'; transform?: string; } /** * Sync filter for conditional processing */ export interface SyncFilter { field: string; operator: 'equals' | 'not_equals' | 'in' | 'not_in' | 'exists'; value: any; } /** * AI Alternative suggestions */ export interface AIAlternative { title: string; explanation: string; codeSnippet: string; pros: string[]; cons: string[]; configuration: SyncConfiguration; } /** * AI Recommendations */ export interface AIRecommendations { conflictResolution?: string; authSetup?: string; bestPractices?: string[]; potentialIssues?: string[]; } /** * Sync Link - Active sync relationship */ export interface SyncLink { id: string; status: 'active' | 'paused' | 'error'; config: SyncConfiguration; createdAt: string; getStatus(): Promise<SyncStatus>; pause(reason?: string): Promise<void>; resume(): Promise<void>; on(event: string | symbol, listener: (...args: any[]) => void): this; off(event: string | symbol, listener: (...args: any[]) => void): this; emit(event: string | symbol, ...args: any[]): boolean; } /** * Sync Status - How your code is performing */ export interface SyncStatus { message: string; active: boolean; lastSync: string; recordsSynced: number; conflictsResolved: number; errorsCount: number; healthScore: number; performance: { avgLatencyMs: number; successRate: number; throughputPerHour: number; }; recentActivity: string[]; } /** * Connection Status - OAuth/Auth state */ export interface ConnectionStatus { service: string; status: 'connected' | 'expired' | 'error' | 'pending'; message: string; connectedAt?: string; expiresAt?: string; permissions: string[]; } /** * Raw API response format (what your backend returns) * These get transformed into paradigm-first responses */ export interface APIResponse { success: boolean; response?: { syncConfig?: { code: string; explanation: string; configuration: any; }; alternatives?: any[]; recommendations?: any; aiContext?: any; }; error?: string; metadata?: { requestId: string; timestamp: string; processingTimeMs: number; tokensUsed: number; }; } /** * Cache entry for fast responses */ export interface CacheEntry { prompt: string; response: AIResponse; createdAt: number; hitCount: number; } /** * SDK Events for real-time updates */ export interface SDKEvents { 'ai:thinking': { prompt: string; }; 'ai:response': { response: AIResponse; }; 'sync:created': { syncId: string; config: SyncConfiguration; }; 'sync:status': { syncId: string; status: SyncStatus; }; 'connection:status': { service: string; status: ConnectionStatus; }; } /** * Auto-connect OAuth result */ export interface AutoConnectResult { service: string; authUrl: string; webhookSetup: 'automated' | 'manual' | 'pending'; message: string; nextSteps?: string[]; } //# sourceMappingURL=types.d.ts.map