@carto/api-client 0.4.0-alpha.3 → 0.4.0-alpha.4

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.
@@ -6,9 +6,9 @@ import { featureCollection, feature, polygon, multiPolygon } from '@turf/helpers
6
6
 
7
7
  /**
8
8
  * @internal
9
- * @internalRemarks Source: @carto/react-core
9
+ * @internalRemarks Source: @carto/react-core, @carto/constants, @deck.gl/carto
10
10
  */
11
- let client = 'carto-api-client';
11
+ let client = 'deck-gl-carto';
12
12
  /**
13
13
  * Returns current client ID, used to categorize API requests. For internal use only.
14
14
  *
@@ -59,24 +59,6 @@ var ApiVersion;
59
59
  ApiVersion["V2"] = "v2";
60
60
  ApiVersion["V3"] = "v3";
61
61
  })(ApiVersion || (ApiVersion = {}));
62
- /******************************************************************************
63
- * DEFAULTS
64
- */
65
- /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
66
- const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
67
- /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
68
- const DEFAULT_CLIENT = 'deck-gl-carto';
69
- /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
70
- const DEFAULT_GEO_COLUMN = 'geom';
71
- /**
72
- * Fastly default limit is 8192; leave some padding.
73
- * @internalRemarks Source: @deck.gl/carto
74
- */
75
- const DEFAULT_MAX_LENGTH_URL = 7000;
76
- /** @internalRemarks Source: @deck.gl/carto */
77
- const DEFAULT_TILE_SIZE = 512;
78
- /** @internalRemarks Source: @deck.gl/carto */
79
- const DEFAULT_TILE_RESOLUTION = 0.5;
80
62
 
81
63
  const FILTER_TYPES = new Set(Object.values(FilterType));
82
64
  const isFilterType = type => FILTER_TYPES.has(type);
@@ -383,6 +365,30 @@ function _objectWithoutPropertiesLoose(r, e) {
383
365
  return t;
384
366
  }
385
367
 
368
+ /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
369
+ const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
370
+ /** @internal */
371
+ const V3_MINOR_VERSION = '3.4';
372
+ /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
373
+ const DEFAULT_GEO_COLUMN = 'geom';
374
+ /**
375
+ * Fastly default limit is 8192; leave some padding.
376
+ * @internalRemarks Source: @deck.gl/carto
377
+ */
378
+ const DEFAULT_MAX_LENGTH_URL = 7000;
379
+ /** @internalRemarks Source: @deck.gl/carto */
380
+ const DEFAULT_TILE_RESOLUTION = 0.5;
381
+ /**
382
+ * @internalRemarks Source: @deck.gl/carto
383
+ * @internal
384
+ */
385
+ const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
386
+ /**
387
+ * @internalRemarks Source: @deck.gl/carto
388
+ * @internal
389
+ */
390
+ const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
391
+
386
392
  /**
387
393
  * Return more descriptive error from API
388
394
  * @internalRemarks Source: @carto/react-api
@@ -395,7 +401,7 @@ function dealWithApiError({
395
401
  if (data.error === 'Column not found') {
396
402
  throw new InvalidColumnError(`${data.error} ${data.column_name}`);
397
403
  }
398
- if ((_data$error = data.error) != null && _data$error.includes('Missing columns')) {
404
+ if (typeof data.error === 'string' && (_data$error = data.error) != null && _data$error.includes('Missing columns')) {
399
405
  throw new InvalidColumnError(data.error);
400
406
  }
401
407
  switch (response.status) {
@@ -1011,22 +1017,6 @@ function buildQueryUrl({
1011
1017
  return buildV3Path(apiBaseUrl, 'v3', 'sql', connectionName, 'query');
1012
1018
  }
1013
1019
 
1014
- /******************************************************************************
1015
- * VERSIONS
1016
- */
1017
- /** @internal */
1018
- const V3_MINOR_VERSION = '3.4';
1019
- /**
1020
- * @internalRemarks Source: @deck.gl/carto
1021
- * @internal
1022
- */
1023
- const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
1024
- /**
1025
- * @internalRemarks Source: @deck.gl/carto
1026
- * @internal
1027
- */
1028
- const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
1029
-
1030
1020
  const DEFAULT_HEADERS = {
1031
1021
  Accept: 'application/json',
1032
1022
  'Content-Type': 'application/json'
@@ -1044,7 +1034,7 @@ async function requestWithParameters({
1044
1034
  // user-provided parameters.
1045
1035
  parameters = _extends({
1046
1036
  v: V3_MINOR_VERSION,
1047
- client: DEFAULT_CLIENT
1037
+ client: getClient()
1048
1038
  }, typeof deck !== 'undefined' && deck.VERSION && {
1049
1039
  deckglVersion: deck.VERSION
1050
1040
  }, parameters);
@@ -1122,7 +1112,7 @@ function excludeURLParameters(baseUrlString, parameters) {
1122
1112
  const _excluded = ["accessToken", "connectionName", "cache"];
1123
1113
  const SOURCE_DEFAULTS = {
1124
1114
  apiBaseUrl: DEFAULT_API_BASE_URL,
1125
- clientId: DEFAULT_CLIENT,
1115
+ clientId: getClient(),
1126
1116
  format: 'tilejson',
1127
1117
  headers: {},
1128
1118
  maxLengthURL: DEFAULT_MAX_LENGTH_URL
@@ -1490,5 +1480,5 @@ const query = async function query(options) {
1490
1480
  });
1491
1481
  };
1492
1482
 
1493
- export { ApiVersion, CartoAPIError, DEFAULT_API_BASE_URL, DEFAULT_CLIENT, DEFAULT_GEO_COLUMN, DEFAULT_MAX_LENGTH_URL, DEFAULT_TILE_RESOLUTION, DEFAULT_TILE_SIZE, FilterType, SOURCE_DEFAULTS, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, addFilter, boundaryQuerySource, boundaryTableSource, buildPublicMapUrl, buildStatsUrl, clearFilters, createPolygonSpatialFilter, createViewportSpatialFilter, getClient, getFilter, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, setClient, vectorQuerySource, vectorTableSource, vectorTilesetSource };
1483
+ export { ApiVersion, CartoAPIError, FilterType, SOURCE_DEFAULTS, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, addFilter, boundaryQuerySource, boundaryTableSource, buildPublicMapUrl, buildStatsUrl, clearFilters, createPolygonSpatialFilter, createViewportSpatialFilter, getClient, getFilter, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, setClient, vectorQuerySource, vectorTableSource, vectorTilesetSource };
1494
1484
  //# sourceMappingURL=api-client.modern.js.map