export class FormatHandler { /** @param {FormatHandlerOptions} opts */ constructor({ sessionId, duckdb, urls, bbox, estimatedBytes, flattenStructs }?: FormatHandlerOptions); sessionId: string; duckdb: import("../duckdb_adapter.js").DuckDBClient; urls: string[]; bbox: { west: number; south: number; east: number; north: number; }; estimatedBytes: number; flattenStructs: boolean; _duckdbRegisteredPaths: Set; _prepared: boolean; _downloadedFiles: Set; _activeTrackers: any[]; cancelled: boolean; /** @returns {number} Expected peak OPFS usage in bytes */ getExpectedBrowserStorageUsage(): number; /** @returns {number} Total expected disk usage including downloads */ getTotalExpectedDiskUsage(): number; /** * Return a format-specific warning or error before download starts, or null. * @returns {{ message: string, isBlocking: boolean } | null} */ getFormatWarning(): { message: string; isBlocking: boolean; } | null; cancel(): void; throwIfCancelled(): void; /** * Start a background interval that polls disk usage and reports progress * based on estimated output size. Returns a stop function. */ startDiskProgressTracker(onProgress: any, onStatus: any, messagePrefix: any, expectedBytes: any, intervalMs?: number): () => void; /** DuckDB read_parquet() expression for the source URLs */ get parquetSource(): string; /** * Create and register an OPFS file path for DuckDB to write to. * @param {string} prefix - OPFS prefix (e.g. OPFS_PREFIX_TMP) * @param {string} ext - File extension * @returns {Promise} opfs:// path */ createDuckdbOpfsFile(prefix: string, ext: string): Promise; _getRoot(): Promise; _opfsRoot: FileSystemDirectoryHandle; removeOpfsFile(opfsFileName: any): Promise; releaseDuckdbOpfsFile(opfsFileName: any): Promise; releaseDuckdbOpfsFiles(): Promise; getOpfsHandle(name: any, { create }?: { create?: boolean; }): Promise; getOpfsFile(opfsPath: any): Promise; /** * Build a SELECT column expression, optionally flattening STRUCT columns. * @param {string[]} [excludeCols] - Columns to exclude * @returns {Promise} SQL column expression */ buildColumnSelect(excludeCols?: string[]): Promise; /** * Create an intermediate parquet file on OPFS with WKB geometry from the remote source. * @param {Object} opts * @param {string} opts.prefix - OPFS filename prefix * @param {string[]} [opts.extraColumns] - Additional SQL expressions for the SELECT * @param {Function} opts.onProgress - Progress callback (0–100) * @param {Function} opts.onStatus - Status message callback * @returns {Promise} opfs:// path to the intermediate parquet file */ createIntermediateParquet({ prefix, extraColumns, onProgress, onStatus }: { prefix: string; extraColumns?: string[]; onProgress: Function; onStatus: Function; }): Promise; /** * Discover attribute columns from an intermediate parquet file via DuckDB DESCRIBE. * @param {string} parquetPath - opfs:// path * @param {Set} internalCols - Columns to exclude * @returns {Promise>} */ describeColumns(parquetPath: string, internalCols: Set): Promise>; /** * Return a list of { downloadName, blobParts } for triggerDownload. * @param {string} baseName * @returns {Promise>} */ getDownloadMap(_baseName: any): Promise>; /** WKT polygon for the current bbox */ get bboxWkt(): string; /** DuckDB WHERE clause for bbox + geometry intersection */ get bboxFilter(): string; /** * Trigger browser download(s) from the format handler's output files. * @param {string} baseName - Base filename (without extension) * @param {number} cleanupDelayMs - Delay before cleaning up OPFS files */ triggerDownload(baseName: string, cleanupDelayMs: number): Promise; /** * Run the format handler's write pipeline. * @param {{ onProgress?: (pct: number) => void, onStatus?: (msg: string) => void }} callbacks */ write(callbacks: { onProgress?: (pct: number) => void; onStatus?: (msg: string) => void; }): Promise; /** @protected - Override in subclass */ protected _write(_callbacks: any): Promise; /** Clean up all OPFS files belonging to this session */ cleanup(): Promise; } export type FormatHandlerOptions = { /** * - Unique session/tab ID for OPFS scoping */ sessionId: string; duckdb: import("../duckdb_adapter.js").DuckDBClient; /** * - Proxied parquet URLs to read from */ urls: string[]; bbox: { west: number; south: number; east: number; north: number; }; /** * - Estimated output size for progress */ estimatedBytes?: number | null; /** * - Flatten STRUCT columns into separate columns */ flattenStructs?: boolean; }; /** * Parse top-level field names from a DuckDB STRUCT type string. * E.g. "STRUCT(a INTEGER, b VARCHAR)" → ["a", "b"] * Handles nested types like "STRUCT(a STRUCT(x INT, y INT), b VARCHAR)" * @param {string} structType * @returns {string[]} */ export function parseStructFieldNames(structType: string): string[];