@walkthru-earth/objex-utils 0.1.0 → 1.0.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/dist/index.d.cts CHANGED
@@ -1,5 +1,34 @@
1
1
  import { Table } from 'apache-arrow';
2
2
 
3
+ /**
4
+ * Shared constants used across the application.
5
+ * Centralizes magic strings, numbers, and sets to prevent duplication.
6
+ */
7
+ declare const STORAGE_KEYS: {
8
+ readonly SETTINGS: "obstore-explore-settings";
9
+ readonly CONNECTIONS: "obstore-explore-connections";
10
+ readonly QUERY_HISTORY: "obstore-explore-query-history";
11
+ };
12
+ /** EPSG codes considered WGS84 (no reprojection needed). */
13
+ declare const WGS84_CODES: Set<number>;
14
+ /** Default target CRS for ST_Transform. */
15
+ declare const DEFAULT_TARGET_CRS = "EPSG:4326";
16
+ /** DuckDB-WASM initialization timeout in ms. */
17
+ declare const DUCKDB_INIT_TIMEOUT_MS = 30000;
18
+ /** Maximum entries kept in query history. */
19
+ declare const MAX_QUERY_HISTORY_ENTRIES = 200;
20
+ /** SQL preview truncation length (characters). */
21
+ declare const SQL_PREVIEW_LENGTH = 120;
22
+ /** Extensions that represent "virtual files" — directories that open as viewers. */
23
+ declare const VIEWER_DIR_EXTENSIONS: Set<string>;
24
+ /**
25
+ * Golden-angle-based hue multiplier for evenly distributing layer colors.
26
+ * 137 ≈ 360 × (1 − 1/φ) where φ is the golden ratio.
27
+ */
28
+ declare const LAYER_HUE_MULTIPLIER = 137;
29
+ /** Duration (ms) to show "Copied!" feedback before resetting. */
30
+ declare const COPY_FEEDBACK_MS = 2000;
31
+
3
32
  /**
4
33
  * Centralized file type detection module.
5
34
  *
@@ -121,7 +150,7 @@ interface FileEntry {
121
150
  interface Connection {
122
151
  id: string;
123
152
  name: string;
124
- provider: 's3' | 'gcs' | 'r2' | 'minio' | 'azure' | 'storj';
153
+ provider: string;
125
154
  endpoint: string;
126
155
  bucket: string;
127
156
  region: string;
@@ -131,7 +160,7 @@ interface Connection {
131
160
  }
132
161
  interface ConnectionConfig {
133
162
  name: string;
134
- provider: 's3' | 'gcs' | 'r2' | 'minio' | 'azure' | 'storj';
163
+ provider: string;
135
164
  endpoint: string;
136
165
  bucket: string;
137
166
  region: string;
@@ -203,6 +232,15 @@ declare function typeColor(category: TypeCategory): string;
203
232
  declare function typeBadgeClass(category: TypeCategory): string;
204
233
  declare function typeLabel(category: TypeCategory): string;
205
234
 
235
+ /**
236
+ * Shared error handling for async viewer load operations.
237
+ */
238
+ /**
239
+ * Extract an error message from an unknown caught value.
240
+ * Returns null for AbortError (caller should silently return).
241
+ */
242
+ declare function handleLoadError(err: unknown): string | null;
243
+
206
244
  /**
207
245
  * Formats a byte count into a human-readable string.
208
246
  */
@@ -217,6 +255,16 @@ declare function formatDate(timestamp: number): string;
217
255
  * Returns an empty string if no extension is found.
218
256
  */
219
257
  declare function getFileExtension(filename: string): string;
258
+ /**
259
+ * JSON replacer that converts BigInt values to strings.
260
+ * Use with `JSON.stringify(value, jsonReplacerBigInt)`.
261
+ */
262
+ declare function jsonReplacerBigInt(_key: string, value: unknown): unknown;
263
+ /**
264
+ * Format a value for display in tables, attribute panels, and exports.
265
+ * Handles null, undefined, Date, BigInt, and objects uniformly.
266
+ */
267
+ declare function formatValue(value: unknown): string;
220
268
 
