@walkthru-earth/objex-utils 1.1.0 → 1.2.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 +46 -39
- package/dist/index.cjs +48 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -8
- package/dist/index.d.ts +65 -8
- package/dist/index.js +44 -5
- package/dist/index.js.map +1 -1
- package/docs/README.md +102 -0
- package/docs/cog.md +303 -0
- package/docs/errors.md +34 -0
- package/docs/file-sort.md +67 -0
- package/docs/file-types.md +141 -0
- package/docs/formatting.md +192 -0
- package/docs/geometry.md +198 -0
- package/docs/local-storage.md +51 -0
- package/docs/markdown-sql.md +109 -0
- package/docs/parquet-metadata.md +133 -0
- package/docs/query-engine.md +140 -0
- package/docs/storage.md +251 -0
- package/docs/types-constants.md +173 -0
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -11,8 +11,12 @@ declare const STORAGE_KEYS: {
|
|
|
11
11
|
};
|
|
12
12
|
/** EPSG codes considered WGS84 (no reprojection needed). */
|
|
13
13
|
declare const WGS84_CODES: Set<number>;
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Default target CRS for ST_Transform. Uses OGC:CRS84 (longitude, latitude)
|
|
16
|
+
* to match GeoParquet 1.1+ spec and DuckDB v1.5's canonical form.
|
|
17
|
+
* Functionally equivalent to EPSG:4326 under `geometry_always_xy = true`.
|
|
18
|
+
*/
|
|
19
|
+
declare const DEFAULT_TARGET_CRS = "OGC:CRS84";
|
|
16
20
|
/** DuckDB-WASM initialization timeout in ms. */
|
|
17
21
|
declare const DUCKDB_INIT_TIMEOUT_MS = 30000;
|
|
18
22
|
/** Maximum entries kept in query history. */
|
|
@@ -119,15 +123,27 @@ interface SchemaField {
|
|
|
119
123
|
type: string;
|
|
120
124
|
nullable: boolean;
|
|
121
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Abstraction over a DuckDB query source. Decouples schema / CRS / count
|
|
128
|
+
* helpers from assuming a file-backed path. `ref` is the FROM-clause target
|
|
129
|
+
* inserted into generated SQL (e.g. `read_parquet('url')` for files, or
|
|
130
|
+
* `attached_db."schema"."table"` for attached databases). `filePath` is
|
|
131
|
+
* optional and only used as a shortcut for Parquet file-level metadata
|
|
132
|
+
* queries (`parquet_kv_metadata`, `parquet_file_metadata`), not for SQL.
|
|
133
|
+
*/
|
|
134
|
+
interface QuerySource {
|
|
135
|
+
ref: string;
|
|
136
|
+
filePath?: string;
|
|
137
|
+
}
|
|
122
138
|
interface QueryEngine {
|
|
123
139
|
query(connId: string, sql: string): Promise<QueryResult>;
|
|
124
140
|
queryForMap(connId: string, sql: string, geomCol: string, geomColType: string, sourceCrs?: string | null): Promise<MapQueryResult>;
|
|
125
|
-
getSchema(connId: string,
|
|
126
|
-
getRowCount(connId: string,
|
|
141
|
+
getSchema(connId: string, source: QuerySource): Promise<SchemaField[]>;
|
|
142
|
+
getRowCount(connId: string, source: QuerySource): Promise<number>;
|
|
127
143
|
/** Detect CRS from GeoParquet metadata. Returns e.g. 'EPSG:27700' or null if WGS84/unknown. */
|
|
128
|
-
detectCrs(connId: string,
|
|
144
|
+
detectCrs(connId: string, source: QuerySource, geomCol: string): Promise<string | null>;
|
|
129
145
|
/** Combined schema + CRS detection in a single connection (fewer web worker round-trips). */
|
|
130
|
-
getSchemaAndCrs?(connId: string,
|
|
146
|
+
getSchemaAndCrs?(connId: string, source: QuerySource, findGeoCol: (schema: SchemaField[]) => string | null): Promise<{
|
|
131
147
|
schema: SchemaField[];
|
|
132
148
|
geomCol: string | null;
|
|
133
149
|
crs: string | null;
|
|
@@ -135,6 +151,10 @@ interface QueryEngine {
|
|
|
135
151
|
queryCancellable?(connId: string, sql: string): QueryHandle;
|
|
136
152
|
queryForMapCancellable?(connId: string, sql: string, geomCol: string, geomColType: string, sourceCrs?: string | null): MapQueryHandle;
|
|
137
153
|
forceCancel?(): Promise<void>;
|
|
154
|
+
/** Register a file buffer in DuckDB-WASM's virtual filesystem for ATTACH. */
|
|
155
|
+
registerFileBuffer?(name: string, buffer: Uint8Array): Promise<void>;
|
|
156
|
+
/** Drop a previously registered file from DuckDB-WASM's virtual filesystem. */
|
|
157
|
+
dropFile?(name: string): Promise<void>;
|
|
138
158
|
releaseMemory(): Promise<void>;
|
|
139
159
|
dispose(): Promise<void>;
|
|
140
160
|
}
|
|
@@ -179,6 +199,17 @@ interface Tab {
|
|
|
179
199
|
connectionId?: string;
|
|
180
200
|
extension: string;
|
|
181
201
|
size?: number;
|
|
202
|
+
/**
|
|
203
|
+
* When set, the tab reads data from a SQL FROM-clause target (e.g. an
|
|
204
|
+
* attached DuckLake/DuckDB/SQLite table) rather than a file URL. The ref
|
|
205
|
+
* is inserted directly into generated SQL, so it must be fully-qualified
|
|
206
|
+
* and pre-quoted, e.g. `__objex_db__."main"."air_quality"`.
|
|
207
|
+
*
|
|
208
|
+
* When `sourceRef` is set, file-specific loading paths (hyparquet
|
|
209
|
+
* metadata, `parquet_kv_metadata`, etc.) are skipped, and schema / CRS /
|
|
210
|
+
* row count are derived from the SQL source directly via DuckDB.
|
|
211
|
+
*/
|
|
212
|
+
sourceRef?: string;
|
|
182
213
|
}
|
|
183
214
|
interface WriteResult {
|
|
184
215
|
key: string;
|
|
@@ -308,6 +339,32 @@ declare function safeDecodeURIComponent(s: string): string;
|
|
|
308
339
|
*/
|
|
309
340
|
declare function resolveCloudUrl(url: string): string;
|
|
310
341
|
|
|
342
|
+
/** SampleFormat tag value → human label. */
|
|
343
|
+
declare const SF_LABELS: Record<number, string>;
|
|
344
|
+
interface GeoBounds {
|
|
345
|
+
west: number;
|
|
346
|
+
south: number;
|
|
347
|
+
east: number;
|
|
348
|
+
north: number;
|
|
349
|
+
}
|
|
350
|
+
interface CogInfo {
|
|
351
|
+
width: number;
|
|
352
|
+
height: number;
|
|
353
|
+
bandCount: number;
|
|
354
|
+
dataType: string;
|
|
355
|
+
bounds: GeoBounds;
|
|
356
|
+
downsampled?: boolean;
|
|
357
|
+
}
|
|
358
|
+
/** Safely clamp a number to a range, treating NaN/Infinity as the fallback. */
|
|
359
|
+
declare function safeClamp(v: number, lo: number, hi: number, fallback: number): number;
|
|
360
|
+
/** Clamp geographic bounds to valid MapLibre web-Mercator range. */
|
|
361
|
+
declare function clampBounds(b: GeoBounds): GeoBounds;
|
|
362
|
+
/**
|
|
363
|
+
* Build a data-type label from GeoTIFF sample format and bits per sample.
|
|
364
|
+
* e.g. "uint8", "float32", "int16"
|
|
365
|
+
*/
|
|
366
|
+
declare function buildDataTypeLabel(sampleFormat: number, bitsPerSample: number): string;
|
|
367
|
+
|
|
311
368
|
type TypeCategory = 'number' | 'string' | 'date' | 'boolean' | 'geo' | 'binary' | 'json' | 'other';
|
|
312
369
|
declare function classifyType(duckdbType: string): TypeCategory;
|
|
313
370
|
declare function typeColor(category: TypeCategory): string;
|
|
@@ -464,7 +521,7 @@ interface ParsedMarkdownDocument {
|
|
|
464
521
|
* SELECT * FROM table
|
|
465
522
|
* ```
|
|
466
523
|
*/
|
|
467
|
-
declare function parseMarkdownDocument(markdown: string): ParsedMarkdownDocument
|
|
524
|
+
declare function parseMarkdownDocument(markdown: string): Promise<ParsedMarkdownDocument>;
|
|
468
525
|
/**
|
|
469
526
|
* Interpolate template variables in markdown text.
|
|
470
527
|
* Supports {queryName.rows[0].columnName} syntax.
|
|
@@ -644,4 +701,4 @@ declare function findGeoColumnFromRows(rows: Record<string, unknown>[], schema:
|
|
|
644
701
|
type: string;
|
|
645
702
|
}[]): string | null;
|
|
646
703
|
|
|
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 };
|
|
704
|
+
export { COPY_FEEDBACK_MS, type CogInfo, 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 GeoBounds, 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, SF_LABELS, 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, buildDataTypeLabel, buildDuckDbSource, buildEndpointFromTemplate, buildGeoArrowTables, buildProviderBaseUrl, clampBounds, 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, safeClamp, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,12 @@ declare const STORAGE_KEYS: {
|
|
|
11
11
|
};
|
|
12
12
|
/** EPSG codes considered WGS84 (no reprojection needed). */
|
|
13
13
|
declare const WGS84_CODES: Set<number>;
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Default target CRS for ST_Transform. Uses OGC:CRS84 (longitude, latitude)
|
|
16
|
+
* to match GeoParquet 1.1+ spec and DuckDB v1.5's canonical form.
|
|
17
|
+
* Functionally equivalent to EPSG:4326 under `geometry_always_xy = true`.
|
|
18
|
+
*/
|
|
19
|
+
declare const DEFAULT_TARGET_CRS = "OGC:CRS84";
|
|
16
20
|
/** DuckDB-WASM initialization timeout in ms. */
|
|
17
21
|
declare const DUCKDB_INIT_TIMEOUT_MS = 30000;
|
|
18
22
|
/** Maximum entries kept in query history. */
|
|
@@ -119,15 +123,27 @@ interface SchemaField {
|
|
|
119
123
|
type: string;
|
|
120
124
|
nullable: boolean;
|
|
121
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Abstraction over a DuckDB query source. Decouples schema / CRS / count
|
|
128
|
+
* helpers from assuming a file-backed path. `ref` is the FROM-clause target
|
|
129
|
+
* inserted into generated SQL (e.g. `read_parquet('url')` for files, or
|
|
130
|
+
* `attached_db."schema"."table"` for attached databases). `filePath` is
|
|
131
|
+
* optional and only used as a shortcut for Parquet file-level metadata
|
|
132
|
+
* queries (`parquet_kv_metadata`, `parquet_file_metadata`), not for SQL.
|
|
133
|
+
*/
|
|
134
|
+
interface QuerySource {
|
|
135
|
+
ref: string;
|
|
136
|
+
filePath?: string;
|
|
137
|
+
}
|
|
122
138
|
interface QueryEngine {
|
|
123
139
|
query(connId: string, sql: string): Promise<QueryResult>;
|
|
124
140
|
queryForMap(connId: string, sql: string, geomCol: string, geomColType: string, sourceCrs?: string | null): Promise<MapQueryResult>;
|
|
125
|
-
getSchema(connId: string,
|
|
126
|
-
getRowCount(connId: string,
|
|
141
|
+
getSchema(connId: string, source: QuerySource): Promise<SchemaField[]>;
|
|
142
|
+
getRowCount(connId: string, source: QuerySource): Promise<number>;
|
|
127
143
|
/** Detect CRS from GeoParquet metadata. Returns e.g. 'EPSG:27700' or null if WGS84/unknown. */
|
|
128
|
-
detectCrs(connId: string,
|
|
144
|
+
detectCrs(connId: string, source: QuerySource, geomCol: string): Promise<string | null>;
|
|
129
145
|
/** Combined schema + CRS detection in a single connection (fewer web worker round-trips). */
|
|
130
|
-
getSchemaAndCrs?(connId: string,
|
|
146
|
+
getSchemaAndCrs?(connId: string, source: QuerySource, findGeoCol: (schema: SchemaField[]) => string | null): Promise<{
|
|
131
147
|
schema: SchemaField[];
|
|
132
148
|
geomCol: string | null;
|
|
133
149
|
crs: string | null;
|
|
@@ -135,6 +151,10 @@ interface QueryEngine {
|
|
|
135
151
|
queryCancellable?(connId: string, sql: string): QueryHandle;
|
|
136
152
|
queryForMapCancellable?(connId: string, sql: string, geomCol: string, geomColType: string, sourceCrs?: string | null): MapQueryHandle;
|
|
137
153
|
forceCancel?(): Promise<void>;
|
|
154
|
+
/** Register a file buffer in DuckDB-WASM's virtual filesystem for ATTACH. */
|
|
155
|
+
registerFileBuffer?(name: string, buffer: Uint8Array): Promise<void>;
|
|
156
|
+
/** Drop a previously registered file from DuckDB-WASM's virtual filesystem. */
|
|
157
|
+
dropFile?(name: string): Promise<void>;
|
|
138
158
|
releaseMemory(): Promise<void>;
|
|
139
159
|
dispose(): Promise<void>;
|
|
140
160
|
}
|
|
@@ -179,6 +199,17 @@ interface Tab {
|
|
|
179
199
|
connectionId?: string;
|
|
180
200
|
extension: string;
|
|
181
201
|
size?: number;
|
|
202
|
+
/**
|
|
203
|
+
* When set, the tab reads data from a SQL FROM-clause target (e.g. an
|
|
204
|
+
* attached DuckLake/DuckDB/SQLite table) rather than a file URL. The ref
|
|
205
|
+
* is inserted directly into generated SQL, so it must be fully-qualified
|
|
206
|
+
* and pre-quoted, e.g. `__objex_db__."main"."air_quality"`.
|
|
207
|
+
*
|
|
208
|
+
* When `sourceRef` is set, file-specific loading paths (hyparquet
|
|
209
|
+
* metadata, `parquet_kv_metadata`, etc.) are skipped, and schema / CRS /
|
|
210
|
+
* row count are derived from the SQL source directly via DuckDB.
|
|
211
|
+
*/
|
|
212
|
+
sourceRef?: string;
|
|
182
213
|
}
|
|
183
214
|
interface WriteResult {
|
|
184
215
|
key: string;
|
|
@@ -308,6 +339,32 @@ declare function safeDecodeURIComponent(s: string): string;
|
|
|
308
339
|
*/
|
|
309
340
|
declare function resolveCloudUrl(url: string): string;
|
|
310
341
|
|
|
342
|
+
/** SampleFormat tag value → human label. */
|
|
343
|
+
declare const SF_LABELS: Record<number, string>;
|
|
344
|
+
interface GeoBounds {
|
|
345
|
+
west: number;
|
|
346
|
+
south: number;
|
|
347
|
+
east: number;
|
|
348
|
+
north: number;
|
|
349
|
+
}
|
|
350
|
+
interface CogInfo {
|
|
351
|
+
width: number;
|
|
352
|
+
height: number;
|
|
353
|
+
bandCount: number;
|
|
354
|
+
dataType: string;
|
|
355
|
+
bounds: GeoBounds;
|
|
356
|
+
downsampled?: boolean;
|
|
357
|
+
}
|
|
358
|
+
/** Safely clamp a number to a range, treating NaN/Infinity as the fallback. */
|
|
359
|
+
declare function safeClamp(v: number, lo: number, hi: number, fallback: number): number;
|
|
360
|
+
/** Clamp geographic bounds to valid MapLibre web-Mercator range. */
|
|
361
|
+
declare function clampBounds(b: GeoBounds): GeoBounds;
|
|
362
|
+
/**
|
|
363
|
+
* Build a data-type label from GeoTIFF sample format and bits per sample.
|
|
364
|
+
* e.g. "uint8", "float32", "int16"
|
|
365
|
+
*/
|
|
366
|
+
declare function buildDataTypeLabel(sampleFormat: number, bitsPerSample: number): string;
|
|
367
|
+
|
|
311
368
|
type TypeCategory = 'number' | 'string' | 'date' | 'boolean' | 'geo' | 'binary' | 'json' | 'other';
|
|
312
369
|
declare function classifyType(duckdbType: string): TypeCategory;
|
|
313
370
|
declare function typeColor(category: TypeCategory): string;
|
|
@@ -464,7 +521,7 @@ interface ParsedMarkdownDocument {
|
|
|
464
521
|
* SELECT * FROM table
|
|
465
522
|
* ```
|
|
466
523
|
*/
|
|
467
|
-
declare function parseMarkdownDocument(markdown: string): ParsedMarkdownDocument
|
|
524
|
+
declare function parseMarkdownDocument(markdown: string): Promise<ParsedMarkdownDocument>;
|
|
468
525
|
/**
|
|
469
526
|
* Interpolate template variables in markdown text.
|
|
470
527
|
* Supports {queryName.rows[0].columnName} syntax.
|
|
@@ -644,4 +701,4 @@ declare function findGeoColumnFromRows(rows: Record<string, unknown>[], schema:
|
|
|
644
701
|
type: string;
|
|
645
702
|
}[]): string | null;
|
|
646
703
|
|
|
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 };
|
|
704
|
+
export { COPY_FEEDBACK_MS, type CogInfo, 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 GeoBounds, 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, SF_LABELS, 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, buildDataTypeLabel, buildDuckDbSource, buildEndpointFromTemplate, buildGeoArrowTables, buildProviderBaseUrl, clampBounds, 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, safeClamp, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import '@developmentseed/epsg/all';
|
|
2
|
+
import '@developmentseed/epsg/all.csv.gz?url';
|
|
3
|
+
import '@developmentseed/geotiff';
|
|
4
|
+
import '@developmentseed/proj';
|
|
5
|
+
import 'proj4';
|
|
1
6
|
import { Field, Float64, FixedSizeList, Schema, Struct, makeData, RecordBatch, Table, List, Utf8 } from 'apache-arrow';
|
|
2
|
-
import YAML from 'yaml';
|
|
3
7
|
|
|
4
8
|
// ../../src/lib/constants.ts
|
|
5
9
|
var STORAGE_KEYS = {
|
|
@@ -8,7 +12,7 @@ var STORAGE_KEYS = {
|
|
|
8
12
|
QUERY_HISTORY: "obstore-explore-query-history"
|
|
9
13
|
};
|
|
10
14
|
var WGS84_CODES = /* @__PURE__ */ new Set([4326, 4979]);
|
|
11
|
-
var DEFAULT_TARGET_CRS = "
|
|
15
|
+
var DEFAULT_TARGET_CRS = "OGC:CRS84";
|
|
12
16
|
var DUCKDB_INIT_TIMEOUT_MS = 3e4;
|
|
13
17
|
var MAX_QUERY_HISTORY_ENTRIES = 200;
|
|
14
18
|
var SQL_PREVIEW_LENGTH = 120;
|
|
@@ -888,6 +892,16 @@ var EXTENSIONS = {
|
|
|
888
892
|
duckdbReadFn: null,
|
|
889
893
|
mimeType: "application/octet-stream"
|
|
890
894
|
},
|
|
895
|
+
".ducklake": {
|
|
896
|
+
icon: "Database",
|
|
897
|
+
color: "text-teal-600 dark:text-teal-400",
|
|
898
|
+
label: "DuckLake",
|
|
899
|
+
category: "database",
|
|
900
|
+
viewer: "database",
|
|
901
|
+
queryable: true,
|
|
902
|
+
duckdbReadFn: null,
|
|
903
|
+
mimeType: "application/octet-stream"
|
|
904
|
+
},
|
|
891
905
|
".sqlite": {
|
|
892
906
|
icon: "Database",
|
|
893
907
|
color: "text-sky-600 dark:text-sky-400",
|
|
@@ -1035,7 +1049,7 @@ function buildDuckDbSource(pathOrExt, url) {
|
|
|
1035
1049
|
const readFn = EXTENSIONS[ext]?.duckdbReadFn ?? "read_parquet";
|
|
1036
1050
|
return `${readFn}('${url}')`;
|
|
1037
1051
|
}
|
|
1038
|
-
var CLOUD_NATIVE_EXTS = /* @__PURE__ */ new Set([".parquet", ".geoparquet", ".gpq", ".gparquet"]);
|
|
1052
|
+
var CLOUD_NATIVE_EXTS = /* @__PURE__ */ new Set([".parquet", ".geoparquet", ".gpq", ".gparquet", ".ducklake"]);
|
|
1039
1053
|
function isCloudNativeFormat(pathOrExt) {
|
|
1040
1054
|
const ext = pathOrExt.includes(".") ? `.${pathOrExt.split(".").pop().toLowerCase()}` : "";
|
|
1041
1055
|
return CLOUD_NATIVE_EXTS.has(ext);
|
|
@@ -1432,6 +1446,28 @@ function resolveCloudUrl(url) {
|
|
|
1432
1446
|
}
|
|
1433
1447
|
return url;
|
|
1434
1448
|
}
|
|
1449
|
+
var SF_LABELS = {
|
|
1450
|
+
1: "uint",
|
|
1451
|
+
2: "int",
|
|
1452
|
+
3: "float",
|
|
1453
|
+
4: "void",
|
|
1454
|
+
5: "complex int",
|
|
1455
|
+
6: "complex float"
|
|
1456
|
+
};
|
|
1457
|
+
function safeClamp(v, lo, hi, fallback) {
|
|
1458
|
+
return Number.isFinite(v) ? Math.max(lo, Math.min(hi, v)) : fallback;
|
|
1459
|
+
}
|
|
1460
|
+
function clampBounds(b) {
|
|
1461
|
+
return {
|
|
1462
|
+
west: safeClamp(b.west, -180, 180, -180),
|
|
1463
|
+
south: safeClamp(b.south, -85.051129, 85.051129, -85.051129),
|
|
1464
|
+
east: safeClamp(b.east, -180, 180, 180),
|
|
1465
|
+
north: safeClamp(b.north, -85.051129, 85.051129, 85.051129)
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
function buildDataTypeLabel(sampleFormat, bitsPerSample) {
|
|
1469
|
+
return `${SF_LABELS[sampleFormat] ?? `sf${sampleFormat}`}${bitsPerSample ?? ""}`;
|
|
1470
|
+
}
|
|
1435
1471
|
|
|
1436
1472
|
// ../../src/lib/utils/column-types.ts
|
|
1437
1473
|
var NUMBER_TYPES = [
|
|
@@ -2283,12 +2319,15 @@ function persistToStorage(key, value) {
|
|
|
2283
2319
|
} catch {
|
|
2284
2320
|
}
|
|
2285
2321
|
}
|
|
2286
|
-
|
|
2322
|
+
|
|
2323
|
+
// ../../src/lib/utils/markdown-sql.ts
|
|
2324
|
+
async function parseMarkdownDocument(markdown) {
|
|
2287
2325
|
let frontmatter = {};
|
|
2288
2326
|
let content = markdown;
|
|
2289
2327
|
const fmMatch = markdown.match(/^---\n([\s\S]*?)\n---\n/);
|
|
2290
2328
|
if (fmMatch) {
|
|
2291
2329
|
try {
|
|
2330
|
+
const { default: YAML } = await import('yaml');
|
|
2292
2331
|
frontmatter = YAML.parse(fmMatch[1]) || {};
|
|
2293
2332
|
} catch {
|
|
2294
2333
|
}
|
|
@@ -3053,6 +3092,6 @@ function isWKT(value) {
|
|
|
3053
3092
|
return WKT_TYPES.some((t) => s.startsWith(t) || s.startsWith(`MULTI${t}`));
|
|
3054
3093
|
}
|
|
3055
3094
|
|
|
3056
|
-
export { COPY_FEEDBACK_MS, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, LAYER_HUE_MULTIPLIER, MAX_QUERY_HISTORY_ENTRIES, PROVIDERS, PROVIDER_IDS, QueryCancelledError, SQL_PREVIEW_LENGTH, STORAGE_KEYS, UrlAdapter, VIEWER_DIR_EXTENSIONS, WGS84_CODES, 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 };
|
|
3095
|
+
export { COPY_FEEDBACK_MS, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, LAYER_HUE_MULTIPLIER, MAX_QUERY_HISTORY_ENTRIES, PROVIDERS, PROVIDER_IDS, QueryCancelledError, SF_LABELS, SQL_PREVIEW_LENGTH, STORAGE_KEYS, UrlAdapter, VIEWER_DIR_EXTENSIONS, WGS84_CODES, buildDataTypeLabel, buildDuckDbSource, buildEndpointFromTemplate, buildGeoArrowTables, buildProviderBaseUrl, clampBounds, 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, safeClamp, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
|
|
3057
3096
|
//# sourceMappingURL=index.js.map
|
|
3058
3097
|
//# sourceMappingURL=index.js.map
|