UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

62 lines (61 loc) 2.04 kB
/** * Index Dev Mode - Helps developers identify when indexes would improve performance * * Dev mode suggestions are ON by default in non-production builds. */ export interface IndexDevModeConfig { /** Enable dev mode index suggestions */ enabled: boolean; /** Suggest indexes when collection has more than this many items */ collectionSizeThreshold: number; /** Suggest indexes when queries take longer than this (ms) */ slowQueryThresholdMs: number; /** Custom handler for index suggestions */ onSuggestion: ((suggestion: IndexSuggestion) => void) | null; } export interface IndexSuggestion { type: `collection-size` | `slow-query` | `frequent-field`; collectionId: string; fieldPath: Array<string>; message: string; collectionSize?: number; queryTimeMs?: number; queryCount?: number; } /** * Configure dev mode for index suggestions */ export declare function configureIndexDevMode(config: Partial<IndexDevModeConfig>): void; /** * Get current dev mode configuration */ export declare function getIndexDevModeConfig(): IndexDevModeConfig; /** * Check if dev mode is enabled */ export declare function isDevModeEnabled(): boolean; /** * Emit an index suggestion (dev mode only) */ export declare function emitIndexSuggestion(suggestion: IndexSuggestion): void; /** * Track a query for dev mode analysis */ export declare function trackQuery(collectionId: string, fieldPath: Array<string>, executionTimeMs: number): void; /** * Check collection size and suggest index if needed (dev mode) */ export declare function checkCollectionSizeForIndex(collectionId: string, collectionSize: number, fieldPath: Array<string>): void; /** * Clear query pattern tracking (useful for tests) */ export declare function clearQueryPatterns(): void; /** * Get query patterns (useful for debugging/testing) */ export declare function getQueryPatterns(): Map<string, { fieldPath: Array<string>; queryCount: number; totalTimeMs: number; avgTimeMs: number; }>;