221
269
  /**
222
270
  * Direct WKB → GeoArrow bridge (zero-copy).
@@ -358,7 +406,7 @@ declare function extractBounds(geo: GeoParquetMeta): [number, number, number, nu
358
406
  *
359
407
  * Also handles plain bucket names (no protocol).
360
408
  */
361
- type StorageProvider = 's3' | 'gcs' | 'r2' | 'minio' | 'azure' | 'storj' | 'unknown';
409
+ type StorageProvider = string;
362
410
  interface ParsedStorageUrl {
363
411
  bucket: string;
364
412
  region: string;
@@ -430,4 +478,4 @@ declare function findGeoColumnFromRows(rows: Record<string, unknown>[], schema:
430
478
  type: string;
431
479
  }[]): string | null;
432
480
 
433
- export { type Connection, type ConnectionConfig, type Defaults, type DuckDbReadFn, type FileCategory, type FileEntry, type FileTypeInfo, type GeoArrowGeomType, type GeoArrowResult, type GeoColumnMeta, type GeoParquetMeta, type GeoType, type HexRow, type ListPage, type MapQueryHandle, type MapQueryResult, type ParquetFileMetadata, type ParsedGeometry, type ParsedStorageUrl, QueryCancelledError, type QueryEngine, type QueryHandle, type QueryResult, type SchemaField, type StorageAdapter, type StorageProvider, type Tab, type Theme, type TypeCategory, UrlAdapter, type ViewerKind, type WriteResult, buildDuckDbSource, buildGeoArrowTables, classifyType, describeParseResult, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getViewerKind, isCloudNativeFormat, isQueryable, looksLikeUrl, normalizeGeomType, parseStorageUrl, parseWKB, readParquetMetadata, toBinary, typeBadgeClass, typeColor, typeLabel };
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 };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,34 @@
1
1
  import { Table } from 'apache-arrow';
2
2
 
3
+ /**
4
+ * Shared constants used across the application.
5
+ * Centralizes magic strings, numbers, and sets to prevent duplication.
6
+ */
7
+ declare const STORAGE_KEYS: {
8
+ readonly SETTINGS: "obstore-explore-settings";
9
+ readonly CONNECTIONS: "obstore-explore-connections";
10
+ readonly QUERY_HISTORY: "obstore-explore-query-history";
11
+ };
12
+ /** EPSG codes considered WGS84 (no reprojection needed). */
13
+ declare const WGS84_CODES: Set<number>;
14
+ /** Default target CRS for ST_Transform. */
15
+ declare const DEFAULT_TARGET_CRS = "EPSG:4326";
16
+ /** DuckDB-WASM initialization timeout in ms. */
17
+ declare const DUCKDB_INIT_TIMEOUT_MS = 30000;
18
+ /** Maximum entries kept in query history. */
19
+ declare const MAX_QUERY_HISTORY_ENTRIES = 200;
20
+ /** SQL preview truncation length (characters). */
21
+ declare const SQL_PREVIEW_LENGTH = 120;
22
+ /** Extensions that represent "virtual files" — directories that open as viewers. */
23
+ declare const VIEWER_DIR_EXTENSIONS: Set<string>;
24
+ /**
25
+ * Golden-angle-based hue multiplier for evenly distributing layer colors.
26
+ * 137 ≈ 360 × (1 − 1/φ) where φ is the golden ratio.
27
+ */
28
+ declare const LAYER_HUE_MULTIPLIER = 137;
29
+ /** Duration (ms) to show "Copied!" feedback before resetting. */
30
+ declare const COPY_FEEDBACK_MS = 2000;
31
+
3
32
  /**
4
33
  * Centralized file type detection module.
5
34
  *
@@ -121,7 +150,7 @@ interface FileEntry {
121
150
  interface Connection {
122
151
  id: string;
123
152
  name: string;
124
- provider: 's3' | 'gcs' | 'r2' | 'minio' | 'azure' | 'storj';
153
+ provider: string;
125
154
  endpoint: string;
126
155
  bucket: string;
127
156
  region: string;
@@ -131,7 +160,7 @@ interface Connection {
131
160
  }
132
161
  interface ConnectionConfig {
133
162
  name: string;
134
- provider: 's3' | 'gcs' | 'r2' | 'minio' | 'azure' | 'storj';
163
+ provider: string;
135
164
  endpoint: string;
136
165
  bucket: string;
137
166
  region: string;
@@ -203,6 +232,15 @@ declare function typeColor(category: TypeCategory): string;
203
232
  declare function typeBadgeClass(category: TypeCategory): string;
204
233
  declare function typeLabel(category: TypeCategory): string;
205
234
 
235
+ /**
236
+ * Shared error handling for async viewer load operations.
237
+ */
238
+ /**
239
+ * Extract an error message from an unknown caught value.
240
+ * Returns null for AbortError (caller should silently return).
241
+ */
242
+ declare function handleLoadError(err: unknown): string | null;
243
+
206
244
  /**
207
245
  * Formats a byte count into a human-readable string.
208
246
  */
