@carto/api-client 0.5.29 → 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 CHANGED
@@ -2,6 +2,8 @@
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
+
5
7
  ### 0.5.29
6
8
 
7
9
  - feat(sources): Support featureBbox parameter (#289)
@@ -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) => ({