UNPKG

drizzle-cube

Version:

Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.

60 lines (59 loc) 1.9 kB
import { CubeQuery, ChartType, ChartAxisConfig, ChartDisplayConfig, MultiQueryConfig } from '../types'; /** * State that can be shared via URL * Query is required (can be single CubeQuery or MultiQueryConfig), chart config is optional (may be dropped if too large) */ export interface ShareableState { query: CubeQuery | MultiQueryConfig; chartType?: ChartType; chartConfig?: ChartAxisConfig; displayConfig?: ChartDisplayConfig; activeView?: 'table' | 'chart'; } /** * Result of compression with fallback */ export interface CompressionResult { encoded: string | null; queryOnly: boolean; } /** * Compress state to URL-safe encoded string */ export declare function compressAndEncode(state: ShareableState): string; /** * Decompress URL-safe encoded string back to state * Returns null if decompression or parsing fails */ export declare function decodeAndDecompress(encoded: string): ShareableState | null; /** * Check if compressed state fits within URL length limit */ export declare function isShareableSize(state: ShareableState): { ok: boolean; size: number; maxSize: number; }; /** * Compress state with automatic fallback * If full state is too large, tries with query only * Returns null encoded if even query-only is too large */ export declare function compressWithFallback(state: ShareableState): CompressionResult; /** * Generate full share URL with compressed state in hash */ export declare function generateShareUrl(state: ShareableState): string | null; /** * Parse share hash from current URL * Returns encoded string if #share= is present, null otherwise */ export declare function parseShareHash(): string | null; /** * Clear share hash from URL without page reload */ export declare function clearShareHash(): void; /** * Get the maximum allowed hash length */ export declare function getMaxHashLength(): number;