@@ -217,6 +255,16 @@ declare function formatDate(timestamp: number): string;
217
255
  * Returns an empty string if no extension is found.
218
256
  */
219
257
  declare function getFileExtension(filename: string): string;
258
+ /**
259
+ * JSON replacer that converts BigInt values to strings.
260
+ * Use with `JSON.stringify(value, jsonReplacerBigInt)`.
261
+ */
262
+ declare function jsonReplacerBigInt(_key: string, value: unknown): unknown;
263
+ /**
264
+ * Format a value for display in tables, attribute panels, and exports.
265
+ * Handles null, undefined, Date, BigInt, and objects uniformly.
266
+ */
267
+ declare function formatValue(value: unknown): string;
220
268
 
221
269
  /**
222
270
  * Direct WKB → GeoArrow bridge (zero-copy).
@@ -358,7 +406,7 @@ declare function extractBounds(geo: GeoParquetMeta): [number, number, number, nu
358
406
  *
359
407
  * Also handles plain bucket names (no protocol).
360
408
  */
361
- type StorageProvider = 's3' | 'gcs' | 'r2' | 'minio' | 'azure' | 'storj' | 'unknown';
409
+ type StorageProvider = string;
362
410
  interface ParsedStorageUrl {
363
411
  bucket: string;
364
412
  region: string;
@@ -430,4 +478,4 @@ declare function findGeoColumnFromRows(rows: Record<string, unknown>[], schema:
430
478
  type: string;
431
479
  }[]): string | null;
432
480
 
433
- export { type Connection, type ConnectionConfig, type Defaults, type DuckDbReadFn, type FileCategory, type FileEntry, type FileTypeInfo, type GeoArrowGeomType, type GeoArrowResult, type GeoColumnMeta, type GeoParquetMeta, type GeoType, type HexRow, type ListPage, type MapQueryHandle, type MapQueryResult, type ParquetFileMetadata, type ParsedGeometry, type ParsedStorageUrl, QueryCancelledError, type QueryEngine, type QueryHandle, type QueryResult, type SchemaField, type StorageAdapter, type StorageProvider, type Tab, type Theme, type TypeCategory, UrlAdapter, type ViewerKind, type WriteResult, buildDuckDbSource, buildGeoArrowTables, classifyType, describeParseResult, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getViewerKind, isCloudNativeFormat, isQueryable, looksLikeUrl, normalizeGeomType, parseStorageUrl, parseWKB, readParquetMetadata, toBinary, typeBadgeClass, typeColor, typeLabel };
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 };