@sqlrooms/deck 0.29.0-rc.10
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/LICENSE.md +10 -0
- package/README.md +654 -0
- package/dist/BlockMapSettings.d.ts +3 -0
- package/dist/BlockMapSettings.d.ts.map +1 -0
- package/dist/BlockMapSettings.js +57 -0
- package/dist/BlockMapSettings.js.map +1 -0
- package/dist/DashboardMapSettings.d.ts +7 -0
- package/dist/DashboardMapSettings.d.ts.map +1 -0
- package/dist/DashboardMapSettings.js +52 -0
- package/dist/DashboardMapSettings.js.map +1 -0
- package/dist/DeckJsonMap.d.ts +4 -0
- package/dist/DeckJsonMap.d.ts.map +1 -0
- package/dist/DeckJsonMap.js +370 -0
- package/dist/DeckJsonMap.js.map +1 -0
- package/dist/DeckJsonMapSpec.d.ts +7617 -0
- package/dist/DeckJsonMapSpec.d.ts.map +1 -0
- package/dist/DeckJsonMapSpec.js +82 -0
- package/dist/DeckJsonMapSpec.js.map +1 -0
- package/dist/DeckMapDefaultStylesProvider.d.ts +28 -0
- package/dist/DeckMapDefaultStylesProvider.d.ts.map +1 -0
- package/dist/DeckMapDefaultStylesProvider.js +23 -0
- package/dist/DeckMapDefaultStylesProvider.js.map +1 -0
- package/dist/DeckMapSurface.d.ts +39 -0
- package/dist/DeckMapSurface.d.ts.map +1 -0
- package/dist/DeckMapSurface.js +137 -0
- package/dist/DeckMapSurface.js.map +1 -0
- package/dist/DeckMapsSlice.d.ts +99 -0
- package/dist/DeckMapsSlice.d.ts.map +1 -0
- package/dist/DeckMapsSlice.js +89 -0
- package/dist/DeckMapsSlice.js.map +1 -0
- package/dist/MapSettings.d.ts +16 -0
- package/dist/MapSettings.d.ts.map +1 -0
- package/dist/MapSettings.js +292 -0
- package/dist/MapSettings.js.map +1 -0
- package/dist/MapSettingsControls.d.ts +40 -0
- package/dist/MapSettingsControls.d.ts.map +1 -0
- package/dist/MapSettingsControls.js +54 -0
- package/dist/MapSettingsControls.js.map +1 -0
- package/dist/ai.d.ts +261 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +392 -0
- package/dist/ai.js.map +1 -0
- package/dist/block.d.ts +21 -0
- package/dist/block.d.ts.map +1 -0
- package/dist/block.js +105 -0
- package/dist/block.js.map +1 -0
- package/dist/blockDocumentRegistration.d.ts +45 -0
- package/dist/blockDocumentRegistration.d.ts.map +1 -0
- package/dist/blockDocumentRegistration.js +68 -0
- package/dist/blockDocumentRegistration.js.map +1 -0
- package/dist/createDeckJsonSpecFromDatasets.d.ts +11 -0
- package/dist/createDeckJsonSpecFromDatasets.d.ts.map +1 -0
- package/dist/createDeckJsonSpecFromDatasets.js +85 -0
- package/dist/createDeckJsonSpecFromDatasets.js.map +1 -0
- package/dist/createOrUpdateDeckMapResource.d.ts +81 -0
- package/dist/createOrUpdateDeckMapResource.d.ts.map +1 -0
- package/dist/createOrUpdateDeckMapResource.js +82 -0
- package/dist/createOrUpdateDeckMapResource.js.map +1 -0
- package/dist/dashboard.d.ts +6 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +337 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/dashboardConfig.d.ts +25 -0
- package/dist/dashboardConfig.d.ts.map +1 -0
- package/dist/dashboardConfig.js +82 -0
- package/dist/dashboardConfig.js.map +1 -0
- package/dist/dashboardIntegration.d.ts +3 -0
- package/dist/dashboardIntegration.d.ts.map +1 -0
- package/dist/dashboardIntegration.js +16 -0
- package/dist/dashboardIntegration.js.map +1 -0
- package/dist/datasetSourceUtils.d.ts +16 -0
- package/dist/datasetSourceUtils.d.ts.map +1 -0
- package/dist/datasetSourceUtils.js +25 -0
- package/dist/datasetSourceUtils.js.map +1 -0
- package/dist/datasets/PreparedDatasetStore.d.ts +120 -0
- package/dist/datasets/PreparedDatasetStore.d.ts.map +1 -0
- package/dist/datasets/PreparedDatasetStore.js +268 -0
- package/dist/datasets/PreparedDatasetStore.js.map +1 -0
- package/dist/datasets/helpers.d.ts +57 -0
- package/dist/datasets/helpers.d.ts.map +1 -0
- package/dist/datasets/helpers.js +155 -0
- package/dist/datasets/helpers.js.map +1 -0
- package/dist/datasets/normalizeDatasets.d.ts +11 -0
- package/dist/datasets/normalizeDatasets.d.ts.map +1 -0
- package/dist/datasets/normalizeDatasets.js +50 -0
- package/dist/datasets/normalizeDatasets.js.map +1 -0
- package/dist/datasets/tableAdapter.d.ts +11 -0
- package/dist/datasets/tableAdapter.d.ts.map +1 -0
- package/dist/datasets/tableAdapter.js +11 -0
- package/dist/datasets/tableAdapter.js.map +1 -0
- package/dist/datasets/tableDatasetSql.d.ts +16 -0
- package/dist/datasets/tableDatasetSql.d.ts.map +1 -0
- package/dist/datasets/tableDatasetSql.js +49 -0
- package/dist/datasets/tableDatasetSql.js.map +1 -0
- package/dist/datasets/types.d.ts +40 -0
- package/dist/datasets/types.d.ts.map +1 -0
- package/dist/datasets/types.js +2 -0
- package/dist/datasets/types.js.map +1 -0
- package/dist/datasets/usePreparedDatasetStates.d.ts +16 -0
- package/dist/datasets/usePreparedDatasetStates.d.ts.map +1 -0
- package/dist/datasets/usePreparedDatasetStates.js +59 -0
- package/dist/datasets/usePreparedDatasetStates.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/json/aggregateWaypoints.d.ts +14 -0
- package/dist/json/aggregateWaypoints.d.ts.map +1 -0
- package/dist/json/aggregateWaypoints.js +190 -0
- package/dist/json/aggregateWaypoints.js.map +1 -0
- package/dist/json/colorScaleFunction.d.ts +27 -0
- package/dist/json/colorScaleFunction.d.ts.map +1 -0
- package/dist/json/colorScaleFunction.js +46 -0
- package/dist/json/colorScaleFunction.js.map +1 -0
- package/dist/json/compileColorScale.d.ts +12 -0
- package/dist/json/compileColorScale.d.ts.map +1 -0
- package/dist/json/compileColorScale.js +125 -0
- package/dist/json/compileColorScale.js.map +1 -0
- package/dist/json/compileGeoArrowAccessor.d.ts +18 -0
- package/dist/json/compileGeoArrowAccessor.d.ts.map +1 -0
- package/dist/json/compileGeoArrowAccessor.js +129 -0
- package/dist/json/compileGeoArrowAccessor.js.map +1 -0
- package/dist/json/createDeckJsonConfiguration.d.ts +9 -0
- package/dist/json/createDeckJsonConfiguration.d.ts.map +1 -0
- package/dist/json/createDeckJsonConfiguration.js +315 -0
- package/dist/json/createDeckJsonConfiguration.js.map +1 -0
- package/dist/json/defaultClasses.d.ts +12 -0
- package/dist/json/defaultClasses.d.ts.map +1 -0
- package/dist/json/defaultClasses.js +35 -0
- package/dist/json/defaultClasses.js.map +1 -0
- package/dist/json/extractColorScaleLegends.d.ts +8 -0
- package/dist/json/extractColorScaleLegends.d.ts.map +1 -0
- package/dist/json/extractColorScaleLegends.js +86 -0
- package/dist/json/extractColorScaleLegends.js.map +1 -0
- package/dist/json/heatmapDefaults.d.ts +8 -0
- package/dist/json/heatmapDefaults.d.ts.map +1 -0
- package/dist/json/heatmapDefaults.js +14 -0
- package/dist/json/heatmapDefaults.js.map +1 -0
- package/dist/json/layerCompatibility.d.ts +21 -0
- package/dist/json/layerCompatibility.d.ts.map +1 -0
- package/dist/json/layerCompatibility.js +168 -0
- package/dist/json/layerCompatibility.js.map +1 -0
- package/dist/json/layerConfig.d.ts +14 -0
- package/dist/json/layerConfig.d.ts.map +1 -0
- package/dist/json/layerConfig.js +54 -0
- package/dist/json/layerConfig.js.map +1 -0
- package/dist/json/layers/DeckColumnLayer.d.ts +10 -0
- package/dist/json/layers/DeckColumnLayer.d.ts.map +1 -0
- package/dist/json/layers/DeckColumnLayer.js +26 -0
- package/dist/json/layers/DeckColumnLayer.js.map +1 -0
- package/dist/json/layers/DeckH3HexagonLayer.d.ts +37 -0
- package/dist/json/layers/DeckH3HexagonLayer.d.ts.map +1 -0
- package/dist/json/layers/DeckH3HexagonLayer.js +118 -0
- package/dist/json/layers/DeckH3HexagonLayer.js.map +1 -0
- package/dist/json/layers/DeckTripsLayer.d.ts +46 -0
- package/dist/json/layers/DeckTripsLayer.d.ts.map +1 -0
- package/dist/json/layers/DeckTripsLayer.js +170 -0
- package/dist/json/layers/DeckTripsLayer.js.map +1 -0
- package/dist/json/layers/createTableToRecordBatchAdapter.d.ts +20 -0
- package/dist/json/layers/createTableToRecordBatchAdapter.d.ts.map +1 -0
- package/dist/json/layers/createTableToRecordBatchAdapter.js +81 -0
- package/dist/json/layers/createTableToRecordBatchAdapter.js.map +1 -0
- package/dist/json/layers/index.d.ts +5 -0
- package/dist/json/layers/index.d.ts.map +1 -0
- package/dist/json/layers/index.js +5 -0
- package/dist/json/layers/index.js.map +1 -0
- package/dist/json/rewriteGeoArrowAccessors.d.ts +7 -0
- package/dist/json/rewriteGeoArrowAccessors.d.ts.map +1 -0
- package/dist/json/rewriteGeoArrowAccessors.js +55 -0
- package/dist/json/rewriteGeoArrowAccessors.js.map +1 -0
- package/dist/mapAiConfig.d.ts +111 -0
- package/dist/mapAiConfig.d.ts.map +1 -0
- package/dist/mapAiConfig.js +69 -0
- package/dist/mapAiConfig.js.map +1 -0
- package/dist/mapConfig.d.ts +73 -0
- package/dist/mapConfig.d.ts.map +1 -0
- package/dist/mapConfig.js +47 -0
- package/dist/mapConfig.js.map +1 -0
- package/dist/mapConfigUtils.d.ts +111 -0
- package/dist/mapConfigUtils.d.ts.map +1 -0
- package/dist/mapConfigUtils.js +502 -0
- package/dist/mapConfigUtils.js.map +1 -0
- package/dist/mapDataPolicy.d.ts +9 -0
- package/dist/mapDataPolicy.d.ts.map +1 -0
- package/dist/mapDataPolicy.js +25 -0
- package/dist/mapDataPolicy.js.map +1 -0
- package/dist/mapFit.d.ts +62 -0
- package/dist/mapFit.d.ts.map +1 -0
- package/dist/mapFit.js +325 -0
- package/dist/mapFit.js.map +1 -0
- package/dist/mapLayerConfigUtils.d.ts +54 -0
- package/dist/mapLayerConfigUtils.d.ts.map +1 -0
- package/dist/mapLayerConfigUtils.js +296 -0
- package/dist/mapLayerConfigUtils.js.map +1 -0
- package/dist/mapResourceAuthoring.d.ts +40 -0
- package/dist/mapResourceAuthoring.d.ts.map +1 -0
- package/dist/mapResourceAuthoring.js +266 -0
- package/dist/mapResourceAuthoring.js.map +1 -0
- package/dist/mosaic.d.ts +9 -0
- package/dist/mosaic.d.ts.map +1 -0
- package/dist/mosaic.js +8 -0
- package/dist/mosaic.js.map +1 -0
- package/dist/prepare/detectGeometryColumn.d.ts +19 -0
- package/dist/prepare/detectGeometryColumn.d.ts.map +1 -0
- package/dist/prepare/detectGeometryColumn.js +126 -0
- package/dist/prepare/detectGeometryColumn.js.map +1 -0
- package/dist/prepare/geoarrow.d.ts +18 -0
- package/dist/prepare/geoarrow.d.ts.map +1 -0
- package/dist/prepare/geoarrow.js +114 -0
- package/dist/prepare/geoarrow.js.map +1 -0
- package/dist/prepare/geometryDecoder.d.ts +8 -0
- package/dist/prepare/geometryDecoder.d.ts.map +1 -0
- package/dist/prepare/geometryDecoder.js +2 -0
- package/dist/prepare/geometryDecoder.js.map +1 -0
- package/dist/prepare/prepareDeckDataset.d.ts +57 -0
- package/dist/prepare/prepareDeckDataset.d.ts.map +1 -0
- package/dist/prepare/prepareDeckDataset.js +112 -0
- package/dist/prepare/prepareDeckDataset.js.map +1 -0
- package/dist/prepare/toGeoJsonBinary.d.ts +9 -0
- package/dist/prepare/toGeoJsonBinary.d.ts.map +1 -0
- package/dist/prepare/toGeoJsonBinary.js +26 -0
- package/dist/prepare/toGeoJsonBinary.js.map +1 -0
- package/dist/prepare/types.d.ts +25 -0
- package/dist/prepare/types.d.ts.map +1 -0
- package/dist/prepare/types.js +2 -0
- package/dist/prepare/types.js.map +1 -0
- package/dist/prepare/wkbDecoder.d.ts +3 -0
- package/dist/prepare/wkbDecoder.d.ts.map +1 -0
- package/dist/prepare/wkbDecoder.js +419 -0
- package/dist/prepare/wkbDecoder.js.map +1 -0
- package/dist/prepare/wkbParser.d.ts +24 -0
- package/dist/prepare/wkbParser.d.ts.map +1 -0
- package/dist/prepare/wkbParser.js +139 -0
- package/dist/prepare/wkbParser.js.map +1 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/useDeckMapDatasetSchema.d.ts +33 -0
- package/dist/useDeckMapDatasetSchema.d.ts.map +1 -0
- package/dist/useDeckMapDatasetSchema.js +138 -0
- package/dist/useDeckMapDatasetSchema.js.map +1 -0
- package/dist/useDeckMapDatasets.d.ts +17 -0
- package/dist/useDeckMapDatasets.d.ts.map +1 -0
- package/dist/useDeckMapDatasets.js +69 -0
- package/dist/useDeckMapDatasets.js.map +1 -0
- package/dist/useDeckMapFitToBounds.d.ts +31 -0
- package/dist/useDeckMapFitToBounds.d.ts.map +1 -0
- package/dist/useDeckMapFitToBounds.js +58 -0
- package/dist/useDeckMapFitToBounds.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { isSqlDatasetInput, isTableDatasetInput, } from '../types';
|
|
2
|
+
import { resolveArrowTable } from './normalizeDatasets';
|
|
3
|
+
export const DEFAULT_MAX_PREPARED_DATASET_ENTRIES = 20;
|
|
4
|
+
let nextDatasetAccess = 0;
|
|
5
|
+
let nextTableIdentity = 0;
|
|
6
|
+
let nextSqlSourceIdentity = 0;
|
|
7
|
+
const tableIdentities = new WeakMap();
|
|
8
|
+
const sqlSourceIdentities = new WeakMap();
|
|
9
|
+
/** Return a monotonic access timestamp used by the prepared-dataset LRU. */
|
|
10
|
+
export function nextAccessTimestamp() {
|
|
11
|
+
nextDatasetAccess += 1;
|
|
12
|
+
return nextDatasetAccess;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Assign a stable cache identity to an Arrow table object.
|
|
16
|
+
*
|
|
17
|
+
* Table identities are stored in a `WeakMap` so this cache does not extend the
|
|
18
|
+
* lifetime of tables once they are no longer referenced elsewhere.
|
|
19
|
+
*/
|
|
20
|
+
export function getTableIdentity(table) {
|
|
21
|
+
const cached = tableIdentities.get(table);
|
|
22
|
+
if (cached) {
|
|
23
|
+
return cached;
|
|
24
|
+
}
|
|
25
|
+
nextTableIdentity += 1;
|
|
26
|
+
const identity = `table:${nextTableIdentity}`;
|
|
27
|
+
tableIdentities.set(table, identity);
|
|
28
|
+
return identity;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Assign a stable cache identity to the current SQL source object.
|
|
32
|
+
*
|
|
33
|
+
* For SQL datasets we include the upstream DuckDB connector identity in the
|
|
34
|
+
* cache key so two rooms using the same SQL text do not accidentally share
|
|
35
|
+
* prepared results across different database instances.
|
|
36
|
+
*/
|
|
37
|
+
export function getSqlSourceIdentity(sqlSourceIdentity) {
|
|
38
|
+
const cached = sqlSourceIdentities.get(sqlSourceIdentity);
|
|
39
|
+
if (cached) {
|
|
40
|
+
return cached;
|
|
41
|
+
}
|
|
42
|
+
nextSqlSourceIdentity += 1;
|
|
43
|
+
const identity = `sql-source:${nextSqlSourceIdentity}`;
|
|
44
|
+
sqlSourceIdentities.set(sqlSourceIdentity, identity);
|
|
45
|
+
return identity;
|
|
46
|
+
}
|
|
47
|
+
export function buildGeometryKey(input) {
|
|
48
|
+
return `${input.geometryColumn ?? ''}\u0001${input.geometryEncodingHint ?? ''}`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build the canonical cache key for one dataset input.
|
|
52
|
+
*
|
|
53
|
+
* The key intentionally ignores the user-facing dataset id and instead uses
|
|
54
|
+
* the underlying data identity:
|
|
55
|
+
*
|
|
56
|
+
* - SQL/table datasets: DuckDB connector identity + compiled SQL + geometry options
|
|
57
|
+
* - Arrow datasets: table object identity + geometry options
|
|
58
|
+
*
|
|
59
|
+
* Unresolved Arrow inputs (`arrowTable: undefined`) return `undefined`, which
|
|
60
|
+
* signals that the dataset should remain in `loading` until a table exists.
|
|
61
|
+
*/
|
|
62
|
+
export function resolvePreparedDatasetCacheKey(options) {
|
|
63
|
+
const { input, sqlSourceIdentity } = options;
|
|
64
|
+
if (isSqlDatasetInput(input) || isTableDatasetInput(input)) {
|
|
65
|
+
if (!sqlSourceIdentity) {
|
|
66
|
+
throw new Error('SQL-backed dataset cache keys require a sqlSourceIdentity object.');
|
|
67
|
+
}
|
|
68
|
+
if (isTableDatasetInput(input)) {
|
|
69
|
+
return [
|
|
70
|
+
'table',
|
|
71
|
+
getSqlSourceIdentity(sqlSourceIdentity),
|
|
72
|
+
input.tableName,
|
|
73
|
+
input.transformSql ?? '',
|
|
74
|
+
buildGeometryKey(input),
|
|
75
|
+
].join('\u0001');
|
|
76
|
+
}
|
|
77
|
+
return [
|
|
78
|
+
'sql',
|
|
79
|
+
getSqlSourceIdentity(sqlSourceIdentity),
|
|
80
|
+
input.sqlQuery,
|
|
81
|
+
buildGeometryKey(input),
|
|
82
|
+
].join('\u0001');
|
|
83
|
+
}
|
|
84
|
+
const table = resolveArrowTable(input);
|
|
85
|
+
if (!table) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
return ['arrow', getTableIdentity(table), buildGeometryKey(input)].join('\u0001');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clone a cache entry while replacing its consumer set and refreshing the
|
|
92
|
+
* access timestamp.
|
|
93
|
+
*
|
|
94
|
+
* This keeps the discriminated union shape intact while centralizing the
|
|
95
|
+
* bookkeeping needed by consumer reconciliation and LRU tracking.
|
|
96
|
+
*/
|
|
97
|
+
export function cloneEntryWithConsumers(entry, consumers) {
|
|
98
|
+
const lastAccessedAt = nextAccessTimestamp();
|
|
99
|
+
if (entry.status === 'loading') {
|
|
100
|
+
return {
|
|
101
|
+
status: 'loading',
|
|
102
|
+
promise: entry.promise,
|
|
103
|
+
consumers,
|
|
104
|
+
lastAccessedAt,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (entry.status === 'ready') {
|
|
108
|
+
return {
|
|
109
|
+
status: 'ready',
|
|
110
|
+
prepared: entry.prepared,
|
|
111
|
+
consumers,
|
|
112
|
+
lastAccessedAt,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
status: 'error',
|
|
117
|
+
error: entry.error,
|
|
118
|
+
consumers,
|
|
119
|
+
lastAccessedAt,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Mark an entry as recently used without changing its lifecycle payload. */
|
|
123
|
+
export function touchEntry(entry) {
|
|
124
|
+
return cloneEntryWithConsumers(entry, new Set(entry.consumers));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Evict least-recently-used settled entries when the cache exceeds capacity.
|
|
128
|
+
*
|
|
129
|
+
* Only `ready` and `error` entries participate in eviction. `loading` entries
|
|
130
|
+
* are preserved so in-flight work is not discarded, and referenced entries are
|
|
131
|
+
* preserved so active maps never lose their prepared data mid-render.
|
|
132
|
+
*/
|
|
133
|
+
export function evictLruEntries(entries, maxEntries) {
|
|
134
|
+
const settledEntries = Object.entries(entries).filter(([, entry]) => entry.status !== 'loading');
|
|
135
|
+
if (settledEntries.length <= maxEntries) {
|
|
136
|
+
return entries;
|
|
137
|
+
}
|
|
138
|
+
const evictable = settledEntries
|
|
139
|
+
.filter(([, entry]) => entry.consumers.size === 0)
|
|
140
|
+
.sort(([, left], [, right]) => left.lastAccessedAt - right.lastAccessedAt);
|
|
141
|
+
if (evictable.length === 0) {
|
|
142
|
+
return entries;
|
|
143
|
+
}
|
|
144
|
+
const nextEntries = { ...entries };
|
|
145
|
+
let settledCount = settledEntries.length;
|
|
146
|
+
for (const [cacheKey] of evictable) {
|
|
147
|
+
if (settledCount <= maxEntries) {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
delete nextEntries[cacheKey];
|
|
151
|
+
settledCount -= 1;
|
|
152
|
+
}
|
|
153
|
+
return nextEntries;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","s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C,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7E,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,WAAW,GAAG,EAAC,GAAG,OAAO,EAAC,CAAC;IACjC,IAAI,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC;IAEzC,KAAK,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;QACnC,IAAI,YAAY,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM;QACR,CAAC;QAED,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC7B,YAAY,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import type * as arrow from 'apache-arrow';\nimport {\n isSqlDatasetInput,\n isTableDatasetInput,\n type DeckDatasetInput,\n} from '../types';\nimport {resolveArrowTable} from './normalizeDatasets';\nimport type {PreparedDatasetCacheEntry} from './types';\n\nexport const DEFAULT_MAX_PREPARED_DATASET_ENTRIES = 20;\n\nlet nextDatasetAccess = 0;\nlet nextTableIdentity = 0;\nlet nextSqlSourceIdentity = 0;\n\nconst tableIdentities = new WeakMap<arrow.Table, string>();\nconst sqlSourceIdentities = new WeakMap<object, string>();\n\n/** Return a monotonic access timestamp used by the prepared-dataset LRU. */\nexport function nextAccessTimestamp(): number {\n nextDatasetAccess += 1;\n return nextDatasetAccess;\n}\n\n/**\n * Assign a stable cache identity to an Arrow table object.\n *\n * Table identities are stored in a `WeakMap` so this cache does not extend the\n * lifetime of tables once they are no longer referenced elsewhere.\n */\nexport function getTableIdentity(table: arrow.Table): string {\n const cached = tableIdentities.get(table);\n if (cached) {\n return cached;\n }\n\n nextTableIdentity += 1;\n const identity = `table:${nextTableIdentity}`;\n tableIdentities.set(table, identity);\n return identity;\n}\n\n/**\n * Assign a stable cache identity to the current SQL source object.\n *\n * For SQL datasets we include the upstream DuckDB connector identity in the\n * cache key so two rooms using the same SQL text do not accidentally share\n * prepared results across different database instances.\n */\nexport function getSqlSourceIdentity(sqlSourceIdentity: object): string {\n const cached = sqlSourceIdentities.get(sqlSourceIdentity);\n if (cached) {\n return cached;\n }\n\n nextSqlSourceIdentity += 1;\n const identity = `sql-source:${nextSqlSourceIdentity}`;\n sqlSourceIdentities.set(sqlSourceIdentity, identity);\n return identity;\n}\n\nexport function buildGeometryKey(input: DeckDatasetInput): string {\n return `${input.geometryColumn ?? ''}\\u0001${input.geometryEncodingHint ?? ''}`;\n}\n\n/**\n * Build the canonical cache key for one dataset input.\n *\n * The key intentionally ignores the user-facing dataset id and instead uses\n * the underlying data identity:\n *\n * - SQL/table datasets: DuckDB connector identity + compiled SQL + geometry options\n * - Arrow datasets: table object identity + geometry options\n *\n * Unresolved Arrow inputs (`arrowTable: undefined`) return `undefined`, which\n * signals that the dataset should remain in `loading` until a table exists.\n */\nexport function resolvePreparedDatasetCacheKey(options: {\n input: DeckDatasetInput;\n sqlSourceIdentity?: object;\n}): string | undefined {\n const {input, sqlSourceIdentity} = options;\n\n if (isSqlDatasetInput(input) || isTableDatasetInput(input)) {\n if (!sqlSourceIdentity) {\n throw new Error(\n 'SQL-backed dataset cache keys require a sqlSourceIdentity object.',\n );\n }\n\n if (isTableDatasetInput(input)) {\n return [\n 'table',\n getSqlSourceIdentity(sqlSourceIdentity),\n input.tableName,\n input.transformSql ?? '',\n buildGeometryKey(input),\n ].join('\\u0001');\n }\n\n return [\n 'sql',\n getSqlSourceIdentity(sqlSourceIdentity),\n input.sqlQuery,\n buildGeometryKey(input),\n ].join('\\u0001');\n }\n\n const table = resolveArrowTable(input);\n if (!table) {\n return undefined;\n }\n\n return ['arrow', getTableIdentity(table), buildGeometryKey(input)].join(\n '\\u0001',\n );\n}\n\n/**\n * Clone a cache entry while replacing its consumer set and refreshing the\n * access timestamp.\n *\n * This keeps the discriminated union shape intact while centralizing the\n * bookkeeping needed by consumer reconciliation and LRU tracking.\n */\nexport function cloneEntryWithConsumers(\n entry: PreparedDatasetCacheEntry,\n consumers: Set<string>,\n): PreparedDatasetCacheEntry {\n const lastAccessedAt = nextAccessTimestamp();\n\n if (entry.status === 'loading') {\n return {\n status: 'loading',\n promise: entry.promise,\n consumers,\n lastAccessedAt,\n };\n }\n\n if (entry.status === 'ready') {\n return {\n status: 'ready',\n prepared: entry.prepared,\n consumers,\n lastAccessedAt,\n };\n }\n\n return {\n status: 'error',\n error: entry.error,\n consumers,\n lastAccessedAt,\n };\n}\n\n/** Mark an entry as recently used without changing its lifecycle payload. */\nexport function touchEntry(\n entry: PreparedDatasetCacheEntry,\n): PreparedDatasetCacheEntry {\n return cloneEntryWithConsumers(entry, new Set(entry.consumers));\n}\n\n/**\n * Evict least-recently-used settled entries when the cache exceeds capacity.\n *\n * Only `ready` and `error` entries participate in eviction. `loading` entries\n * are preserved so in-flight work is not discarded, and referenced entries are\n * preserved so active maps never lose their prepared data mid-render.\n */\nexport function evictLruEntries(\n entries: Record<string, PreparedDatasetCacheEntry>,\n maxEntries: number,\n): Record<string, PreparedDatasetCacheEntry> {\n const settledEntries = Object.entries(entries).filter(\n ([, entry]) => entry.status !== 'loading',\n );\n\n if (settledEntries.length <= maxEntries) {\n return entries;\n }\n\n const evictable = settledEntries\n .filter(([, entry]) => entry.consumers.size === 0)\n .sort(([, left], [, right]) => left.lastAccessedAt - right.lastAccessedAt);\n\n if (evictable.length === 0) {\n return entries;\n }\n\n const nextEntries = {...entries};\n let settledCount = settledEntries.length;\n\n for (const [cacheKey] of evictable) {\n if (settledCount <= maxEntries) {\n break;\n }\n\n delete nextEntries[cacheKey];\n settledCount -= 1;\n }\n\n return nextEntries;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as arrow from 'apache-arrow';
|
|
2
|
+
import { type DeckDatasetInput, type DeckJsonMapProps } from '../types';
|
|
3
|
+
export declare function resolveArrowTable(input: DeckDatasetInput): arrow.Table | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Validate and normalize a raw datasets record into canonical
|
|
6
|
+
* `DeckDatasetInput` entries.
|
|
7
|
+
*
|
|
8
|
+
* @throws {Error} If `datasets` is empty (DeckJsonMap requires at least one entry).
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeDatasets(datasets: DeckJsonMapProps['datasets']): Record<string, DeckDatasetInput>;
|
|
11
|
+
//# sourceMappingURL=normalizeDatasets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeDatasets.d.ts","sourceRoot":"","sources":["../../src/datasets/normalizeDatasets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAqClB,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,GACtB,KAAK,CAAC,KAAK,GAAG,SAAS,CAMzB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,GACrC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAalC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isArrowTableDatasetInput, isSqlDatasetInput, isTableDatasetInput, } from '../types';
|
|
2
|
+
import { toArrowTable } from './tableAdapter';
|
|
3
|
+
function normalizeDatasetEntry(datasetId, input) {
|
|
4
|
+
if (isSqlDatasetInput(input)) {
|
|
5
|
+
return {
|
|
6
|
+
sqlQuery: input.sqlQuery,
|
|
7
|
+
geometryColumn: input.geometryColumn,
|
|
8
|
+
geometryEncodingHint: input.geometryEncodingHint,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
if (isArrowTableDatasetInput(input)) {
|
|
12
|
+
return {
|
|
13
|
+
arrowTable: input.arrowTable,
|
|
14
|
+
geometryColumn: input.geometryColumn,
|
|
15
|
+
geometryEncodingHint: input.geometryEncodingHint,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (isTableDatasetInput(input)) {
|
|
19
|
+
return {
|
|
20
|
+
tableName: input.tableName,
|
|
21
|
+
transformSql: input.transformSql,
|
|
22
|
+
geometryColumn: input.geometryColumn,
|
|
23
|
+
geometryEncodingHint: input.geometryEncodingHint,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
throw new Error(`Dataset "${datasetId}" has an unrecognized input shape. Expected { sqlQuery }, { tableName }, { tableName, transformSql }, or { arrowTable }.`);
|
|
27
|
+
}
|
|
28
|
+
export function resolveArrowTable(input) {
|
|
29
|
+
if (!isArrowTableDatasetInput(input) || input.arrowTable === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return toArrowTable(input.arrowTable);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validate and normalize a raw datasets record into canonical
|
|
36
|
+
* `DeckDatasetInput` entries.
|
|
37
|
+
*
|
|
38
|
+
* @throws {Error} If `datasets` is empty (DeckJsonMap requires at least one entry).
|
|
39
|
+
*/
|
|
40
|
+
export function normalizeDatasets(datasets) {
|
|
41
|
+
const entries = Object.entries(datasets);
|
|
42
|
+
if (entries.length === 0) {
|
|
43
|
+
throw new Error('DeckJsonMap requires at least one dataset entry.');
|
|
44
|
+
}
|
|
45
|
+
return Object.fromEntries(entries.map(([datasetId, input]) => [
|
|
46
|
+
datasetId,
|
|
47
|
+
normalizeDatasetEntry(datasetId, input),
|
|
48
|
+
]));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=normalizeDatasets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeDatasets.js","sourceRoot":"","sources":["../../src/datasets/normalizeDatasets.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,mBA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AAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,MAAM,CAAC,WAAW,CACvB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAClC,SAAS;QACT,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC;KACxC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import type * as arrow from 'apache-arrow';\nimport {\n isArrowTableDatasetInput,\n isSqlDatasetInput,\n isTableDatasetInput,\n type DeckDatasetInput,\n type DeckJsonMapProps,\n} from '../types';\nimport {toArrowTable} from './tableAdapter';\n\nfunction normalizeDatasetEntry(\n datasetId: string,\n input: DeckDatasetInput,\n): DeckDatasetInput {\n if (isSqlDatasetInput(input)) {\n return {\n sqlQuery: input.sqlQuery,\n geometryColumn: input.geometryColumn,\n geometryEncodingHint: input.geometryEncodingHint,\n };\n }\n\n if (isArrowTableDatasetInput(input)) {\n return {\n arrowTable: input.arrowTable,\n geometryColumn: input.geometryColumn,\n geometryEncodingHint: input.geometryEncodingHint,\n };\n }\n\n if (isTableDatasetInput(input)) {\n return {\n tableName: input.tableName,\n transformSql: input.transformSql,\n geometryColumn: input.geometryColumn,\n geometryEncodingHint: input.geometryEncodingHint,\n };\n }\n\n throw new Error(\n `Dataset \"${datasetId}\" has an unrecognized input shape. Expected { sqlQuery }, { tableName }, { tableName, transformSql }, or { arrowTable }.`,\n );\n}\n\nexport function resolveArrowTable(\n input: DeckDatasetInput,\n): arrow.Table | undefined {\n if (!isArrowTableDatasetInput(input) || input.arrowTable === undefined) {\n return undefined;\n }\n\n return toArrowTable(input.arrowTable);\n}\n\n/**\n * Validate and normalize a raw datasets record into canonical\n * `DeckDatasetInput` entries.\n *\n * @throws {Error} If `datasets` is empty (DeckJsonMap requires at least one entry).\n */\nexport function normalizeDatasets(\n datasets: DeckJsonMapProps['datasets'],\n): Record<string, DeckDatasetInput> {\n const entries = Object.entries(datasets);\n\n if (entries.length === 0) {\n throw new Error('DeckJsonMap requires at least one dataset entry.');\n }\n\n return Object.fromEntries(\n entries.map(([datasetId, input]) => [\n datasetId,\n normalizeDatasetEntry(datasetId, input),\n ]),\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Table as ArrowTable } from 'apache-arrow';
|
|
2
|
+
export type SupportedTable = ArrowTable;
|
|
3
|
+
/**
|
|
4
|
+
* Normalize supported table runtimes to Apache Arrow for deck preparation.
|
|
5
|
+
*
|
|
6
|
+
* `@sqlrooms/deck` uses Apache Arrow internally because GeoArrow integration
|
|
7
|
+
* and the existing preparation pipeline depend on Arrow's `Table` / `Vector`
|
|
8
|
+
* APIs. The public `arrowTable` dataset input is therefore Apache Arrow.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toArrowTable(table: SupportedTable): ArrowTable;
|
|
11
|
+
//# sourceMappingURL=tableAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableAdapter.d.ts","sourceRoot":"","sources":["../../src/datasets/tableAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC;AAExC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAE9D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize supported table runtimes to Apache Arrow for deck preparation.
|
|
3
|
+
*
|
|
4
|
+
* `@sqlrooms/deck` uses Apache Arrow internally because GeoArrow integration
|
|
5
|
+
* and the existing preparation pipeline depend on Arrow's `Table` / `Vector`
|
|
6
|
+
* APIs. The public `arrowTable` dataset input is therefore Apache Arrow.
|
|
7
|
+
*/
|
|
8
|
+
export function toArrowTable(table) {
|
|
9
|
+
return table;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=tableAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableAdapter.js","sourceRoot":"","sources":["../../src/datasets/tableAdapter.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAqB;IAChD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type {Table as ArrowTable} from 'apache-arrow';\n\nexport type SupportedTable = ArrowTable;\n\n/**\n * Normalize supported table runtimes to Apache Arrow for deck preparation.\n *\n * `@sqlrooms/deck` uses Apache Arrow internally because GeoArrow integration\n * and the existing preparation pipeline depend on Arrow's `Table` / `Vector`\n * APIs. The public `arrowTable` dataset input is therefore Apache Arrow.\n */\nexport function toArrowTable(table: SupportedTable): ArrowTable {\n return table;\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DeckTableDatasetInput } from '../types';
|
|
2
|
+
/** Reserved relation name that table dataset transforms must read from. */
|
|
3
|
+
export declare const DECK_TABLE_DATASET_SOURCE_RELATION = "__sqlrooms_source";
|
|
4
|
+
/** Error thrown when a table dataset input cannot be compiled to a table ref. */
|
|
5
|
+
export declare class DeckTableDatasetInvalidTableNameError extends Error {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Compiles a structured table dataset input into executable SQL.
|
|
10
|
+
*
|
|
11
|
+
* Direct table inputs compile to `SELECT * FROM <quoted table>`. Transformed
|
|
12
|
+
* inputs bind the table to the reserved `__sqlrooms_source` CTE and nest the
|
|
13
|
+
* authored `transformSql` so its CTEs remain self-contained.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createDeckTableDatasetSql(input: DeckTableDatasetInput): string;
|
|
16
|
+
//# sourceMappingURL=tableDatasetSql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableDatasetSql.d.ts","sourceRoot":"","sources":["../../src/datasets/tableDatasetSql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAEpD,2EAA2E;AAC3E,eAAO,MAAM,kCAAkC,sBAAsB,CAAC;AAEtE,iFAAiF;AACjF,qBAAa,qCAAsC,SAAQ,KAAK;;CAK/D;AAqBD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,qBAAqB,GAC3B,MAAM,CAyBR"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { quoteParsedRawSqlTableReference } from '@sqlrooms/duckdb';
|
|
2
|
+
/** Reserved relation name that table dataset transforms must read from. */
|
|
3
|
+
export const DECK_TABLE_DATASET_SOURCE_RELATION = '__sqlrooms_source';
|
|
4
|
+
/** Error thrown when a table dataset input cannot be compiled to a table ref. */
|
|
5
|
+
export class DeckTableDatasetInvalidTableNameError extends Error {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('Deck table dataset input requires a valid tableName.');
|
|
8
|
+
this.name = 'DeckTableDatasetInvalidTableNameError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function cleanTransformSql(transformSql) {
|
|
12
|
+
return transformSql.trim().replace(/(?:\s*;+\s*)+$/, '');
|
|
13
|
+
}
|
|
14
|
+
function createTransformedTableDatasetSql(options) {
|
|
15
|
+
return [
|
|
16
|
+
`WITH ${DECK_TABLE_DATASET_SOURCE_RELATION} AS (`,
|
|
17
|
+
` SELECT * FROM ${options.tableReference}`,
|
|
18
|
+
`)`,
|
|
19
|
+
`SELECT *`,
|
|
20
|
+
`FROM (`,
|
|
21
|
+
options.transformSql,
|
|
22
|
+
`) AS "__sqlrooms_transform"`,
|
|
23
|
+
].join('\n');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Compiles a structured table dataset input into executable SQL.
|
|
27
|
+
*
|
|
28
|
+
* Direct table inputs compile to `SELECT * FROM <quoted table>`. Transformed
|
|
29
|
+
* inputs bind the table to the reserved `__sqlrooms_source` CTE and nest the
|
|
30
|
+
* authored `transformSql` so its CTEs remain self-contained.
|
|
31
|
+
*/
|
|
32
|
+
export function createDeckTableDatasetSql(input) {
|
|
33
|
+
const tableReference = quoteParsedRawSqlTableReference(input.tableName);
|
|
34
|
+
if (!tableReference) {
|
|
35
|
+
throw new DeckTableDatasetInvalidTableNameError();
|
|
36
|
+
}
|
|
37
|
+
if (!input.transformSql?.trim()) {
|
|
38
|
+
return `SELECT * FROM ${tableReference}`;
|
|
39
|
+
}
|
|
40
|
+
const transformSql = cleanTransformSql(input.transformSql);
|
|
41
|
+
if (!new RegExp(`\\b${DECK_TABLE_DATASET_SOURCE_RELATION}\\b`, 'i').test(transformSql)) {
|
|
42
|
+
throw new Error(`Deck table dataset transformSql must reference ${DECK_TABLE_DATASET_SOURCE_RELATION}.`);
|
|
43
|
+
}
|
|
44
|
+
return createTransformedTableDatasetSql({
|
|
45
|
+
tableReference,
|
|
46
|
+
transformSql,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=tableDatasetSql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableDatasetSql.js","sourceRoot":"","sources":["../../src/datasets/tableDatasetSql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,+BAA+B,EAAC,MAAM,kBAAkB,CAAC;AAGjE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kCAAkC,GAAG,mBAAmB,CAAC;AAEtE,iFAAiF;AACjF,MAAM,OAAO,qCAAsC,SAAQ,KAAK;IAC9D;QACE,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,uCAAuC,CAAC;IACtD,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,YAAoB;IAC7C,OAAO,YAAY,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,gCAAgC,CAAC,OAGzC;IACC,OAAO;QACL,QAAQ,kCAAkC,OAAO;QACjD,mBAAmB,OAAO,CAAC,cAAc,EAAE;QAC3C,GAAG;QACH,UAAU;QACV,QAAQ;QACR,OAAO,CAAC,YAAY;QACpB,6BAA6B;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAA4B;IAE5B,MAAM,cAAc,GAAG,+BAA+B,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACxE,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,qCAAqC,EAAE,CAAC;IACpD,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE,EAAE,CAAC;QAChC,OAAO,iBAAiB,cAAc,EAAE,CAAC;IAC3C,CAAC;IAED,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC3D,IACE,CAAC,IAAI,MAAM,CAAC,MAAM,kCAAkC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAClE,YAAY,CACb,EACD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,kDAAkD,kCAAkC,GAAG,CACxF,CAAC;IACJ,CAAC;IAED,OAAO,gCAAgC,CAAC;QACtC,cAAc;QACd,YAAY;KACb,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {quoteParsedRawSqlTableReference} from '@sqlrooms/duckdb';\nimport type {DeckTableDatasetInput} from '../types';\n\n/** Reserved relation name that table dataset transforms must read from. */\nexport const DECK_TABLE_DATASET_SOURCE_RELATION = '__sqlrooms_source';\n\n/** Error thrown when a table dataset input cannot be compiled to a table ref. */\nexport class DeckTableDatasetInvalidTableNameError extends Error {\n constructor() {\n super('Deck table dataset input requires a valid tableName.');\n this.name = 'DeckTableDatasetInvalidTableNameError';\n }\n}\n\nfunction cleanTransformSql(transformSql: string): string {\n return transformSql.trim().replace(/(?:\\s*;+\\s*)+$/, '');\n}\n\nfunction createTransformedTableDatasetSql(options: {\n tableReference: string;\n transformSql: string;\n}) {\n return [\n `WITH ${DECK_TABLE_DATASET_SOURCE_RELATION} AS (`,\n ` SELECT * FROM ${options.tableReference}`,\n `)`,\n `SELECT *`,\n `FROM (`,\n options.transformSql,\n `) AS \"__sqlrooms_transform\"`,\n ].join('\\n');\n}\n\n/**\n * Compiles a structured table dataset input into executable SQL.\n *\n * Direct table inputs compile to `SELECT * FROM <quoted table>`. Transformed\n * inputs bind the table to the reserved `__sqlrooms_source` CTE and nest the\n * authored `transformSql` so its CTEs remain self-contained.\n */\nexport function createDeckTableDatasetSql(\n input: DeckTableDatasetInput,\n): string {\n const tableReference = quoteParsedRawSqlTableReference(input.tableName);\n if (!tableReference) {\n throw new DeckTableDatasetInvalidTableNameError();\n }\n\n if (!input.transformSql?.trim()) {\n return `SELECT * FROM ${tableReference}`;\n }\n\n const transformSql = cleanTransformSql(input.transformSql);\n if (\n !new RegExp(`\\\\b${DECK_TABLE_DATASET_SOURCE_RELATION}\\\\b`, 'i').test(\n transformSql,\n )\n ) {\n throw new Error(\n `Deck table dataset transformSql must reference ${DECK_TABLE_DATASET_SOURCE_RELATION}.`,\n );\n }\n\n return createTransformedTableDatasetSql({\n tableReference,\n transformSql,\n });\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type * as arrow from 'apache-arrow';
|
|
2
|
+
import type { GeometryEncodingHint, PreparedDeckDataset } from '../prepare/types';
|
|
3
|
+
/**
|
|
4
|
+
* One cached prepared-dataset entry keyed by resolved dataset identity.
|
|
5
|
+
*
|
|
6
|
+
* The entry tracks both lifecycle state and eviction metadata:
|
|
7
|
+
*
|
|
8
|
+
* - `consumers` records which hook instances currently reference the entry, so
|
|
9
|
+
* live entries are not evicted while a map is still using them
|
|
10
|
+
* - `lastAccessedAt` drives the internal LRU policy for settled entries
|
|
11
|
+
* - the discriminated union stores either the in-flight preparation promise,
|
|
12
|
+
* the prepared dataset, or the terminal error
|
|
13
|
+
*/
|
|
14
|
+
export type PreparedDatasetCacheEntry = {
|
|
15
|
+
/** Consumer ids currently subscribed to this cache entry. */
|
|
16
|
+
consumers: Set<string>;
|
|
17
|
+
/** Monotonic access counter used to evict the least-recently-used entry. */
|
|
18
|
+
lastAccessedAt: number;
|
|
19
|
+
} & ({
|
|
20
|
+
status: 'loading';
|
|
21
|
+
promise: Promise<void>;
|
|
22
|
+
} | {
|
|
23
|
+
status: 'ready';
|
|
24
|
+
prepared: PreparedDeckDataset;
|
|
25
|
+
} | {
|
|
26
|
+
status: 'error';
|
|
27
|
+
error: Error;
|
|
28
|
+
});
|
|
29
|
+
export type PreparedDatasetStoreOptions = {
|
|
30
|
+
/** Maximum number of settled prepared entries to retain before LRU eviction. */
|
|
31
|
+
maxEntries?: number;
|
|
32
|
+
/** Injectable preparation function for tests and future specialization. */
|
|
33
|
+
prepareDataset?: (options: {
|
|
34
|
+
datasetId: string;
|
|
35
|
+
geometryColumn?: string;
|
|
36
|
+
geometryEncodingHint?: GeometryEncodingHint;
|
|
37
|
+
table: arrow.Table;
|
|
38
|
+
}) => PreparedDeckDataset;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/datasets/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,6DAA6D;IAC7D,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,CACA;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CAAC,GAC3C;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAC,GAChD;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,CAClC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE;QACzB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;QAC5C,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;KACpB,KAAK,mBAAmB,CAAC;CAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/datasets/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as arrow from 'apache-arrow';\nimport type {GeometryEncodingHint, PreparedDeckDataset} from '../prepare/types';\n\n/**\n * One cached prepared-dataset entry keyed by resolved dataset identity.\n *\n * The entry tracks both lifecycle state and eviction metadata:\n *\n * - `consumers` records which hook instances currently reference the entry, so\n * live entries are not evicted while a map is still using them\n * - `lastAccessedAt` drives the internal LRU policy for settled entries\n * - the discriminated union stores either the in-flight preparation promise,\n * the prepared dataset, or the terminal error\n */\nexport type PreparedDatasetCacheEntry = {\n /** Consumer ids currently subscribed to this cache entry. */\n consumers: Set<string>;\n /** Monotonic access counter used to evict the least-recently-used entry. */\n lastAccessedAt: number;\n} & (\n | {status: 'loading'; promise: Promise<void>}\n | {status: 'ready'; prepared: PreparedDeckDataset}\n | {status: 'error'; error: Error}\n);\n\nexport type PreparedDatasetStoreOptions = {\n /** Maximum number of settled prepared entries to retain before LRU eviction. */\n maxEntries?: number;\n /** Injectable preparation function for tests and future specialization. */\n prepareDataset?: (options: {\n datasetId: string;\n geometryColumn?: string;\n geometryEncodingHint?: GeometryEncodingHint;\n table: arrow.Table;\n }) => PreparedDeckDataset;\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type DeckDatasetInput, type PreparedDeckDatasetState } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Subscribe a `DeckJsonMap` instance to prepared dataset state.
|
|
4
|
+
*
|
|
5
|
+
* This hook is intentionally a thin React adapter over the internal prepared
|
|
6
|
+
* dataset store. The heavy work lives in the store so prepared geometry can be
|
|
7
|
+
* reused across rerenders and even across multiple map instances, while the
|
|
8
|
+
* hook itself focuses on subscribing React to the store and cleaning up the
|
|
9
|
+
* consumer membership for this map instance.
|
|
10
|
+
*
|
|
11
|
+
* It preserves the current loading behavior for unresolved Arrow inputs, so a
|
|
12
|
+
* caller can pass `{arrowTable: undefined}` and still render the basemap while
|
|
13
|
+
* data is loading.
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePreparedDatasetStates(datasets: Record<string, DeckDatasetInput>): Record<string, PreparedDeckDatasetState>;
|
|
16
|
+
//# sourceMappingURL=usePreparedDatasetStates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePreparedDatasetStates.d.ts","sourceRoot":"","sources":["../../src/datasets/usePreparedDatasetStates.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,gBAAgB,EAAE,KAAK,wBAAwB,EAAC,MAAM,UAAU,CAAC;AA0B9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GACzC,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CA6B1C"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useStoreWithDuckDb } from '@sqlrooms/duckdb';
|
|
2
|
+
import { useEffect, useId, useMemo, useState } from 'react';
|
|
3
|
+
import { useStore } from 'zustand';
|
|
4
|
+
import { shallow } from 'zustand/shallow';
|
|
5
|
+
import { preparedDatasetStore, resolvePreparedDeckDatasetStates, } from './PreparedDatasetStore';
|
|
6
|
+
/**
|
|
7
|
+
* Stabilize a `datasets` record so that a new object reference created on
|
|
8
|
+
* every render (e.g. an inline `{ earthquakes: { arrowTable } }` literal)
|
|
9
|
+
* does not cause downstream effects and memos to re-run when nothing
|
|
10
|
+
* actually changed. Uses Zustand's `shallow` to compare top-level keys
|
|
11
|
+
* and per-entry identity.
|
|
12
|
+
*
|
|
13
|
+
* Implemented via the "adjusting state during rendering" pattern so the
|
|
14
|
+
* React compiler does not flag ref access during render.
|
|
15
|
+
*/
|
|
16
|
+
function useStableDatasets(datasets) {
|
|
17
|
+
const [stable, setStable] = useState(datasets);
|
|
18
|
+
if (!shallow(stable, datasets)) {
|
|
19
|
+
setStable(datasets);
|
|
20
|
+
}
|
|
21
|
+
return stable;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Subscribe a `DeckJsonMap` instance to prepared dataset state.
|
|
25
|
+
*
|
|
26
|
+
* This hook is intentionally a thin React adapter over the internal prepared
|
|
27
|
+
* dataset store. The heavy work lives in the store so prepared geometry can be
|
|
28
|
+
* reused across rerenders and even across multiple map instances, while the
|
|
29
|
+
* hook itself focuses on subscribing React to the store and cleaning up the
|
|
30
|
+
* consumer membership for this map instance.
|
|
31
|
+
*
|
|
32
|
+
* It preserves the current loading behavior for unresolved Arrow inputs, so a
|
|
33
|
+
* caller can pass `{arrowTable: undefined}` and still render the basemap while
|
|
34
|
+
* data is loading.
|
|
35
|
+
*/
|
|
36
|
+
export function usePreparedDatasetStates(datasets) {
|
|
37
|
+
const stableDatasets = useStableDatasets(datasets);
|
|
38
|
+
const executeSql = useStoreWithDuckDb((state) => state.db.executeSql);
|
|
39
|
+
const connector = useStoreWithDuckDb((state) => state.db.connector);
|
|
40
|
+
const consumerId = useId();
|
|
41
|
+
const entries = useStore(preparedDatasetStore, (state) => state.entries);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
preparedDatasetStore.getState().syncDatasetsForConsumer({
|
|
44
|
+
consumerId,
|
|
45
|
+
datasets: stableDatasets,
|
|
46
|
+
executeSql,
|
|
47
|
+
sqlSourceIdentity: connector,
|
|
48
|
+
});
|
|
49
|
+
return () => {
|
|
50
|
+
preparedDatasetStore.getState().removeConsumer(consumerId);
|
|
51
|
+
};
|
|
52
|
+
}, [connector, consumerId, stableDatasets, executeSql]);
|
|
53
|
+
return useMemo(() => resolvePreparedDeckDatasetStates({
|
|
54
|
+
datasets: stableDatasets,
|
|
55
|
+
entries,
|
|
56
|
+
sqlSourceIdentity: connector,
|
|
57
|
+
}), [connector, stableDatasets, entries]);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=usePreparedDatasetStates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePreparedDatasetStates.js","sourceRoot":"","sources":["../../src/datasets/usePreparedDatasetStates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAExC,OAAO,EACL,oBAAoB,EACpB,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;GASG;AACH,SAAS,iBAAiB,CACxB,QAA0C;IAE1C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC/B,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAA0C;IAE1C,MAAM,cAAc,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,kBAAkB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,kBAAkB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,KAAK,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,QAAQ,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEzE,SAAS,CAAC,GAAG,EAAE;QACb,oBAAoB,CAAC,QAAQ,EAAE,CAAC,uBAAuB,CAAC;YACtD,UAAU;YACV,QAAQ,EAAE,cAAc;YACxB,UAAU;YACV,iBAAiB,EAAE,SAAS;SAC7B,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,oBAAoB,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC7D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;IAExD,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,gCAAgC,CAAC;QAC/B,QAAQ,EAAE,cAAc;QACxB,OAAO;QACP,iBAAiB,EAAE,SAAS;KAC7B,CAAC,EACJ,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,CACrC,CAAC;AACJ,CAAC","sourcesContent":["import {useStoreWithDuckDb} from '@sqlrooms/duckdb';\nimport {useEffect, useId, useMemo, useState} from 'react';\nimport {useStore} from 'zustand';\nimport {shallow} from 'zustand/shallow';\nimport {type DeckDatasetInput, type PreparedDeckDatasetState} from '../types';\nimport {\n preparedDatasetStore,\n resolvePreparedDeckDatasetStates,\n} from './PreparedDatasetStore';\n\n/**\n * Stabilize a `datasets` record so that a new object reference created on\n * every render (e.g. an inline `{ earthquakes: { arrowTable } }` literal)\n * does not cause downstream effects and memos to re-run when nothing\n * actually changed. Uses Zustand's `shallow` to compare top-level keys\n * and per-entry identity.\n *\n * Implemented via the \"adjusting state during rendering\" pattern so the\n * React compiler does not flag ref access during render.\n */\nfunction useStableDatasets(\n datasets: Record<string, DeckDatasetInput>,\n): Record<string, DeckDatasetInput> {\n const [stable, setStable] = useState(datasets);\n if (!shallow(stable, datasets)) {\n setStable(datasets);\n }\n return stable;\n}\n\n/**\n * Subscribe a `DeckJsonMap` instance to prepared dataset state.\n *\n * This hook is intentionally a thin React adapter over the internal prepared\n * dataset store. The heavy work lives in the store so prepared geometry can be\n * reused across rerenders and even across multiple map instances, while the\n * hook itself focuses on subscribing React to the store and cleaning up the\n * consumer membership for this map instance.\n *\n * It preserves the current loading behavior for unresolved Arrow inputs, so a\n * caller can pass `{arrowTable: undefined}` and still render the basemap while\n * data is loading.\n */\nexport function usePreparedDatasetStates(\n datasets: Record<string, DeckDatasetInput>,\n): Record<string, PreparedDeckDatasetState> {\n const stableDatasets = useStableDatasets(datasets);\n const executeSql = useStoreWithDuckDb((state) => state.db.executeSql);\n const connector = useStoreWithDuckDb((state) => state.db.connector);\n const consumerId = useId();\n const entries = useStore(preparedDatasetStore, (state) => state.entries);\n\n useEffect(() => {\n preparedDatasetStore.getState().syncDatasetsForConsumer({\n consumerId,\n datasets: stableDatasets,\n executeSql,\n sqlSourceIdentity: connector,\n });\n\n return () => {\n preparedDatasetStore.getState().removeConsumer(consumerId);\n };\n }, [connector, consumerId, stableDatasets, executeSql]);\n\n return useMemo(\n () =>\n resolvePreparedDeckDatasetStates({\n datasets: stableDatasets,\n entries,\n sqlSourceIdentity: connector,\n }),\n [connector, stableDatasets, entries],\n );\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@include ../README.md}
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
export { ColorScaleLegend } from '@sqlrooms/color-scales';
|
|
6
|
+
export { createDeckJsonSpecFromDatasets } from './createDeckJsonSpecFromDatasets';
|
|
7
|
+
export { DeckMapBlockSettings } from './BlockMapSettings';
|
|
8
|
+
export { DeckMapSettingsPanel, type DeckMapSettingsPanelProps, } from './MapSettings';
|
|
9
|
+
export { DeckMapBlockRenderer, ensureDeckMapResourceState, type DeckMapBlockRendererProps, } from './block';
|
|
10
|
+
export { asDeckJsonMapConfig, createEmptyDeckMapConfig, createDeckMapDashboardPanelConfig, DEFAULT_DECK_MAP_MAX_DATA_POINTS, DECK_MAP_DASHBOARD_PANEL_TYPE, isDeckMapDashboardSqlDatasetSource, isDeckMapDashboardTableDatasetSource, } from './mapConfig';
|
|
11
|
+
export { getDeckMapDataPolicy, type DeckMapDataPolicy } from './mapDataPolicy';
|
|
12
|
+
export { createDeckMapDashboardConfigForTable, createDeckMapConfigForTable, createDeckMapDashboardPanelConfigForTable, createDeckMapPointTransformSql, findDeckMapLongitudeLatitudeColumns, findGeometryColumn, findLongitudeLatitudeColumns, normalizeDeckMapFillColor, normalizeDeckMapPointConfig, quoteDeckMapSqlIdentifier, quoteDeckMapSqlTableReference, regenerateMapConfigForTable, } from './mapConfigUtils';
|
|
13
|
+
export type { DeckMapConfigColumn, DeckMapFillColor, DeckMapTableReference, } from './mapConfigUtils';
|
|
14
|
+
export { getFirstDatasetSourceTableName, hasSqlOnlyDatasetSource, } from './datasetSourceUtils';
|
|
15
|
+
export type { DeckMapDatasetSourceConfig } from './datasetSourceUtils';
|
|
16
|
+
export { DeckMapResourceConfigParameter, DeckMapResourceToolParameters, } from './mapAiConfig';
|
|
17
|
+
export { DeckMapResourceConfigError, assertDeckMapResourceConfig, getDeckMapResourceAiInstructions, getDeckMapResourceConfigIssues, mergeDeckMapResourceConfigPatch, type DeckMapResourceConfigMergeOptions, type DeckMapResourceConfigIssue, type DeckMapResourceConfigValidationOptions, } from './mapResourceAuthoring';
|
|
18
|
+
export { createOrUpdateDeckMapResource, type CreateOrUpdateDeckMapResourceHost, type CreateOrUpdateDeckMapResourceParams, type CreateOrUpdateDeckMapResourceResult, } from './createOrUpdateDeckMapResource';
|
|
19
|
+
export { DeckMapResourceSchema, DeckMapsSliceConfig, createDeckMapsSlice, useStoreWithDeckMaps, } from './DeckMapsSlice';
|
|
20
|
+
export type { DeckMapResource, DeckMapRuntimeIssue, DeckMapRuntimeIssueReporter, DeckMapsSliceState, } from './DeckMapsSlice';
|
|
21
|
+
export { DeckMapSurface, directDeckMapDataAdapter, type DeckMapDataAdapter, type DeckMapSurfaceProps, } from './DeckMapSurface';
|
|
22
|
+
export { DECK_MAP_BLOCK_DEFAULT_HEIGHT, DECK_MAP_BLOCK_DEFAULT_TITLE, DECK_MAP_BLOCK_TYPE, createDeckMapBlockDocumentCommandType, createDeckMapBlockDocumentType, type DeckMapBlockDocumentRegistrationOptions, } from './blockDocumentRegistration';
|
|
23
|
+
export type { DeckMapConfigMode, DeckMapDashboardFitToDataConfig, CreateDeckMapDashboardPanelConfigOptions, DeckMapDashboardDatasetConfig, DeckMapDataPolicyOverride, DeckMapDashboardInteractionConfig, DeckMapDashboardPanelConfig, DeckMapConfig, DeckMapDatasetConfig, DeckMapDatasetSource, DeckMapFitToDataConfig, DeckMapInteractionConfig, } from './mapConfig';
|
|
24
|
+
export { DeckJsonMap } from './DeckJsonMap';
|
|
25
|
+
export { DeckMapDefaultStylesProvider, resolveDeckMapStyle, useDeckMapDefaultStyles, type DeckMapDefaultStyles, type DeckMapStyle, } from './DeckMapDefaultStylesProvider';
|
|
26
|
+
export { ColorScaleFunction, GeometryEncodingHint as DeckGeometryEncodingHint, DeckJsonMapLayerSpec, DeckJsonMapSpec, LayerBindingConfig, LayerBindingProps, } from './DeckJsonMapSpec';
|
|
27
|
+
export { createDeckJsonConfiguration } from './json/createDeckJsonConfiguration';
|
|
28
|
+
export { prepareDeckDataset } from './prepare/prepareDeckDataset';
|
|
29
|
+
export type { ColorLegendConfig, ColorScaleConfig } from '@sqlrooms/color-scales';
|
|
30
|
+
export type { GeometryEncodingHint, PreparedDeckDataset, PreparedGeoArrowLayerData, ResolvedGeometryColumn, ResolvedGeometryEncoding, } from './prepare/types';
|
|
31
|
+
export { isArrowTableDatasetInput, isSqlDatasetInput, isTableDatasetInput, } from './types';
|
|
32
|
+
export { DECK_TABLE_DATASET_SOURCE_RELATION, createDeckTableDatasetSql, } from './datasets/tableDatasetSql';
|
|
33
|
+
export type { CreateDeckJsonSpecFromDatasetsOptions, DeckArrowTableDatasetInput, DeckAutoLayerType, DeckDatasetInput, DeckJsonMapHandle, DeckJsonMapProps, DeckJsonSpecDatasetHint, DeckSqlDatasetInput, DeckTableDatasetInput, DeckTable, PreparedDeckDatasetState, } from './types';
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,8BAA8B,EAAC,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iCAAiC,EACjC,gCAAgC,EAChC,6BAA6B,EAC7B,kCAAkC,EAClC,oCAAoC,GACrC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,oBAAoB,EAAE,KAAK,iBAAiB,EAAC,MAAM,iBAAi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|
|
4
|
+
*/
|
|
5
|
+
export { ColorScaleLegend } from '@sqlrooms/color-scales';
|
|
6
|
+
export { createDeckJsonSpecFromDatasets } from './createDeckJsonSpecFromDatasets';
|
|
7
|
+
export { DeckMapBlockSettings } from './BlockMapSettings';
|
|
8
|
+
export { DeckMapSettingsPanel, } from './MapSettings';
|
|
9
|
+
export { DeckMapBlockRenderer, ensureDeckMapResourceState, } from './block';
|
|
10
|
+
export { asDeckJsonMapConfig, createEmptyDeckMapConfig, createDeckMapDashboardPanelConfig, DEFAULT_DECK_MAP_MAX_DATA_POINTS, DECK_MAP_DASHBOARD_PANEL_TYPE, isDeckMapDashboardSqlDatasetSource, isDeckMapDashboardTableDatasetSource, } from './mapConfig';
|
|
11
|
+
export { getDeckMapDataPolicy } from './mapDataPolicy';
|
|
12
|
+
export { createDeckMapDashboardConfigForTable, createDeckMapConfigForTable, createDeckMapDashboardPanelConfigForTable, createDeckMapPointTransformSql, findDeckMapLongitudeLatitudeColumns, findGeometryColumn, findLongitudeLatitudeColumns, normalizeDeckMapFillColor, normalizeDeckMapPointConfig, quoteDeckMapSqlIdentifier, quoteDeckMapSqlTableReference, regenerateMapConfigForTable, } from './mapConfigUtils';
|
|
13
|
+
export { getFirstDatasetSourceTableName, hasSqlOnlyDatasetSource, } from './datasetSourceUtils';
|
|
14
|
+
export { DeckMapResourceConfigParameter, DeckMapResourceToolParameters, } from './mapAiConfig';
|
|
15
|
+
export { DeckMapResourceConfigError, assertDeckMapResourceConfig, getDeckMapResourceAiInstructions, getDeckMapResourceConfigIssues, mergeDeckMapResourceConfigPatch, } from './mapResourceAuthoring';
|
|
16
|
+
export { createOrUpdateDeckMapResource, } from './createOrUpdateDeckMapResource';
|
|
17
|
+
export { DeckMapResourceSchema, DeckMapsSliceConfig, createDeckMapsSlice, useStoreWithDeckMaps, } from './DeckMapsSlice';
|
|
18
|
+
export { DeckMapSurface, directDeckMapDataAdapter, } from './DeckMapSurface';
|
|
19
|
+
export { DECK_MAP_BLOCK_DEFAULT_HEIGHT, DECK_MAP_BLOCK_DEFAULT_TITLE, DECK_MAP_BLOCK_TYPE, createDeckMapBlockDocumentCommandType, createDeckMapBlockDocumentType, } from './blockDocumentRegistration';
|
|
20
|
+
export { DeckJsonMap } from './DeckJsonMap';
|
|
21
|
+
export { DeckMapDefaultStylesProvider, resolveDeckMapStyle, useDeckMapDefaultStyles, } from './DeckMapDefaultStylesProvider';
|
|
22
|
+
export { ColorScaleFunction, GeometryEncodingHint as DeckGeometryEncodingHint, DeckJsonMapLayerSpec, DeckJsonMapSpec, LayerBindingConfig, LayerBindingProps, } from './DeckJsonMapSpec';
|
|
23
|
+
export { createDeckJsonConfiguration } from './json/createDeckJsonConfiguration';
|
|
24
|
+
export { prepareDeckDataset } from './prepare/prepareDeckDataset';
|
|
25
|
+
export { isArrowTableDatasetInput, isSqlDatasetInput, isTableDatasetInput, } from './types';
|
|
26
|
+
export { DECK_TABLE_DATASET_SOURCE_RELATION, createDeckTableDatasetSql, } from './datasets/tableDatasetSql';
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,8BAA8B,EAAC,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,oBAAoB,GAErB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAE3B,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iCAAiC,EACjC,gCAAgC,EAChC,6BAA6B,EAC7B,kCAAkC,EAClC,oCAAoC,GACrC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,oBAAoB,EAAyB,MAAM,iBAAiB,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,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nexport {ColorScaleLegend} from '@sqlrooms/color-scales';\nexport {createDeckJsonSpecFromDatasets} from './createDeckJsonSpecFromDatasets';\nexport {DeckMapBlockSettings} from './BlockMapSettings';\nexport {\n DeckMapSettingsPanel,\n type DeckMapSettingsPanelProps,\n} from './MapSettings';\nexport {\n DeckMapBlockRenderer,\n ensureDeckMapResourceState,\n type DeckMapBlockRendererProps,\n} from './block';\nexport {\n asDeckJsonMapConfig,\n createEmptyDeckMapConfig,\n createDeckMapDashboardPanelConfig,\n DEFAULT_DECK_MAP_MAX_DATA_POINTS,\n DECK_MAP_DASHBOARD_PANEL_TYPE,\n isDeckMapDashboardSqlDatasetSource,\n isDeckMapDashboardTableDatasetSource,\n} from './mapConfig';\nexport {getDeckMapDataPolicy, type DeckMapDataPolicy} from './mapDataPolicy';\nexport {\n createDeckMapDashboardConfigForTable,\n createDeckMapConfigForTable,\n createDeckMapDashboardPanelConfigForTable,\n createDeckMapPointTransformSql,\n findDeckMapLongitudeLatitudeColumns,\n findGeometryColumn,\n findLongitudeLatitudeColumns,\n normalizeDeckMapFillColor,\n normalizeDeckMapPointConfig,\n quoteDeckMapSqlIdentifier,\n quoteDeckMapSqlTableReference,\n regenerateMapConfigForTable,\n} from './mapConfigUtils';\nexport type {\n DeckMapConfigColumn,\n DeckMapFillColor,\n DeckMapTableReference,\n} from './mapConfigUtils';\nexport {\n getFirstDatasetSourceTableName,\n hasSqlOnlyDatasetSource,\n} from './datasetSourceUtils';\nexport type {DeckMapDatasetSourceConfig} from './datasetSourceUtils';\nexport {\n DeckMapResourceConfigParameter,\n DeckMapResourceToolParameters,\n} from './mapAiConfig';\nexport {\n DeckMapResourceConfigError,\n assertDeckMapResourceConfig,\n getDeckMapResourceAiInstructions,\n getDeckMapResourceConfigIssues,\n mergeDeckMapResourceConfigPatch,\n type DeckMapResourceConfigMergeOptions,\n type DeckMapResourceConfigIssue,\n type DeckMapResourceConfigValidationOptions,\n} from './mapResourceAuthoring';\nexport {\n createOrUpdateDeckMapResource,\n type CreateOrUpdateDeckMapResourceHost,\n type CreateOrUpdateDeckMapResourceParams,\n type CreateOrUpdateDeckMapResourceResult,\n} from './createOrUpdateDeckMapResource';\nexport {\n DeckMapResourceSchema,\n DeckMapsSliceConfig,\n createDeckMapsSlice,\n useStoreWithDeckMaps,\n} from './DeckMapsSlice';\nexport type {\n DeckMapResource,\n DeckMapRuntimeIssue,\n DeckMapRuntimeIssueReporter,\n DeckMapsSliceState,\n} from './DeckMapsSlice';\nexport {\n DeckMapSurface,\n directDeckMapDataAdapter,\n type DeckMapDataAdapter,\n type DeckMapSurfaceProps,\n} from './DeckMapSurface';\nexport {\n DECK_MAP_BLOCK_DEFAULT_HEIGHT,\n DECK_MAP_BLOCK_DEFAULT_TITLE,\n DECK_MAP_BLOCK_TYPE,\n createDeckMapBlockDocumentCommandType,\n createDeckMapBlockDocumentType,\n type DeckMapBlockDocumentRegistrationOptions,\n} from './blockDocumentRegistration';\nexport type {\n DeckMapConfigMode,\n DeckMapDashboardFitToDataConfig,\n CreateDeckMapDashboardPanelConfigOptions,\n DeckMapDashboardDatasetConfig,\n DeckMapDataPolicyOverride,\n DeckMapDashboardInteractionConfig,\n DeckMapDashboardPanelConfig,\n DeckMapConfig,\n DeckMapDatasetConfig,\n DeckMapDatasetSource,\n DeckMapFitToDataConfig,\n DeckMapInteractionConfig,\n} from './mapConfig';\nexport {DeckJsonMap} from './DeckJsonMap';\nexport {\n DeckMapDefaultStylesProvider,\n resolveDeckMapStyle,\n useDeckMapDefaultStyles,\n type DeckMapDefaultStyles,\n type DeckMapStyle,\n} from './DeckMapDefaultStylesProvider';\nexport {\n ColorScaleFunction,\n GeometryEncodingHint as DeckGeometryEncodingHint,\n DeckJsonMapLayerSpec,\n DeckJsonMapSpec,\n LayerBindingConfig,\n LayerBindingProps,\n} from './DeckJsonMapSpec';\nexport {createDeckJsonConfiguration} from './json/createDeckJsonConfiguration';\nexport {prepareDeckDataset} from './prepare/prepareDeckDataset';\n\nexport type {ColorLegendConfig, ColorScaleConfig} from '@sqlrooms/color-scales';\nexport type {\n GeometryEncodingHint,\n PreparedDeckDataset,\n PreparedGeoArrowLayerData,\n ResolvedGeometryColumn,\n ResolvedGeometryEncoding,\n} from './prepare/types';\nexport {\n isArrowTableDatasetInput,\n isSqlDatasetInput,\n isTableDatasetInput,\n} from './types';\nexport {\n DECK_TABLE_DATASET_SOURCE_RELATION,\n createDeckTableDatasetSql,\n} from './datasets/tableDatasetSql';\nexport type {\n CreateDeckJsonSpecFromDatasetsOptions,\n DeckArrowTableDatasetInput,\n DeckAutoLayerType,\n DeckDatasetInput,\n DeckJsonMapHandle,\n DeckJsonMapProps,\n DeckJsonSpecDatasetHint,\n DeckSqlDatasetInput,\n DeckTableDatasetInput,\n DeckTable,\n PreparedDeckDatasetState,\n} from './types';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
/**
|
|
3
|
+
* Auto-aggregates per-waypoint rows into LineString vectors for PathLayer.
|
|
4
|
+
* Detects group-by ID and order columns by naming patterns, groups rows,
|
|
5
|
+
* and builds a GeoArrow List<FixedSizeList<2, Float64>> linestring vector.
|
|
6
|
+
*
|
|
7
|
+
* Also builds a timestamps list column if a timestamp-like column is found,
|
|
8
|
+
* suitable for GeoArrowTripsLayer.
|
|
9
|
+
*/
|
|
10
|
+
export declare function tryAggregateWaypointsToLineStrings(table: arrow.Table): {
|
|
11
|
+
table: arrow.Table;
|
|
12
|
+
geometryVector: arrow.Vector;
|
|
13
|
+
} | null;
|
|
14
|
+
//# sourceMappingURL=aggregateWaypoints.d.ts.map
|