@carto/api-client 0.5.28 → 0.5.30-alpha.3cf7d80.116
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/CHANGELOG.md +6 -0
- package/build/api-client.cjs +55 -11
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +43 -4
- package/build/api-client.d.ts +43 -4
- package/build/api-client.js +55 -11
- package/build/api-client.js.map +1 -1
- package/package.json +1 -1
- package/src/fetch-map/fetch-map.ts +22 -0
- package/src/fetch-map/source.ts +2 -0
- package/src/fetch-map/types.ts +1 -0
- package/src/sources/vector-query-source.ts +14 -1
- package/src/sources/vector-table-source.ts +14 -1
- package/src/widget-sources/types.ts +24 -1
- package/src/widget-sources/widget-remote-source.ts +34 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- feat(widgetSources): support `featureIds` / `geometryType` request options to filter widget aggregations by a feature selection without relying on the synthetic `_carto_feature_id` column (#294)
|
|
6
|
+
|
|
7
|
+
### 0.5.29
|
|
8
|
+
|
|
9
|
+
- feat(sources): Support featureBbox parameter (#289)
|
|
10
|
+
|
|
5
11
|
### 0.5.28
|
|
6
12
|
|
|
7
13
|
- feat(fetchMap): Support zoom-dependent point styling (#287)
|
package/build/api-client.cjs
CHANGED
|
@@ -6590,6 +6590,19 @@ init_cjs_shims();
|
|
|
6590
6590
|
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
6591
6591
|
|
|
6592
6592
|
// src/widget-sources/widget-remote-source.ts
|
|
6593
|
+
var FEATURE_IDS_LIMIT = 1e3;
|
|
6594
|
+
function getFeatureSelectionParams(options) {
|
|
6595
|
+
const { featureIds, geometryType } = options;
|
|
6596
|
+
if (!featureIds || featureIds.length === 0) {
|
|
6597
|
+
return {};
|
|
6598
|
+
}
|
|
6599
|
+
assert2(geometryType, "geometryType is required when featureIds are provided");
|
|
6600
|
+
assert2(
|
|
6601
|
+
featureIds.length <= FEATURE_IDS_LIMIT,
|
|
6602
|
+
`featureIds is limited to ${FEATURE_IDS_LIMIT} values, received ${featureIds.length}`
|
|
6603
|
+
);
|
|
6604
|
+
return { featureIds, geometryType };
|
|
6605
|
+
}
|
|
6593
6606
|
var WidgetRemoteSource = class extends WidgetSource {
|
|
6594
6607
|
_getModelSource(filters, filterOwner) {
|
|
6595
6608
|
const props = this.props;
|
|
@@ -6640,7 +6653,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6640
6653
|
operationExp,
|
|
6641
6654
|
operationColumn: operationColumn || column,
|
|
6642
6655
|
othersThreshold,
|
|
6643
|
-
orderBy
|
|
6656
|
+
orderBy,
|
|
6657
|
+
...getFeatureSelectionParams(options)
|
|
6644
6658
|
},
|
|
6645
6659
|
opts: { signal, headers: this.props.headers }
|
|
6646
6660
|
});
|
|
@@ -6710,7 +6724,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6710
6724
|
params: {
|
|
6711
6725
|
column: column ?? "*",
|
|
6712
6726
|
operation: operation2 ?? AggregationTypes.Count,
|
|
6713
|
-
operationExp
|
|
6727
|
+
operationExp,
|
|
6728
|
+
...getFeatureSelectionParams(options)
|
|
6714
6729
|
},
|
|
6715
6730
|
opts: { signal, headers: this.props.headers }
|
|
6716
6731
|
}).then((res) => normalizeObjectKeys(res.rows[0]));
|
|
@@ -6732,7 +6747,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6732
6747
|
spatialFiltersMode,
|
|
6733
6748
|
spatialFilter
|
|
6734
6749
|
},
|
|
6735
|
-
params: { column, operation: operation2, ticks },
|
|
6750
|
+
params: { column, operation: operation2, ticks, ...getFeatureSelectionParams(options) },
|
|
6736
6751
|
opts: { signal, headers: this.props.headers }
|
|
6737
6752
|
}).then((res) => normalizeObjectKeys(res.rows));
|
|
6738
6753
|
if (data.length) {
|
|
@@ -6761,7 +6776,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6761
6776
|
spatialFiltersMode,
|
|
6762
6777
|
spatialFilter
|
|
6763
6778
|
},
|
|
6764
|
-
params: { column },
|
|
6779
|
+
params: { column, ...getFeatureSelectionParams(options) },
|
|
6765
6780
|
opts: { signal, headers: this.props.headers }
|
|
6766
6781
|
}).then((res) => normalizeObjectKeys(res.rows[0]));
|
|
6767
6782
|
}
|
|
@@ -6788,7 +6803,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6788
6803
|
xAxisJoinOperation,
|
|
6789
6804
|
yAxisColumn,
|
|
6790
6805
|
yAxisJoinOperation,
|
|
6791
|
-
limit: HARD_LIMIT
|
|
6806
|
+
limit: HARD_LIMIT,
|
|
6807
|
+
...getFeatureSelectionParams(options)
|
|
6792
6808
|
},
|
|
6793
6809
|
opts: { signal, headers: this.props.headers }
|
|
6794
6810
|
}).then((res) => normalizeObjectKeys(res.rows)).then((res) => res.map(({ x, y }) => [x, y]));
|
|
@@ -6815,7 +6831,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6815
6831
|
sortBy,
|
|
6816
6832
|
sortDirection,
|
|
6817
6833
|
limit,
|
|
6818
|
-
offset
|
|
6834
|
+
offset,
|
|
6835
|
+
...getFeatureSelectionParams(options)
|
|
6819
6836
|
},
|
|
6820
6837
|
opts: { signal, headers: this.props.headers }
|
|
6821
6838
|
}).then((res) => ({
|
|
@@ -6865,7 +6882,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6865
6882
|
operationExp,
|
|
6866
6883
|
splitByCategory,
|
|
6867
6884
|
splitByCategoryLimit,
|
|
6868
|
-
splitByCategoryValues
|
|
6885
|
+
splitByCategoryValues,
|
|
6886
|
+
...getFeatureSelectionParams(options)
|
|
6869
6887
|
},
|
|
6870
6888
|
opts: { signal, headers: this.props.headers }
|
|
6871
6889
|
}).then((res) => ({
|
|
@@ -6890,7 +6908,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6890
6908
|
spatialFilter
|
|
6891
6909
|
},
|
|
6892
6910
|
params: {
|
|
6893
|
-
aggregations
|
|
6911
|
+
aggregations,
|
|
6912
|
+
...getFeatureSelectionParams(options)
|
|
6894
6913
|
},
|
|
6895
6914
|
opts: { signal, headers: this.props.headers }
|
|
6896
6915
|
}).then((res) => ({
|
|
@@ -8564,7 +8583,8 @@ var vectorQuerySource = async function(options) {
|
|
|
8564
8583
|
sqlQuery,
|
|
8565
8584
|
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
8566
8585
|
queryParameters,
|
|
8567
|
-
aggregationExp
|
|
8586
|
+
aggregationExp,
|
|
8587
|
+
featureBbox
|
|
8568
8588
|
} = options;
|
|
8569
8589
|
const spatialDataType = "geo";
|
|
8570
8590
|
const urlParameters = {
|
|
@@ -8585,6 +8605,9 @@ var vectorQuerySource = async function(options) {
|
|
|
8585
8605
|
if (aggregationExp) {
|
|
8586
8606
|
urlParameters.aggregationExp = aggregationExp;
|
|
8587
8607
|
}
|
|
8608
|
+
if (featureBbox) {
|
|
8609
|
+
urlParameters.featureBbox = true;
|
|
8610
|
+
}
|
|
8588
8611
|
return baseSource("query", options, urlParameters).then(
|
|
8589
8612
|
(result) => ({
|
|
8590
8613
|
...result,
|
|
@@ -8608,7 +8631,8 @@ var vectorTableSource = async function(options) {
|
|
|
8608
8631
|
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
8609
8632
|
tableName,
|
|
8610
8633
|
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
8611
|
-
aggregationExp
|
|
8634
|
+
aggregationExp,
|
|
8635
|
+
featureBbox
|
|
8612
8636
|
} = options;
|
|
8613
8637
|
const spatialDataType = "geo";
|
|
8614
8638
|
const urlParameters = {
|
|
@@ -8626,6 +8650,9 @@ var vectorTableSource = async function(options) {
|
|
|
8626
8650
|
if (aggregationExp) {
|
|
8627
8651
|
urlParameters.aggregationExp = aggregationExp;
|
|
8628
8652
|
}
|
|
8653
|
+
if (featureBbox) {
|
|
8654
|
+
urlParameters.featureBbox = true;
|
|
8655
|
+
}
|
|
8629
8656
|
return baseSource("table", options, urlParameters).then(
|
|
8630
8657
|
(result) => ({
|
|
8631
8658
|
...result,
|
|
@@ -11216,11 +11243,13 @@ function configureSource({
|
|
|
11216
11243
|
tileResolution,
|
|
11217
11244
|
...queryParameters && { queryParameters }
|
|
11218
11245
|
};
|
|
11246
|
+
const { featureBbox } = dataset;
|
|
11219
11247
|
const vectorOptions = {
|
|
11220
11248
|
spatialDataColumn,
|
|
11221
11249
|
...columns && { columns },
|
|
11222
11250
|
...filters && { filters },
|
|
11223
|
-
...aggregationExp && { aggregationExp }
|
|
11251
|
+
...aggregationExp && { aggregationExp },
|
|
11252
|
+
...featureBbox && { featureBbox }
|
|
11224
11253
|
};
|
|
11225
11254
|
if (type === "raster") {
|
|
11226
11255
|
return rasterSource({
|
|
@@ -11504,6 +11533,21 @@ async function fetchMap({
|
|
|
11504
11533
|
}
|
|
11505
11534
|
}
|
|
11506
11535
|
});
|
|
11536
|
+
const layers = map.keplerMapConfig.config.visState.layers;
|
|
11537
|
+
const datasetsWithLabels = /* @__PURE__ */ new Set();
|
|
11538
|
+
for (const layer of layers) {
|
|
11539
|
+
const hasTextLabel = layer.config?.textLabel?.some(
|
|
11540
|
+
(t) => t.field?.name
|
|
11541
|
+
);
|
|
11542
|
+
if (hasTextLabel) {
|
|
11543
|
+
datasetsWithLabels.add(layer.config.dataId);
|
|
11544
|
+
}
|
|
11545
|
+
}
|
|
11546
|
+
map.datasets.forEach((dataset) => {
|
|
11547
|
+
if (datasetsWithLabels.has(dataset.id) && (dataset.type === "table" || dataset.type === "query")) {
|
|
11548
|
+
dataset.featureBbox = true;
|
|
11549
|
+
}
|
|
11550
|
+
});
|
|
11507
11551
|
const [basemap] = await Promise.all([
|
|
11508
11552
|
fetchBasemapProps({ config: map.keplerMapConfig.config, errorContext }),
|
|
11509
11553
|
// Mutates map.datasets so that dataset.data contains data
|