/** * Shared utilities for querying per-stream per-device data presence * via the analytics SQL backend. * * Uses a UNION ALL across all telemetry tables to discover what data * exists, grouped by (device_id, stream_name, stream_type). */ /** * Escape a string for safe interpolation into a SQL single-quoted literal. * Replaces single quotes with two single quotes. */ export declare function escapeSQL(value: string): string; export interface StreamPresenceRow { data_points: number; device_id: string; first_seen: string; last_seen: string; stream_name: string; stream_type: string; } /** * Build a SQL query that returns per-stream per-device data presence. * * Returns columns: device_id, stream_name, stream_type, data_points, first_seen, last_seen */ export declare function buildPresenceSQL(options: { days?: number; deviceIds?: string[]; limit?: number; streamNames?: string[]; streamTypes?: string[]; }): string; /** * Build a SQL query that returns the last time any data was seen per device. * * Returns columns: device_id, last_seen, total_points, stream_count */ export declare function buildLastSeenSQL(options: { days?: number; deviceIds?: string[]; }): string; /** * Normalize a timestamp string from analytics SQL (e.g. "2026-02-19 23:37:04.747") * to ISO 8601 format ("2026-02-19T23:37:04.747Z"). */ export declare function toIsoDateTime(sqlTimestamp: string): string; /** * Freshness label based on how recently data was seen. */ export type FreshnessLevel = 'active' | 'dormant' | 'recent' | 'stale'; export declare function getFreshness(lastSeenIso: string): FreshnessLevel;