@walkthru-earth/objex-utils 1.2.0 → 1.3.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 +8 -0
- package/dist/index.cjs +280 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +178 -2
- package/dist/index.d.ts +178 -2
- package/dist/index.js +270 -31
- package/dist/index.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/cog.md +14 -225
- package/docs/parquet-metadata.md +9 -1
- package/docs/stac-geoparquet.md +198 -0
- package/docs/storage.md +2 -0
- package/package.json +9 -4
package/dist/index.d.cts
CHANGED
|
@@ -285,6 +285,12 @@ declare const PROVIDER_IDS: ProviderId[];
|
|
|
285
285
|
declare function getProvider(id: string): ProviderDef;
|
|
286
286
|
/** Build endpoint URL from template + region. */
|
|
287
287
|
declare function buildEndpointFromTemplate(id: ProviderId, region: string): string;
|
|
288
|
+
/**
|
|
289
|
+
* Resolve an endpoint URL for a provider using its registered template,
|
|
290
|
+
* falling back to the provider's default region when none is supplied.
|
|
291
|
+
* Returns '' when the provider has no template (e.g. plain S3 or MinIO).
|
|
292
|
+
*/
|
|
293
|
+
declare function resolveProviderEndpoint(provider: string, region?: string): string;
|
|
288
294
|
/**
|
|
289
295
|
* Build the base URL for API requests (endpoint + bucket).
|
|
290
296
|
* Used by browser-cloud adapter and url-state.
|
|
@@ -292,6 +298,33 @@ declare function buildEndpointFromTemplate(id: ProviderId, region: string): stri
|
|
|
292
298
|
declare function buildProviderBaseUrl(provider: ProviderId, endpoint: string, bucket: string, region: string): string;
|
|
293
299
|
/** Check if a provider uses the GCS JSON API (not S3 XML). */
|
|
294
300
|
declare function isGcsProvider(provider: string, endpoint: string): boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Minimal connection shape needed to decide access mode.
|
|
303
|
+
* Kept loose so callers don't need to import the full Connection type.
|
|
304
|
+
*/
|
|
305
|
+
interface AccessModeInput {
|
|
306
|
+
provider: string;
|
|
307
|
+
anonymous?: boolean;
|
|
308
|
+
endpoint?: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* How a connection's files can be read by the browser:
|
|
312
|
+
*
|
|
313
|
+
* - `public-https`: plain HTTPS via any HTTP client. No auth, no signing.
|
|
314
|
+
* Covers anonymous AWS/GCS/R2/Storj/Wasabi/etc.
|
|
315
|
+
* - `sas-https`: HTTPS with SAS token embedded in the URL. Still works with
|
|
316
|
+
* any HTTP client. Azure only.
|
|
317
|
+
* - `signed-s3`: requires SigV4 signing. DuckDB uses the `s3://` URI and
|
|
318
|
+
* signs it via its S3 config; other viewers must go through the storage
|
|
319
|
+
* adapter (which returns a blob) instead of streaming the HTTPS URL.
|
|
320
|
+
*/
|
|
321
|
+
type AccessMode = 'public-https' | 'sas-https' | 'signed-s3';
|
|
322
|
+
declare function getAccessMode(conn: AccessModeInput): AccessMode;
|
|
323
|
+
/**
|
|
324
|
+
* True when the connection's files can be fetched by any HTTP client
|
|
325
|
+
* (fetch/img/video/DuckDB httpfs/COG/Zarr/etc.) without the storage adapter.
|
|
326
|
+
*/
|
|
327
|
+
declare function isPubliclyStreamable(conn: AccessModeInput): boolean;
|
|
295
328
|
|
|
296
329
|
/**
|
|
297
330
|
* Minimal adapter for direct HTTPS URLs (source: 'url').
|
|
@@ -394,6 +427,14 @@ declare function serializeToCsv(columns: string[], rows: Record<string, unknown>
|
|
|
394
427
|
* Pure function — no browser APIs, works in Node.js.
|
|
395
428
|
*/
|
|
396
429
|
declare function serializeToJson(columns: string[], rows: Record<string, unknown>[]): string;
|
|
430
|
+
/**
|
|
431
|
+
* Export data as CSV file (triggers browser download).
|
|
432
|
+
*/
|
|
433
|
+
declare function exportToCsv(columns: string[], rows: Record<string, unknown>[], filename: string): void;
|
|
434
|
+
/**
|
|
435
|
+
* Export data as JSON file (triggers browser download).
|
|
436
|
+
*/
|
|
437
|
+
declare function exportToJson(columns: string[], rows: Record<string, unknown>[], filename: string): void;
|
|
397
438
|
|
|
398
439
|
/**
|
|
399
440
|
* Pure file entry sorting — framework-agnostic, works in Node.js.
|
|
@@ -555,11 +596,17 @@ interface GeoParquetMeta {
|
|
|
555
596
|
interface ParquetFileMetadata {
|
|
556
597
|
/** Total number of rows across all row groups. */
|
|
557
598
|
rowCount: number;
|
|
558
|
-
/** Column schema (name + type). */
|
|
599
|
+
/** Column schema (name + type). Leaf columns only (structs flattened to children). */
|
|
559
600
|
schema: {
|
|
560
601
|
name: string;
|
|
561
602
|
type: string;
|
|
562
603
|
}[];
|
|
604
|
+
/**
|
|
605
|
+
* Top-level column names as written. Includes struct/group parents (e.g.
|
|
606
|
+
* `assets`, `bbox`) that `schema` flattens away. Required for stac-geoparquet
|
|
607
|
+
* detection, which looks up struct columns by their parent name.
|
|
608
|
+
*/
|
|
609
|
+
topLevelColumns: string[];
|
|
563
610
|
/** GeoParquet "geo" metadata if present. */
|
|
564
611
|
geo: GeoParquetMeta | null;
|
|
565
612
|
/** True when file has legacy GeoParquet metadata (schema_version 0.x without "version" field). */
|
|
@@ -592,6 +639,135 @@ declare function extractGeometryTypes(geo: GeoParquetMeta): GeoArrowGeomType[];
|
|
|
592
639
|
*/
|
|
593
640
|
declare function extractBounds(geo: GeoParquetMeta): [number, number, number, number] | null;
|
|
594
641
|
|
|
642
|
+
/**
|
|
643
|
+
* STAC (SpatioTemporal Asset Catalog) detection and parsing.
|
|
644
|
+
*
|
|
645
|
+
* Pure TypeScript helpers shared by ViewerRouter, StacMosaicViewer, and
|
|
646
|
+
* MultiCogViewer. No Svelte dependency, publishable via objex-utils.
|
|
647
|
+
*/
|
|
648
|
+
/** STAC Link (shared by Catalog/Collection/Item). */
|
|
649
|
+
interface StacLink {
|
|
650
|
+
rel: string;
|
|
651
|
+
href: string;
|
|
652
|
+
type?: string;
|
|
653
|
+
title?: string;
|
|
654
|
+
}
|
|
655
|
+
/** STAC Item (GeoJSON Feature shape with stac_version). */
|
|
656
|
+
interface StacItem {
|
|
657
|
+
type: 'Feature';
|
|
658
|
+
stac_version: string;
|
|
659
|
+
id: string;
|
|
660
|
+
bbox?: [number, number, number, number];
|
|
661
|
+
geometry?: unknown;
|
|
662
|
+
properties?: Record<string, unknown>;
|
|
663
|
+
assets?: Record<string, StacAsset>;
|
|
664
|
+
collection?: string;
|
|
665
|
+
links?: StacLink[];
|
|
666
|
+
}
|
|
667
|
+
/** Single asset entry within a STAC item. */
|
|
668
|
+
interface StacAsset {
|
|
669
|
+
href: string;
|
|
670
|
+
type?: string;
|
|
671
|
+
title?: string;
|
|
672
|
+
roles?: string[];
|
|
673
|
+
/** Set when the asset carries `eo:bands`. */
|
|
674
|
+
'eo:bands'?: {
|
|
675
|
+
name?: string;
|
|
676
|
+
common_name?: string;
|
|
677
|
+
}[];
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* stac-geoparquet helpers.
|
|
682
|
+
*
|
|
683
|
+
* Pure TypeScript, zero Svelte / DuckDB / deck.gl dependencies. Re-exported
|
|
684
|
+
* through `@walkthru-earth/objex-utils` so other projects can consume the
|
|
685
|
+
* detection + row-to-Item transforms without pulling the Svelte lib.
|
|
686
|
+
*
|
|
687
|
+
* The module is decoupled from WKB decoding: callers pass a `wkbParser`
|
|
688
|
+
* callback (the objex Svelte lib threads its `parseWKB`; other consumers
|
|
689
|
+
* can plug in `geoarrow-wasm`, `wkx`, or any other library).
|
|
690
|
+
*/
|
|
691
|
+
|
|
692
|
+
/** Minimal schema column shape. Works with hyparquet, DuckDB, Arrow. */
|
|
693
|
+
interface StacGeoparquetSchemaColumn {
|
|
694
|
+
name: string;
|
|
695
|
+
type?: string;
|
|
696
|
+
}
|
|
697
|
+
/** Bbox in struct shape as produced by DuckDB's `bbox struct(xmin,ymin,xmax,ymax)`. */
|
|
698
|
+
interface StacBboxStruct {
|
|
699
|
+
xmin: number;
|
|
700
|
+
ymin: number;
|
|
701
|
+
xmax: number;
|
|
702
|
+
ymax: number;
|
|
703
|
+
}
|
|
704
|
+
/** Generic Record shape representing a single stac-geoparquet row after DuckDB decoding. */
|
|
705
|
+
type StacGeoparquetRow = Record<string, unknown>;
|
|
706
|
+
interface StacRowToItemOptions {
|
|
707
|
+
/**
|
|
708
|
+
* Decoder for the geometry column. Accepts a Uint8Array of WKB bytes and
|
|
709
|
+
* returns a GeoJSON geometry object (or null on failure).
|
|
710
|
+
*
|
|
711
|
+
* Consumers in the objex Svelte lib should pass `parseWKB` from
|
|
712
|
+
* `@walkthru-earth/objex-utils`. Other projects can use any WKB library.
|
|
713
|
+
*/
|
|
714
|
+
wkbParser?: (bytes: Uint8Array) => unknown;
|
|
715
|
+
/**
|
|
716
|
+
* Column name holding the WKB bytes. Defaults to `'geom_wkb'` because the
|
|
717
|
+
* recommended SQL projection is `ST_AsWKB(geometry) AS geom_wkb`.
|
|
718
|
+
*/
|
|
719
|
+
wkbColumn?: string;
|
|
720
|
+
/** Override the column holding the pre-decoded GeoJSON geometry, when available. */
|
|
721
|
+
geometryColumn?: string;
|
|
722
|
+
}
|
|
723
|
+
/** Columns every stac-geoparquet file MUST carry per the stac-geoparquet spec. */
|
|
724
|
+
declare const STAC_GEOPARQUET_REQUIRED_COLUMNS: readonly ["stac_version", "type", "geometry", "assets"];
|
|
725
|
+
/**
|
|
726
|
+
* Detect stac-geoparquet by presence of the required STAC columns.
|
|
727
|
+
*
|
|
728
|
+
* Deliberately type-agnostic: some pipelines know the type (DuckDB DESCRIBE,
|
|
729
|
+
* Arrow Field), others only have the name list (hyparquet schema walk). The
|
|
730
|
+
* set of names is sufficient for routing.
|
|
731
|
+
*/
|
|
732
|
+
declare function isStacGeoparquetSchema(schema: StacGeoparquetSchemaColumn[]): boolean;
|
|
733
|
+
/**
|
|
734
|
+
* Flatten a DuckDB `struct(xmin,ymin,xmax,ymax)` bbox to the `[minX, minY, maxX, maxY]`
|
|
735
|
+
* array shape that STAC Items and deck.gl-geotiff MosaicLayer expect.
|
|
736
|
+
*
|
|
737
|
+
* Pass-through for arrays so callers that already have `[minX,minY,maxX,maxY]`
|
|
738
|
+
* shape (e.g. from a Feature's `bbox` field) don't need a separate path.
|
|
739
|
+
*/
|
|
740
|
+
declare function flattenStacBbox(bbox: StacBboxStruct | number[] | null | undefined): [number, number, number, number] | null;
|
|
741
|
+
/**
|
|
742
|
+
* Resolve a possibly-relative STAC asset href against the parquet file URL.
|
|
743
|
+
*
|
|
744
|
+
* `./foo.tif` or `foo.tif` → absolute against `baseUrl`. Absolute URLs
|
|
745
|
+
* (`http(s)://`, `s3://`, `gs://`, etc.) are returned unchanged.
|
|
746
|
+
*/
|
|
747
|
+
declare function resolveStacAssetHref(href: string, baseUrl: string): string;
|
|
748
|
+
/**
|
|
749
|
+
* Pick the "primary" asset from a STAC Item's `assets` map.
|
|
750
|
+
*
|
|
751
|
+
* Priority: caller-specified `preferredKeys` → `data` key → first asset with
|
|
752
|
+
* `roles` containing `'data'` → first asset. Returns `null` if the map is
|
|
753
|
+
* empty or not an object.
|
|
754
|
+
*/
|
|
755
|
+
declare function pickStacPrimaryAsset(assets: Record<string, StacAsset> | null | undefined, preferredKeys?: readonly string[]): {
|
|
756
|
+
key: string;
|
|
757
|
+
asset: StacAsset;
|
|
758
|
+
} | null;
|
|
759
|
+
/**
|
|
760
|
+
* Convert one stac-geoparquet row into a standard STAC Item JSON object.
|
|
761
|
+
*
|
|
762
|
+
* Handles:
|
|
763
|
+
* - `assets` named-struct flattening + relative href resolution
|
|
764
|
+
* - `bbox` struct → `[minX, minY, maxX, maxY]` array
|
|
765
|
+
* - Optional WKB geometry → GeoJSON via `opts.wkbParser`
|
|
766
|
+
* - `datetime` → ISO string (passes through already-string values)
|
|
767
|
+
* - Promotes `properties.*` columns (`proj:*`, `datetime`) onto `item.properties`
|
|
768
|
+
*/
|
|
769
|
+
declare function stacRowToItem(row: StacGeoparquetRow, baseUrl: string, opts?: StacRowToItemOptions): StacItem;
|
|
770
|
+
|
|
595
771
|
/**
|
|
596
772
|
* Universal cloud storage URL / bucket parser.
|
|
597
773
|
*
|
|
@@ -701,4 +877,4 @@ declare function findGeoColumnFromRows(rows: Record<string, unknown>[], schema:
|
|
|
701
877
|
type: string;
|
|
702
878
|
}[]): string | null;
|
|
703
879
|
|
|
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 };
|
|
880
|
+
export { type AccessMode, type AccessModeInput, 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, type QuerySource, SF_LABELS, SQL_PREVIEW_LENGTH, STAC_GEOPARQUET_REQUIRED_COLUMNS, STORAGE_KEYS, type SchemaField, type SortConfig, type SortDirection, type SortField, type SqlBlock, type StacBboxStruct, type StacGeoparquetRow, type StacGeoparquetSchemaColumn, type StacRowToItemOptions, 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, exportToCsv, exportToJson, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, flattenStacBbox, formatDate, formatFileSize, formatValue, generateHexDump, getAccessMode, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getNativeScheme, getProvider, getViewerKind, handleLoadError, interpolateTemplates, isCloudNativeFormat, isGcsProvider, isPubliclyStreamable, isQueryable, isStacGeoparquetSchema, jsonReplacerBigInt, loadFromStorage, looksLikeUrl, markSqlBlocks, normalizeGeomType, parseMarkdownDocument, parseStorageUrl, parseWKB, persistToStorage, pickStacPrimaryAsset, readParquetMetadata, resolveCloudUrl, resolveProviderEndpoint, resolveStacAssetHref, safeClamp, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, stacRowToItem, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -285,6 +285,12 @@ declare const PROVIDER_IDS: ProviderId[];
|
|
|
285
285
|
declare function getProvider(id: string): ProviderDef;
|
|
286
286
|
/** Build endpoint URL from template + region. */
|
|
287
287
|
declare function buildEndpointFromTemplate(id: ProviderId, region: string): string;
|
|
288
|
+
/**
|
|
289
|
+
* Resolve an endpoint URL for a provider using its registered template,
|
|
290
|
+
* falling back to the provider's default region when none is supplied.
|
|
291
|
+
* Returns '' when the provider has no template (e.g. plain S3 or MinIO).
|
|
292
|
+
*/
|
|
293
|
+
declare function resolveProviderEndpoint(provider: string, region?: string): string;
|
|
288
294
|
/**
|
|
289
295
|
* Build the base URL for API requests (endpoint + bucket).
|
|
290
296
|
* Used by browser-cloud adapter and url-state.
|
|
@@ -292,6 +298,33 @@ declare function buildEndpointFromTemplate(id: ProviderId, region: string): stri
|
|
|
292
298
|
declare function buildProviderBaseUrl(provider: ProviderId, endpoint: string, bucket: string, region: string): string;
|
|
293
299
|
/** Check if a provider uses the GCS JSON API (not S3 XML). */
|
|
294
300
|
declare function isGcsProvider(provider: string, endpoint: string): boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Minimal connection shape needed to decide access mode.
|
|
303
|
+
* Kept loose so callers don't need to import the full Connection type.
|
|
304
|
+
*/
|
|
305
|
+
interface AccessModeInput {
|
|
306
|
+
provider: string;
|
|
307
|
+
anonymous?: boolean;
|
|
308
|
+
endpoint?: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* How a connection's files can be read by the browser:
|
|
312
|
+
*
|
|
313
|
+
* - `public-https`: plain HTTPS via any HTTP client. No auth, no signing.
|
|
314
|
+
* Covers anonymous AWS/GCS/R2/Storj/Wasabi/etc.
|
|
315
|
+
* - `sas-https`: HTTPS with SAS token embedded in the URL. Still works with
|
|
316
|
+
* any HTTP client. Azure only.
|
|
317
|
+
* - `signed-s3`: requires SigV4 signing. DuckDB uses the `s3://` URI and
|
|
318
|
+
* signs it via its S3 config; other viewers must go through the storage
|
|
319
|
+
* adapter (which returns a blob) instead of streaming the HTTPS URL.
|
|
320
|
+
*/
|
|
321
|
+
type AccessMode = 'public-https' | 'sas-https' | 'signed-s3';
|
|
322
|
+
declare function getAccessMode(conn: AccessModeInput): AccessMode;
|
|
323
|
+
/**
|
|
324
|
+
* True when the connection's files can be fetched by any HTTP client
|
|
325
|
+
* (fetch/img/video/DuckDB httpfs/COG/Zarr/etc.) without the storage adapter.
|
|
326
|
+
*/
|
|
327
|
+
declare function isPubliclyStreamable(conn: AccessModeInput): boolean;
|
|
295
328
|
|
|
296
329
|
/**
|
|
297
330
|
* Minimal adapter for direct HTTPS URLs (source: 'url').
|
|
@@ -394,6 +427,14 @@ declare function serializeToCsv(columns: string[], rows: Record<string, unknown>
|
|
|
394
427
|
* Pure function — no browser APIs, works in Node.js.
|
|
395
428
|
*/
|
|
396
429
|
declare function serializeToJson(columns: string[], rows: Record<string, unknown>[]): string;
|
|
430
|
+
/**
|
|
431
|
+
* Export data as CSV file (triggers browser download).
|
|
432
|
+
*/
|
|
433
|
+
declare function exportToCsv(columns: string[], rows: Record<string, unknown>[], filename: string): void;
|
|
434
|
+
/**
|
|
435
|
+
* Export data as JSON file (triggers browser download).
|
|
436
|
+
*/
|
|
437
|
+
declare function exportToJson(columns: string[], rows: Record<string, unknown>[], filename: string): void;
|
|
397
438
|
|
|
398
439
|
/**
|
|
399
440
|
* Pure file entry sorting — framework-agnostic, works in Node.js.
|
|
@@ -555,11 +596,17 @@ interface GeoParquetMeta {
|
|
|
555
596
|
interface ParquetFileMetadata {
|
|
556
597
|
/** Total number of rows across all row groups. */
|
|
557
598
|
rowCount: number;
|
|
558
|
-
/** Column schema (name + type). */
|
|
599
|
+
/** Column schema (name + type). Leaf columns only (structs flattened to children). */
|
|
559
600
|
schema: {
|
|
560
601
|
name: string;
|
|
561
602
|
type: string;
|
|
562
603
|
}[];
|
|
604
|
+
/**
|
|
605
|
+
* Top-level column names as written. Includes struct/group parents (e.g.
|
|
606
|
+
* `assets`, `bbox`) that `schema` flattens away. Required for stac-geoparquet
|
|
607
|
+
* detection, which looks up struct columns by their parent name.
|
|
608
|
+
*/
|
|
609
|
+
topLevelColumns: string[];
|
|
563
610
|
/** GeoParquet "geo" metadata if present. */
|
|
564
611
|
geo: GeoParquetMeta | null;
|
|
565
612
|
/** True when file has legacy GeoParquet metadata (schema_version 0.x without "version" field). */
|
|
@@ -592,6 +639,135 @@ declare function extractGeometryTypes(geo: GeoParquetMeta): GeoArrowGeomType[];
|
|
|
592
639
|
*/
|
|
593
640
|
declare function extractBounds(geo: GeoParquetMeta): [number, number, number, number] | null;
|
|
594
641
|
|
|
642
|
+
/**
|
|
643
|
+
* STAC (SpatioTemporal Asset Catalog) detection and parsing.
|
|
644
|
+
*
|
|
645
|
+
* Pure TypeScript helpers shared by ViewerRouter, StacMosaicViewer, and
|
|
646
|
+
* MultiCogViewer. No Svelte dependency, publishable via objex-utils.
|
|
647
|
+
*/
|
|
648
|
+
/** STAC Link (shared by Catalog/Collection/Item). */
|
|
649
|
+
interface StacLink {
|
|
650
|
+
rel: string;
|
|
651
|
+
href: string;
|
|
652
|
+
type?: string;
|
|
653
|
+
title?: string;
|
|
654
|
+
}
|
|
655
|
+
/** STAC Item (GeoJSON Feature shape with stac_version). */
|
|
656
|
+
interface StacItem {
|
|
657
|
+
type: 'Feature';
|
|
658
|
+
stac_version: string;
|
|
659
|
+
id: string;
|
|
660
|
+
bbox?: [number, number, number, number];
|
|
661
|
+
geometry?: unknown;
|
|
662
|
+
properties?: Record<string, unknown>;
|
|
663
|
+
assets?: Record<string, StacAsset>;
|
|
664
|
+
collection?: string;
|
|
665
|
+
links?: StacLink[];
|
|
666
|
+
}
|
|
667
|
+
/** Single asset entry within a STAC item. */
|
|
668
|
+
interface StacAsset {
|
|
669
|
+
href: string;
|
|
670
|
+
type?: string;
|
|
671
|
+
title?: string;
|
|
672
|
+
roles?: string[];
|
|
673
|
+
/** Set when the asset carries `eo:bands`. */
|
|
674
|
+
'eo:bands'?: {
|
|
675
|
+
name?: string;
|
|
676
|
+
common_name?: string;
|
|
677
|
+
}[];
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* stac-geoparquet helpers.
|
|
682
|
+
*
|
|
683
|
+
* Pure TypeScript, zero Svelte / DuckDB / deck.gl dependencies. Re-exported
|
|
684
|
+
* through `@walkthru-earth/objex-utils` so other projects can consume the
|
|
685
|
+
* detection + row-to-Item transforms without pulling the Svelte lib.
|
|
686
|
+
*
|
|
687
|
+
* The module is decoupled from WKB decoding: callers pass a `wkbParser`
|
|
688
|
+
* callback (the objex Svelte lib threads its `parseWKB`; other consumers
|
|
689
|
+
* can plug in `geoarrow-wasm`, `wkx`, or any other library).
|
|
690
|
+
*/
|
|
691
|
+
|
|
692
|
+
/** Minimal schema column shape. Works with hyparquet, DuckDB, Arrow. */
|
|
693
|
+
interface StacGeoparquetSchemaColumn {
|
|
694
|
+
name: string;
|
|
695
|
+
type?: string;
|
|
696
|
+
}
|
|
697
|
+
/** Bbox in struct shape as produced by DuckDB's `bbox struct(xmin,ymin,xmax,ymax)`. */
|
|
698
|
+
interface StacBboxStruct {
|
|
699
|
+
xmin: number;
|
|
700
|
+
ymin: number;
|
|
701
|
+
xmax: number;
|
|
702
|
+
ymax: number;
|
|
703
|
+
}
|
|
704
|
+
/** Generic Record shape representing a single stac-geoparquet row after DuckDB decoding. */
|
|
705
|
+
type StacGeoparquetRow = Record<string, unknown>;
|
|
706
|
+
interface StacRowToItemOptions {
|
|
707
|
+
/**
|
|
708
|
+
* Decoder for the geometry column. Accepts a Uint8Array of WKB bytes and
|
|
709
|
+
* returns a GeoJSON geometry object (or null on failure).
|
|
710
|
+
*
|
|
711
|
+
* Consumers in the objex Svelte lib should pass `parseWKB` from
|
|
712
|
+
* `@walkthru-earth/objex-utils`. Other projects can use any WKB library.
|
|
713
|
+
*/
|
|
714
|
+
wkbParser?: (bytes: Uint8Array) => unknown;
|
|
715
|
+
/**
|
|
716
|
+
* Column name holding the WKB bytes. Defaults to `'geom_wkb'` because the
|
|
717
|
+
* recommended SQL projection is `ST_AsWKB(geometry) AS geom_wkb`.
|
|
718
|
+
*/
|
|
719
|
+
wkbColumn?: string;
|
|
720
|
+
/** Override the column holding the pre-decoded GeoJSON geometry, when available. */
|
|
721
|
+
geometryColumn?: string;
|
|
722
|
+
}
|
|
723
|
+
/** Columns every stac-geoparquet file MUST carry per the stac-geoparquet spec. */
|
|
724
|
+
declare const STAC_GEOPARQUET_REQUIRED_COLUMNS: readonly ["stac_version", "type", "geometry", "assets"];
|
|
725
|
+
/**
|
|
726
|
+
* Detect stac-geoparquet by presence of the required STAC columns.
|
|
727
|
+
*
|
|
728
|
+
* Deliberately type-agnostic: some pipelines know the type (DuckDB DESCRIBE,
|
|
729
|
+
* Arrow Field), others only have the name list (hyparquet schema walk). The
|
|
730
|
+
* set of names is sufficient for routing.
|
|
731
|
+
*/
|
|
732
|
+
declare function isStacGeoparquetSchema(schema: StacGeoparquetSchemaColumn[]): boolean;
|
|
733
|
+
/**
|
|
734
|
+
* Flatten a DuckDB `struct(xmin,ymin,xmax,ymax)` bbox to the `[minX, minY, maxX, maxY]`
|
|
735
|
+
* array shape that STAC Items and deck.gl-geotiff MosaicLayer expect.
|
|
736
|
+
*
|
|
737
|
+
* Pass-through for arrays so callers that already have `[minX,minY,maxX,maxY]`
|
|
738
|
+
* shape (e.g. from a Feature's `bbox` field) don't need a separate path.
|
|
739
|
+
*/
|
|
740
|
+
declare function flattenStacBbox(bbox: StacBboxStruct | number[] | null | undefined): [number, number, number, number] | null;
|
|
741
|
+
/**
|
|
742
|
+
* Resolve a possibly-relative STAC asset href against the parquet file URL.
|
|
743
|
+
*
|
|
744
|
+
* `./foo.tif` or `foo.tif` → absolute against `baseUrl`. Absolute URLs
|
|
745
|
+
* (`http(s)://`, `s3://`, `gs://`, etc.) are returned unchanged.
|
|
746
|
+
*/
|
|
747
|
+
declare function resolveStacAssetHref(href: string, baseUrl: string): string;
|
|
748
|
+
/**
|
|
749
|
+
* Pick the "primary" asset from a STAC Item's `assets` map.
|
|
750
|
+
*
|
|
751
|
+
* Priority: caller-specified `preferredKeys` → `data` key → first asset with
|
|
752
|
+
* `roles` containing `'data'` → first asset. Returns `null` if the map is
|
|
753
|
+
* empty or not an object.
|
|
754
|
+
*/
|
|
755
|
+
declare function pickStacPrimaryAsset(assets: Record<string, StacAsset> | null | undefined, preferredKeys?: readonly string[]): {
|
|
756
|
+
key: string;
|
|
757
|
+
asset: StacAsset;
|
|
758
|
+
} | null;
|
|
759
|
+
/**
|
|
760
|
+
* Convert one stac-geoparquet row into a standard STAC Item JSON object.
|
|
761
|
+
*
|
|
762
|
+
* Handles:
|
|
763
|
+
* - `assets` named-struct flattening + relative href resolution
|
|
764
|
+
* - `bbox` struct → `[minX, minY, maxX, maxY]` array
|
|
765
|
+
* - Optional WKB geometry → GeoJSON via `opts.wkbParser`
|
|
766
|
+
* - `datetime` → ISO string (passes through already-string values)
|
|
767
|
+
* - Promotes `properties.*` columns (`proj:*`, `datetime`) onto `item.properties`
|
|
768
|
+
*/
|
|
769
|
+
declare function stacRowToItem(row: StacGeoparquetRow, baseUrl: string, opts?: StacRowToItemOptions): StacItem;
|
|
770
|
+
|
|
595
771
|
/**
|
|
596
772
|
* Universal cloud storage URL / bucket parser.
|
|
597
773
|
*
|
|
@@ -701,4 +877,4 @@ declare function findGeoColumnFromRows(rows: Record<string, unknown>[], schema:
|
|
|
701
877
|
type: string;
|
|
702
878
|
}[]): string | null;
|
|
703
879
|
|
|
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 };
|
|
880
|
+
export { type AccessMode, type AccessModeInput, 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, type QuerySource, SF_LABELS, SQL_PREVIEW_LENGTH, STAC_GEOPARQUET_REQUIRED_COLUMNS, STORAGE_KEYS, type SchemaField, type SortConfig, type SortDirection, type SortField, type SqlBlock, type StacBboxStruct, type StacGeoparquetRow, type StacGeoparquetSchemaColumn, type StacRowToItemOptions, 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, exportToCsv, exportToJson, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, flattenStacBbox, formatDate, formatFileSize, formatValue, generateHexDump, getAccessMode, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getNativeScheme, getProvider, getViewerKind, handleLoadError, interpolateTemplates, isCloudNativeFormat, isGcsProvider, isPubliclyStreamable, isQueryable, isStacGeoparquetSchema, jsonReplacerBigInt, loadFromStorage, looksLikeUrl, markSqlBlocks, normalizeGeomType, parseMarkdownDocument, parseStorageUrl, parseWKB, persistToStorage, pickStacPrimaryAsset, readParquetMetadata, resolveCloudUrl, resolveProviderEndpoint, resolveStacAssetHref, safeClamp, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, stacRowToItem, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
|