@carto/api-client 0.5.13 → 0.5.14

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,14 @@
2
2
 
3
3
  ## 0.5
4
4
 
5
+ ### 0.5.14
6
+
7
+ - feat(widgets): Add 'getExtent()' method, experimental (#220)
8
+
9
+ ### 0.5.13
10
+
11
+ - fix(constants): Export RasterBandColorinterp (#216)
12
+
5
13
  ### 0.5.12
6
14
 
7
15
  - feat(sources): allow passing tags to baseSource and query methods (#193)
@@ -215,11 +215,11 @@ var FilterType = /* @__PURE__ */ ((FilterType2) => {
215
215
  FilterType2["STRING_SEARCH"] = "stringSearch";
216
216
  return FilterType2;
217
217
  })(FilterType || {});
218
- var ApiVersion = /* @__PURE__ */ ((ApiVersion3) => {
219
- ApiVersion3["V1"] = "v1";
220
- ApiVersion3["V2"] = "v2";
221
- ApiVersion3["V3"] = "v3";
222
- return ApiVersion3;
218
+ var ApiVersion = /* @__PURE__ */ ((ApiVersion2) => {
219
+ ApiVersion2["V1"] = "v1";
220
+ ApiVersion2["V2"] = "v2";
221
+ ApiVersion2["V3"] = "v3";
222
+ return ApiVersion2;
223
223
  })(ApiVersion || {});
224
224
  var DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
225
225
  var TileFormat = /* @__PURE__ */ ((TileFormat2) => {
@@ -6861,6 +6861,48 @@ var WidgetRemoteSource = class extends WidgetSource {
6861
6861
  categories: res.metadata?.categories
6862
6862
  }));
6863
6863
  }
6864
+ /** @experimental */
6865
+ async getExtent(options = {}) {
6866
+ const { signal, filters = this.props.filters, filterOwner } = options;
6867
+ const {
6868
+ type,
6869
+ data,
6870
+ apiBaseUrl,
6871
+ apiVersion,
6872
+ connectionName,
6873
+ spatialDataColumn,
6874
+ spatialDataType,
6875
+ queryParameters
6876
+ } = this.getModelSource(filters, filterOwner);
6877
+ assert2(apiVersion === "v3" /* V3 */, "Stats API requires CARTO 3+");
6878
+ let url;
6879
+ const parameters = { filters, spatialDataType };
6880
+ if (type === "query") {
6881
+ url = `${apiBaseUrl}/${apiVersion}/stats/${connectionName}/${spatialDataColumn}`;
6882
+ parameters.q = data;
6883
+ parameters.queryParameters = queryParameters;
6884
+ } else {
6885
+ url = `${apiBaseUrl}/${apiVersion}/stats/${connectionName}/${data}/${spatialDataColumn}`;
6886
+ }
6887
+ const headers = {
6888
+ Authorization: `Bearer ${this.props.accessToken}`,
6889
+ ...this.props.headers
6890
+ };
6891
+ const errorContext = {
6892
+ requestType: "Tile stats",
6893
+ connection: connectionName,
6894
+ type
6895
+ };
6896
+ return requestWithParameters({
6897
+ baseUrl: url,
6898
+ headers,
6899
+ signal,
6900
+ errorContext,
6901
+ parameters
6902
+ }).then(({ extent: { xmin, ymin, xmax, ymax } }) => ({
6903
+ bbox: [xmin, ymin, xmax, ymax]
6904
+ }));
6905
+ }
6864
6906
  };
6865
6907
 
6866
6908
  // src/widget-sources/widget-query-source.ts
@@ -7839,6 +7881,10 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
7839
7881
  max: aggregationFunctions.max(filteredFeatures, column)
7840
7882
  };
7841
7883
  }
7884
+ /** @experimental */
7885
+ async getExtent() {
7886
+ return Promise.reject(new Error("not implemented"));
7887
+ }
7842
7888
  /****************************************************************************
7843
7889
  * INTERNAL
7844
7890
  */
@@ -8069,6 +8115,12 @@ var WidgetTilesetSource = class extends WidgetSource {
8069
8115
  }) {
8070
8116
  return this._executeWorkerMethod("getRange" /* GET_RANGE */, [options], signal);
8071
8117
  }
8118
+ /** @experimental */
8119
+ async getExtent() {
8120
+ return Promise.resolve({
8121
+ bbox: this.props.spatialDataBounds
8122
+ });
8123
+ }
8072
8124
  };
8073
8125
 
8074
8126
  // src/widget-sources/widget-raster-source.ts
@@ -8191,7 +8243,8 @@ var h3TilesetSource = async function(options) {
8191
8243
  ...options,
8192
8244
  tileFormat: getTileFormat(result),
8193
8245
  spatialDataColumn,
8194
- spatialDataType: "h3"
8246
+ spatialDataType: "h3",
8247
+ spatialDataBounds: result.bounds
8195
8248
  })
8196
8249
  })
8197
8250
  );
@@ -8213,6 +8266,7 @@ var rasterSource = async function(options) {
8213
8266
  tileFormat: getTileFormat(result),
8214
8267
  spatialDataColumn: "quadbin",
8215
8268
  spatialDataType: "quadbin",
8269
+ spatialDataBounds: result.bounds,
8216
8270
  rasterMetadata: result.raster_metadata
8217
8271
  })
8218
8272
  })
@@ -8315,7 +8369,8 @@ var quadbinTilesetSource = async function(options) {
8315
8369
  ...options,
8316
8370
  tileFormat: getTileFormat(result),
8317
8371
  spatialDataColumn,
8318
- spatialDataType: "quadbin"
8372
+ spatialDataType: "quadbin",
8373
+ spatialDataBounds: result.bounds
8319
8374
  })
8320
8375
  })
8321
8376
  );
@@ -8419,7 +8474,8 @@ var vectorTilesetSource = async function(options) {
8419
8474
  ...options,
8420
8475
  tileFormat: getTileFormat(result),
8421
8476
  spatialDataColumn,
8422
- spatialDataType: "geo"
8477
+ spatialDataType: "geo",
8478
+ spatialDataBounds: result.bounds
8423
8479
  })
8424
8480
  })
8425
8481
  );