@walkthru-earth/objex-utils 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -0
- package/dist/index.cjs +1183 -954
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +167 -1
- package/dist/index.d.ts +167 -1
- package/dist/index.js +1161 -955
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
package/dist/index.d.cts
CHANGED
|
@@ -208,6 +208,60 @@ interface StorageAdapter {
|
|
|
208
208
|
readonly supportsWrite: boolean;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Provider registry — single source of truth for all cloud storage providers.
|
|
213
|
+
*
|
|
214
|
+
* Centralizes endpoint patterns, regions, auth methods, and UI metadata.
|
|
215
|
+
* Used by ConnectionDialog, browser-cloud adapter, host-detection, url-state, etc.
|
|
216
|
+
*/
|
|
217
|
+
type ProviderId = 's3' | 'gcs' | 'r2' | 'minio' | 'azure' | 'storj' | 'b2' | 'digitalocean' | 'wasabi' | 'contabo' | 'hetzner' | 'linode' | 'ovhcloud';
|
|
218
|
+
interface ProviderRegion {
|
|
219
|
+
code: string;
|
|
220
|
+
label: string;
|
|
221
|
+
}
|
|
222
|
+
interface ProviderDef {
|
|
223
|
+
/** Display label in the UI. */
|
|
224
|
+
label: string;
|
|
225
|
+
/** Short description shown as helper text. */
|
|
226
|
+
description: string;
|
|
227
|
+
/** Auth method used by this provider. */
|
|
228
|
+
authMethod: 'sigv4' | 'sas-token';
|
|
229
|
+
/** Whether the region field is relevant for this provider. */
|
|
230
|
+
needsRegion: boolean;
|
|
231
|
+
/** Whether the endpoint field is required. */
|
|
232
|
+
needsEndpoint: boolean;
|
|
233
|
+
/** Default region when creating a new connection. */
|
|
234
|
+
defaultRegion: string;
|
|
235
|
+
/**
|
|
236
|
+
* Endpoint template with `{region}` placeholder.
|
|
237
|
+
* If null, the user must provide a custom endpoint (e.g. MinIO).
|
|
238
|
+
* If a fixed string (no `{region}`), it's always the same (e.g. GCS).
|
|
239
|
+
*/
|
|
240
|
+
endpointTemplate: string | null;
|
|
241
|
+
/** Known regions with labels. Empty = free-form region input. */
|
|
242
|
+
regions: ProviderRegion[];
|
|
243
|
+
/** Bucket label override (e.g. Azure uses "Container"). */
|
|
244
|
+
bucketLabel?: string;
|
|
245
|
+
/** Default endpoint placeholder shown in the input. */
|
|
246
|
+
endpointPlaceholder: string;
|
|
247
|
+
/** URI schemes that map to this provider (lowercase, without "://"). */
|
|
248
|
+
schemes: string[];
|
|
249
|
+
}
|
|
250
|
+
declare const PROVIDERS: Record<ProviderId, ProviderDef>;
|
|
251
|
+
/** All provider IDs, ordered for the UI. */
|
|
252
|
+
declare const PROVIDER_IDS: ProviderId[];
|
|
253
|
+
/** Get provider def, falling back to S3 for unknown. */
|
|
254
|
+
declare function getProvider(id: string): ProviderDef;
|
|
255
|
+
/** Build endpoint URL from template + region. */
|
|
256
|
+
declare function buildEndpointFromTemplate(id: ProviderId, region: string): string;
|
|
257
|
+
/**
|
|
258
|
+
* Build the base URL for API requests (endpoint + bucket).
|
|
259
|
+
* Used by browser-cloud adapter and url-state.
|
|
260
|
+
*/
|
|
261
|
+
declare function buildProviderBaseUrl(provider: ProviderId, endpoint: string, bucket: string, region: string): string;
|
|
262
|
+
/** Check if a provider uses the GCS JSON API (not S3 XML). */
|
|
263
|
+
declare function isGcsProvider(provider: string, endpoint: string): boolean;
|
|
264
|
+
|
|
211
265
|
/**
|
|
212
266
|
* Minimal adapter for direct HTTPS URLs (source: 'url').
|
|
213
267
|
* Only supports read/head — no listing or writing.
|
|
@@ -226,6 +280,34 @@ declare class UrlAdapter implements StorageAdapter {
|
|
|
226
280
|
copy(): Promise<WriteResult>;
|
|
227
281
|
}
|
|
228
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Cloud storage protocol URL utilities — pure TS, no Svelte dependency.
|
|
285
|
+
*
|
|
286
|
+
* Converts cloud protocol URLs (s3://, gs://) to HTTPS URLs for browser access.
|
|
287
|
+
* Provider-aware native scheme lookup.
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* Map provider to its native URI scheme prefix.
|
|
291
|
+
* Derived from the registry's `schemes` array (first entry is the primary scheme).
|
|
292
|
+
* Falls back to 's3' for providers without a scheme (S3-compatible).
|
|
293
|
+
*/
|
|
294
|
+
declare function getNativeScheme(provider: string): string;
|
|
295
|
+
/**
|
|
296
|
+
* Safely decode a percent-encoded URI component.
|
|
297
|
+
* Returns the original string if decoding fails (malformed sequences).
|
|
298
|
+
*/
|
|
299
|
+
declare function safeDecodeURIComponent(s: string): string;
|
|
300
|
+
/**
|
|
301
|
+
* Convert a cloud storage protocol URL (s3://, gs://) to an HTTPS URL
|
|
302
|
+
* for browser access. Returns the original URL if already HTTP(S) or unknown.
|
|
303
|
+
*
|
|
304
|
+
* Supported:
|
|
305
|
+
* - `s3://bucket/key` → `https://s3.{region}.amazonaws.com/{bucket}/{key}`
|
|
306
|
+
* (region auto-detected from bucket name when possible)
|
|
307
|
+
* - `gs://bucket/key` → `https://storage.googleapis.com/{bucket}/{key}`
|
|
308
|
+
*/
|
|
309
|
+
declare function resolveCloudUrl(url: string): string;
|
|
310
|
+
|
|
229
311
|
type TypeCategory = 'number' | 'string' | 'date' | 'boolean' | 'geo' | 'binary' | 'json' | 'other';
|
|
230
312
|
declare function classifyType(duckdbType: string): TypeCategory;
|
|
231
313
|
declare function typeColor(category: TypeCategory): string;
|
|
@@ -241,6 +323,42 @@ declare function typeLabel(category: TypeCategory): string;
|
|
|
241
323
|
*/
|
|
242
324
|
declare function handleLoadError(err: unknown): string | null;
|
|
243
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Escape a CSV field value per RFC 4180.
|
|
328
|
+
*/
|
|
329
|
+
declare function escapeCsvField(value: string): string;
|
|
330
|
+
/**
|
|
331
|
+
* Serialize column/row data to a CSV string.
|
|
332
|
+
* Pure function — no browser APIs, works in Node.js.
|
|
333
|
+
*/
|
|
334
|
+
declare function serializeToCsv(columns: string[], rows: Record<string, unknown>[]): string;
|
|
335
|
+
/**
|
|
336
|
+
* Serialize column/row data to a formatted JSON string.
|
|
337
|
+
* Pure function — no browser APIs, works in Node.js.
|
|
338
|
+
*/
|
|
339
|
+
declare function serializeToJson(columns: string[], rows: Record<string, unknown>[]): string;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Pure file entry sorting — framework-agnostic, works in Node.js.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
type SortField = 'name' | 'size' | 'modified' | 'extension';
|
|
346
|
+
type SortDirection = 'asc' | 'desc';
|
|
347
|
+
interface SortConfig {
|
|
348
|
+
field: SortField;
|
|
349
|
+
direction: SortDirection;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Sort file entries by the given config.
|
|
353
|
+
* Directories always sort before files regardless of sort field.
|
|
354
|
+
* Returns a new array (does not mutate the input).
|
|
355
|
+
*/
|
|
356
|
+
declare function sortFileEntries(entries: FileEntry[], config: SortConfig): FileEntry[];
|
|
357
|
+
/**
|
|
358
|
+
* Toggle sort config: same field flips direction, new field starts ascending.
|
|
359
|
+
*/
|
|
360
|
+
declare function toggleSortField(current: SortConfig, field: SortField): SortConfig;
|
|
361
|
+
|
|
244
362
|
/**
|
|
245
363
|
* Formats a byte count into a human-readable string.
|
|
246
364
|
*/
|
|
@@ -310,6 +428,54 @@ interface HexRow {
|
|
|
310
428
|
*/
|
|
311
429
|
declare function generateHexDump(data: Uint8Array, bytesPerRow?: number): HexRow[];
|
|
312
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Generic localStorage helpers with SSR safety.
|
|
433
|
+
*
|
|
434
|
+
* Used by connection, settings, and query-history stores to avoid
|
|
435
|
+
* repeating the same load/persist/try-catch/SSR-guard pattern.
|
|
436
|
+
*/
|
|
437
|
+
/**
|
|
438
|
+
* Load a JSON value from localStorage.
|
|
439
|
+
* Returns `defaultValue` on SSR, missing key, or parse error.
|
|
440
|
+
*/
|
|
441
|
+
declare function loadFromStorage<T>(key: string, defaultValue: T): T;
|
|
442
|
+
/**
|
|
443
|
+
* Persist a JSON-serializable value to localStorage.
|
|
444
|
+
* Silently no-ops on SSR or storage errors (quota, private browsing).
|
|
445
|
+
*/
|
|
446
|
+
declare function persistToStorage(key: string, value: unknown): void;
|
|
447
|
+
|
|
448
|
+
interface SqlBlock {
|
|
449
|
+
name: string;
|
|
450
|
+
sql: string;
|
|
451
|
+
startLine: number;
|
|
452
|
+
endLine: number;
|
|
453
|
+
}
|
|
454
|
+
interface ParsedMarkdownDocument {
|
|
455
|
+
frontmatter: Record<string, any>;
|
|
456
|
+
content: string;
|
|
457
|
+
sqlBlocks: SqlBlock[];
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Parse a markdown document with YAML frontmatter and SQL code blocks.
|
|
461
|
+
*
|
|
462
|
+
* Evidence-compatible syntax:
|
|
463
|
+
* ```sql query_name
|
|
464
|
+
* SELECT * FROM table
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
declare function parseMarkdownDocument(markdown: string): ParsedMarkdownDocument;
|
|
468
|
+
/**
|
|
469
|
+
* Interpolate template variables in markdown text.
|
|
470
|
+
* Supports {queryName.rows[0].columnName} syntax.
|
|
471
|
+
*/
|
|
472
|
+
declare function interpolateTemplates(text: string, queryResults: Map<string, Record<string, any>[]>): string;
|
|
473
|
+
/**
|
|
474
|
+
* Replace SQL blocks in markdown content with placeholder markers
|
|
475
|
+
* that can be replaced with rendered components.
|
|
476
|
+
*/
|
|
477
|
+
declare function markSqlBlocks(content: string): string;
|
|
478
|
+
|
|
313
479
|
/**
|
|
314
480
|
* Lightweight Parquet metadata reader using hyparquet.
|
|
315
481
|
*
|
|
@@ -478,4 +644,4 @@ declare function findGeoColumnFromRows(rows: Record<string, unknown>[], schema:
|
|
|
478
644
|
type: string;
|
|
479
645
|
}[]): string | null;
|
|
480
646
|
|
|
481
|
-
export { COPY_FEEDBACK_MS, type Connection, type ConnectionConfig, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, type Defaults, type DuckDbReadFn, type FileCategory, type FileEntry, type FileTypeInfo, type GeoArrowGeomType, type GeoArrowResult, type GeoColumnMeta, type GeoParquetMeta, type GeoType, type HexRow, LAYER_HUE_MULTIPLIER, type ListPage, MAX_QUERY_HISTORY_ENTRIES, type MapQueryHandle, type MapQueryResult, type ParquetFileMetadata, type ParsedGeometry, type ParsedStorageUrl, QueryCancelledError, type QueryEngine, type QueryHandle, type QueryResult, SQL_PREVIEW_LENGTH, STORAGE_KEYS, type SchemaField, type StorageAdapter, type StorageProvider, type Tab, type Theme, type TypeCategory, UrlAdapter, VIEWER_DIR_EXTENSIONS, type ViewerKind, WGS84_CODES, type WriteResult, buildDuckDbSource, buildGeoArrowTables, classifyType, describeParseResult, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, formatValue, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getViewerKind, handleLoadError, isCloudNativeFormat, isQueryable, jsonReplacerBigInt, looksLikeUrl, normalizeGeomType, parseStorageUrl, parseWKB, readParquetMetadata, toBinary, typeBadgeClass, typeColor, typeLabel };
|
|
647
|
+
export { COPY_FEEDBACK_MS, type Connection, type ConnectionConfig, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, type Defaults, type DuckDbReadFn, type FileCategory, type FileEntry, type FileTypeInfo, type GeoArrowGeomType, type GeoArrowResult, type GeoColumnMeta, type GeoParquetMeta, type GeoType, type HexRow, LAYER_HUE_MULTIPLIER, type ListPage, MAX_QUERY_HISTORY_ENTRIES, type MapQueryHandle, type MapQueryResult, PROVIDERS, PROVIDER_IDS, type ParquetFileMetadata, type ParsedGeometry, type ParsedMarkdownDocument, type ParsedStorageUrl, type ProviderDef, type ProviderId, type ProviderRegion, QueryCancelledError, type QueryEngine, type QueryHandle, type QueryResult, SQL_PREVIEW_LENGTH, STORAGE_KEYS, type SchemaField, type SortConfig, type SortDirection, type SortField, type SqlBlock, type StorageAdapter, type StorageProvider, type Tab, type Theme, type TypeCategory, UrlAdapter, VIEWER_DIR_EXTENSIONS, type ViewerKind, WGS84_CODES, type WriteResult, buildDuckDbSource, buildEndpointFromTemplate, buildGeoArrowTables, buildProviderBaseUrl, classifyType, describeParseResult, escapeCsvField, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, formatValue, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getNativeScheme, getProvider, getViewerKind, handleLoadError, interpolateTemplates, isCloudNativeFormat, isGcsProvider, isQueryable, jsonReplacerBigInt, loadFromStorage, looksLikeUrl, markSqlBlocks, normalizeGeomType, parseMarkdownDocument, parseStorageUrl, parseWKB, persistToStorage, readParquetMetadata, resolveCloudUrl, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -208,6 +208,60 @@ interface StorageAdapter {
|
|
|
208
208
|
readonly supportsWrite: boolean;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Provider registry — single source of truth for all cloud storage providers.
|
|
213
|
+
*
|
|
214
|
+
* Centralizes endpoint patterns, regions, auth methods, and UI metadata.
|
|
215
|
+
* Used by ConnectionDialog, browser-cloud adapter, host-detection, url-state, etc.
|
|
216
|
+
*/
|
|
217
|
+
type ProviderId = 's3' | 'gcs' | 'r2' | 'minio' | 'azure' | 'storj' | 'b2' | 'digitalocean' | 'wasabi' | 'contabo' | 'hetzner' | 'linode' | 'ovhcloud';
|
|
218
|
+
interface ProviderRegion {
|
|
219
|
+
code: string;
|
|
220
|
+
label: string;
|
|
221
|
+
}
|
|
222
|
+
interface ProviderDef {
|
|
223
|
+
/** Display label in the UI. */
|
|
224
|
+
label: string;
|
|
225
|
+
/** Short description shown as helper text. */
|
|
226
|
+
description: string;
|
|
227
|
+
/** Auth method used by this provider. */
|
|
228
|
+
authMethod: 'sigv4' | 'sas-token';
|
|
229
|
+
/** Whether the region field is relevant for this provider. */
|
|
230
|
+
needsRegion: boolean;
|
|
231
|
+
/** Whether the endpoint field is required. */
|
|
232
|
+
needsEndpoint: boolean;
|
|
233
|
+
/** Default region when creating a new connection. */
|
|
234
|
+
defaultRegion: string;
|
|
235
|
+
/**
|
|
236
|
+
* Endpoint template with `{region}` placeholder.
|
|
237
|
+
* If null, the user must provide a custom endpoint (e.g. MinIO).
|
|
238
|
+
* If a fixed string (no `{region}`), it's always the same (e.g. GCS).
|
|
239
|
+
*/
|
|
240
|
+
endpointTemplate: string | null;
|
|
241
|
+
/** Known regions with labels. Empty = free-form region input. */
|
|
242
|
+
regions: ProviderRegion[];
|
|
243
|
+
/** Bucket label override (e.g. Azure uses "Container"). */
|
|
244
|
+
bucketLabel?: string;
|
|
245
|
+
/** Default endpoint placeholder shown in the input. */
|
|
246
|
+
endpointPlaceholder: string;
|
|
247
|
+
/** URI schemes that map to this provider (lowercase, without "://"). */
|
|
248
|
+
schemes: string[];
|
|
249
|
+
}
|
|
250
|
+
declare const PROVIDERS: Record<ProviderId, ProviderDef>;
|
|
251
|
+
/** All provider IDs, ordered for the UI. */
|
|
252
|
+
declare const PROVIDER_IDS: ProviderId[];
|
|
253
|
+
/** Get provider def, falling back to S3 for unknown. */
|
|
254
|
+
declare function getProvider(id: string): ProviderDef;
|
|
255
|
+
/** Build endpoint URL from template + region. */
|
|
256
|
+
declare function buildEndpointFromTemplate(id: ProviderId, region: string): string;
|
|
257
|
+
/**
|
|
258
|
+
* Build the base URL for API requests (endpoint + bucket).
|
|
259
|
+
* Used by browser-cloud adapter and url-state.
|
|
260
|
+
*/
|
|
261
|
+
declare function buildProviderBaseUrl(provider: ProviderId, endpoint: string, bucket: string, region: string): string;
|
|
262
|
+
/** Check if a provider uses the GCS JSON API (not S3 XML). */
|
|
263
|
+
declare function isGcsProvider(provider: string, endpoint: string): boolean;
|
|
264
|
+
|
|
211
265
|
/**
|
|
212
266
|
* Minimal adapter for direct HTTPS URLs (source: 'url').
|
|
213
267
|
* Only supports read/head — no listing or writing.
|
|
@@ -226,6 +280,34 @@ declare class UrlAdapter implements StorageAdapter {
|
|
|
226
280
|
copy(): Promise<WriteResult>;
|
|
227
281
|
}
|
|
228
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Cloud storage protocol URL utilities — pure TS, no Svelte dependency.
|
|
285
|
+
*
|
|
286
|
+
* Converts cloud protocol URLs (s3://, gs://) to HTTPS URLs for browser access.
|
|
287
|
+
* Provider-aware native scheme lookup.
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* Map provider to its native URI scheme prefix.
|
|
291
|
+
* Derived from the registry's `schemes` array (first entry is the primary scheme).
|
|
292
|
+
* Falls back to 's3' for providers without a scheme (S3-compatible).
|
|
293
|
+
*/
|
|
294
|
+
declare function getNativeScheme(provider: string): string;
|
|
295
|
+
/**
|
|
296
|
+
* Safely decode a percent-encoded URI component.
|
|
297
|
+
* Returns the original string if decoding fails (malformed sequences).
|
|
298
|
+
*/
|
|
299
|
+
declare function safeDecodeURIComponent(s: string): string;
|
|
300
|
+
/**
|
|
301
|
+
* Convert a cloud storage protocol URL (s3://, gs://) to an HTTPS URL
|
|
302
|
+
* for browser access. Returns the original URL if already HTTP(S) or unknown.
|
|
303
|
+
*
|
|
304
|
+
* Supported:
|
|
305
|
+
* - `s3://bucket/key` → `https://s3.{region}.amazonaws.com/{bucket}/{key}`
|
|
306
|
+
* (region auto-detected from bucket name when possible)
|
|
307
|
+
* - `gs://bucket/key` → `https://storage.googleapis.com/{bucket}/{key}`
|
|
308
|
+
*/
|
|
309
|
+
declare function resolveCloudUrl(url: string): string;
|
|
310
|
+
|
|
229
311
|
type TypeCategory = 'number' | 'string' | 'date' | 'boolean' | 'geo' | 'binary' | 'json' | 'other';
|
|
230
312
|
declare function classifyType(duckdbType: string): TypeCategory;
|
|
231
313
|
declare function typeColor(category: TypeCategory): string;
|
|
@@ -241,6 +323,42 @@ declare function typeLabel(category: TypeCategory): string;
|
|
|
241
323
|
*/
|
|
242
324
|
declare function handleLoadError(err: unknown): string | null;
|
|
243
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Escape a CSV field value per RFC 4180.
|
|
328
|
+
*/
|
|
329
|
+
declare function escapeCsvField(value: string): string;
|
|
330
|
+
/**
|
|
331
|
+
* Serialize column/row data to a CSV string.
|
|
332
|
+
* Pure function — no browser APIs, works in Node.js.
|
|
333
|
+
*/
|
|
334
|
+
declare function serializeToCsv(columns: string[], rows: Record<string, unknown>[]): string;
|
|
335
|
+
/**
|
|
336
|
+
* Serialize column/row data to a formatted JSON string.
|
|
337
|
+
* Pure function — no browser APIs, works in Node.js.
|
|
338
|
+
*/
|
|
339
|
+
declare function serializeToJson(columns: string[], rows: Record<string, unknown>[]): string;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Pure file entry sorting — framework-agnostic, works in Node.js.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
type SortField = 'name' | 'size' | 'modified' | 'extension';
|
|
346
|
+
type SortDirection = 'asc' | 'desc';
|
|
347
|
+
interface SortConfig {
|
|
348
|
+
field: SortField;
|
|
349
|
+
direction: SortDirection;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Sort file entries by the given config.
|
|
353
|
+
* Directories always sort before files regardless of sort field.
|
|
354
|
+
* Returns a new array (does not mutate the input).
|
|
355
|
+
*/
|
|
356
|
+
declare function sortFileEntries(entries: FileEntry[], config: SortConfig): FileEntry[];
|
|
357
|
+
/**
|
|
358
|
+
* Toggle sort config: same field flips direction, new field starts ascending.
|
|
359
|
+
*/
|
|
360
|
+
declare function toggleSortField(current: SortConfig, field: SortField): SortConfig;
|
|
361
|
+
|
|
244
362
|
/**
|
|
245
363
|
* Formats a byte count into a human-readable string.
|
|
246
364
|
*/
|
|
@@ -310,6 +428,54 @@ interface HexRow {
|
|
|
310
428
|
*/
|
|
311
429
|
declare function generateHexDump(data: Uint8Array, bytesPerRow?: number): HexRow[];
|
|
312
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Generic localStorage helpers with SSR safety.
|
|
433
|
+
*
|
|
434
|
+
* Used by connection, settings, and query-history stores to avoid
|
|
435
|
+
* repeating the same load/persist/try-catch/SSR-guard pattern.
|
|
436
|
+
*/
|
|
437
|
+
/**
|
|
438
|
+
* Load a JSON value from localStorage.
|
|
439
|
+
* Returns `defaultValue` on SSR, missing key, or parse error.
|
|
440
|
+
*/
|
|
441
|
+
declare function loadFromStorage<T>(key: string, defaultValue: T): T;
|
|
442
|
+
/**
|
|
443
|
+
* Persist a JSON-serializable value to localStorage.
|
|
444
|
+
* Silently no-ops on SSR or storage errors (quota, private browsing).
|
|
445
|
+
*/
|
|
446
|
+
declare function persistToStorage(key: string, value: unknown): void;
|
|
447
|
+
|
|
448
|
+
interface SqlBlock {
|
|
449
|
+
name: string;
|
|
450
|
+
sql: string;
|
|
451
|
+
startLine: number;
|
|
452
|
+
endLine: number;
|
|
453
|
+
}
|
|
454
|
+
interface ParsedMarkdownDocument {
|
|
455
|
+
frontmatter: Record<string, any>;
|
|
456
|
+
content: string;
|
|
457
|
+
sqlBlocks: SqlBlock[];
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Parse a markdown document with YAML frontmatter and SQL code blocks.
|
|
461
|
+
*
|
|
462
|
+
* Evidence-compatible syntax:
|
|
463
|
+
* ```sql query_name
|
|
464
|
+
* SELECT * FROM table
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
declare function parseMarkdownDocument(markdown: string): ParsedMarkdownDocument;
|
|
468
|
+
/**
|
|
469
|
+
* Interpolate template variables in markdown text.
|
|
470
|
+
* Supports {queryName.rows[0].columnName} syntax.
|
|
471
|
+
*/
|
|
472
|
+
declare function interpolateTemplates(text: string, queryResults: Map<string, Record<string, any>[]>): string;
|
|
473
|
+
/**
|
|
474
|
+
* Replace SQL blocks in markdown content with placeholder markers
|
|
475
|
+
* that can be replaced with rendered components.
|
|
476
|
+
*/
|
|
477
|
+
declare function markSqlBlocks(content: string): string;
|
|
478
|
+
|
|
313
479
|
/**
|
|
314
480
|
* Lightweight Parquet metadata reader using hyparquet.
|
|
315
481
|
*
|
|
@@ -478,4 +644,4 @@ declare function findGeoColumnFromRows(rows: Record<string, unknown>[], schema:
|
|
|
478
644
|
type: string;
|
|
479
645
|
}[]): string | null;
|
|
480
646
|
|
|
481
|
-
export { COPY_FEEDBACK_MS, type Connection, type ConnectionConfig, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, type Defaults, type DuckDbReadFn, type FileCategory, type FileEntry, type FileTypeInfo, type GeoArrowGeomType, type GeoArrowResult, type GeoColumnMeta, type GeoParquetMeta, type GeoType, type HexRow, LAYER_HUE_MULTIPLIER, type ListPage, MAX_QUERY_HISTORY_ENTRIES, type MapQueryHandle, type MapQueryResult, type ParquetFileMetadata, type ParsedGeometry, type ParsedStorageUrl, QueryCancelledError, type QueryEngine, type QueryHandle, type QueryResult, SQL_PREVIEW_LENGTH, STORAGE_KEYS, type SchemaField, type StorageAdapter, type StorageProvider, type Tab, type Theme, type TypeCategory, UrlAdapter, VIEWER_DIR_EXTENSIONS, type ViewerKind, WGS84_CODES, type WriteResult, buildDuckDbSource, buildGeoArrowTables, classifyType, describeParseResult, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, formatValue, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getViewerKind, handleLoadError, isCloudNativeFormat, isQueryable, jsonReplacerBigInt, looksLikeUrl, normalizeGeomType, parseStorageUrl, parseWKB, readParquetMetadata, toBinary, typeBadgeClass, typeColor, typeLabel };
|
|
647
|
+
export { COPY_FEEDBACK_MS, type Connection, type ConnectionConfig, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, type Defaults, type DuckDbReadFn, type FileCategory, type FileEntry, type FileTypeInfo, type GeoArrowGeomType, type GeoArrowResult, type GeoColumnMeta, type GeoParquetMeta, type GeoType, type HexRow, LAYER_HUE_MULTIPLIER, type ListPage, MAX_QUERY_HISTORY_ENTRIES, type MapQueryHandle, type MapQueryResult, PROVIDERS, PROVIDER_IDS, type ParquetFileMetadata, type ParsedGeometry, type ParsedMarkdownDocument, type ParsedStorageUrl, type ProviderDef, type ProviderId, type ProviderRegion, QueryCancelledError, type QueryEngine, type QueryHandle, type QueryResult, SQL_PREVIEW_LENGTH, STORAGE_KEYS, type SchemaField, type SortConfig, type SortDirection, type SortField, type SqlBlock, type StorageAdapter, type StorageProvider, type Tab, type Theme, type TypeCategory, UrlAdapter, VIEWER_DIR_EXTENSIONS, type ViewerKind, WGS84_CODES, type WriteResult, buildDuckDbSource, buildEndpointFromTemplate, buildGeoArrowTables, buildProviderBaseUrl, classifyType, describeParseResult, escapeCsvField, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, formatValue, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getNativeScheme, getProvider, getViewerKind, handleLoadError, interpolateTemplates, isCloudNativeFormat, isGcsProvider, isQueryable, jsonReplacerBigInt, loadFromStorage, looksLikeUrl, markSqlBlocks, normalizeGeomType, parseMarkdownDocument, parseStorageUrl, parseWKB, persistToStorage, readParquetMetadata, resolveCloudUrl, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
|