← back to Watches
sdk/types.d.ts
316 lines
/**
* TypeScript definitions for Omega Watch Price History API
* @version 2.0.0
*/
export interface PricePoint {
year: number;
price: number;
condition?: 'new' | 'vintage' | 'excellent' | 'good';
source?: string;
}
export interface Specifications {
caseSize?: string;
caseMaterial?: string;
movement?: string;
waterResistance?: string;
crystal?: string;
dialColor?: string;
bezel?: string;
lugWidth?: string;
thickness?: string;
powerReserve?: string;
weight?: string;
features?: string[];
}
export interface Watch {
id: string;
model: string;
series: string;
reference: string;
yearIntroduced: number;
description?: string;
priceHistory: PricePoint[];
specifications?: Specifications;
imageUrl?: string;
detailedDescription?: string;
}
export interface WatchesListResponse {
total: number;
page: number;
limit: number;
totalPages: number;
watches: Watch[];
}
export interface SearchResponse {
query: string;
total: number;
page: number;
limit: number;
totalPages: number;
results: Watch[];
}
export interface TrendingWatch extends Watch {
views: number;
}
export interface TrendingResponse {
trending: TrendingWatch[];
totalViews: number;
}
export interface WatchHistoryResponse {
watch: {
id: string;
model: string;
series: string;
reference: string;
yearIntroduced: number;
specifications?: Specifications;
};
priceHistory: PricePoint[];
views: number;
}
export interface PricePrediction {
year: number;
predictedPrice: number;
confidence: number;
}
export interface PricePredictionResponse {
model: string;
currentPrice: number;
trend: 'increasing' | 'decreasing';
averageAnnualChange: number;
predictions: PricePrediction[];
}
export interface TopPerformer {
id: string;
model: string;
series: string;
appreciation: number;
currentPrice: number;
yearIntroduced: number;
}
export interface StatisticsResponse {
totalWatches: number;
totalSeries: number;
averageAppreciation: number;
topPerformers: TopPerformer[];
lastUpdated: string;
priceRanges: Record<string, number>;
movementTypes: Record<string, number>;
appreciationByDecade: Record<string, number>;
}
export interface CollectionWatch {
id: string;
model: string;
reference: string;
yearIntroduced: number;
}
export interface Collection {
series: string;
count: number;
avgPrice: number;
avgAppreciation: number;
avgYearIntroduced: number;
watches: CollectionWatch[];
}
export interface CollectionsResponse {
collections: Collection[];
totalCollections: number;
}
export interface CompareWatch extends Watch {
currentPrice: number;
appreciation: number;
}
export interface CompareResponse {
watches: CompareWatch[];
count: number;
}
export interface HealthResponse {
status: string;
timestamp: string;
uptime: number;
memory: {
rss: number;
heapTotal: number;
heapUsed: number;
external: number;
arrayBuffers?: number;
};
cache: {
keys: number;
size: number;
oldestEntry: number;
};
database: {
watches: number;
collections: number;
};
websocket: {
connections: number;
};
}
export interface ErrorResponse {
error: string;
details?: string;
}
export interface GetWatchesOptions {
series?: string;
minYear?: number;
maxYear?: number;
minPrice?: number;
maxPrice?: number;
page?: number;
limit?: number;
}
export interface SearchOptions {
series?: string;
movement?: string;
minPrice?: number;
maxPrice?: number;
page?: number;
limit?: number;
}
export interface WebSocketConfig {
onUpdate?: (data: WebSocketUpdateMessage) => void;
onError?: (error: Error) => void;
onConnect?: () => void;
onDisconnect?: () => void;
}
export interface WebSocketSubscribeMessage {
type: 'subscribe';
watchId: string;
}
export interface WebSocketSubscribedMessage {
type: 'subscribed';
watchId: string;
}
export interface WebSocketUpdateMessage {
type: 'update';
watchId: string;
data: {
price?: number;
change?: number;
timestamp?: string;
[key: string]: any;
};
}
export interface APIClientOptions {
baseURL?: string;
timeout?: number;
apiKey?: string;
}
/**
* Main API Client Class
*/
export class OmegaWatchAPI {
constructor(options?: APIClientOptions);
/**
* Get system health status
*/
getHealth(): Promise<HealthResponse>;
/**
* Get all watches with optional filtering
*/
getWatches(options?: GetWatchesOptions): Promise<WatchesListResponse>;
/**
* Get watch by ID
*/
getWatchById(id: string): Promise<WatchHistoryResponse>;
/**
* Search watches
*/
search(query: string, options?: SearchOptions): Promise<SearchResponse>;
/**
* Get trending watches
*/
getTrending(limit?: number): Promise<TrendingResponse>;
/**
* Get price predictions for a watch
*/
getPricePredictions(id: string): Promise<PricePredictionResponse>;
/**
* Get market statistics
*/
getStatistics(): Promise<StatisticsResponse>;
/**
* Get all collections
*/
getCollections(): Promise<CollectionsResponse>;
/**
* Compare multiple watches
*/
compareWatches(watchIds: string[]): Promise<CompareResponse>;
/**
* Export data as JSON
*/
exportJSON(): Promise<any>;
/**
* Export data as CSV
*/
exportCSV(): Promise<string>;
/**
* Connect to WebSocket for real-time updates
*/
connectWebSocket(config: WebSocketConfig): void;
/**
* Subscribe to watch updates
*/
subscribeToWatch(watchId: string): void;
/**
* Disconnect WebSocket
*/
disconnectWebSocket(): void;
/**
* Clear server cache (admin only)
*/
clearCache(): Promise<any>;
/**
* Create database backup (admin only)
*/
createBackup(): Promise<any>;
}
export default OmegaWatchAPI;