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

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.
@@ -12,9 +12,9 @@ var union__default = /*#__PURE__*/_interopDefaultLegacy(union);
12
12
 
13
13
  /**
14
14
  * @internal
15
- * @internalRemarks Source: @carto/react-core
15
+ * @internalRemarks Source: @carto/react-core, @carto/constants, @deck.gl/carto
16
16
  */
17
- let client = 'carto-api-client';
17
+ let client = 'deck-gl-carto';
18
18
  /**
19
19
  * Returns current client ID, used to categorize API requests. For internal use only.
20
20
  *
@@ -65,24 +65,8 @@ exports.ApiVersion = void 0;
65
65
  ApiVersion["V2"] = "v2";
66
66
  ApiVersion["V3"] = "v3";
67
67
  })(exports.ApiVersion || (exports.ApiVersion = {}));
68
- /******************************************************************************
69
- * DEFAULTS
70
- */
71
68
  /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
72
69
  const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
73
- /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
74
- const DEFAULT_CLIENT = 'deck-gl-carto';
75
- /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
76
- const DEFAULT_GEO_COLUMN = 'geom';
77
- /**
78
- * Fastly default limit is 8192; leave some padding.
79
- * @internalRemarks Source: @deck.gl/carto
80
- */
81
- const DEFAULT_MAX_LENGTH_URL = 7000;
82
- /** @internalRemarks Source: @deck.gl/carto */
83
- const DEFAULT_TILE_SIZE = 512;
84
- /** @internalRemarks Source: @deck.gl/carto */
85
- const DEFAULT_TILE_RESOLUTION = 0.5;
86
70
 
87
71
  const FILTER_TYPES = new Set(Object.values(exports.FilterType));
88
72
  const isFilterType = type => FILTER_TYPES.has(type);
@@ -371,6 +355,32 @@ function _isMultiPolygon(geometry) {
371
355
  return invariant.getType(geometry) === 'MultiPolygon';
372
356
  }
373
357
 
358
+ /**
359
+ * Current version of @carto/api-client.
360
+ * @internal
361
+ */
362
+ /** @internal */
363
+ const V3_MINOR_VERSION = '3.4';
364
+ /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
365
+ const DEFAULT_GEO_COLUMN = 'geom';
366
+ /**
367
+ * Fastly default limit is 8192; leave some padding.
368
+ * @internalRemarks Source: @deck.gl/carto
369
+ */
370
+ const DEFAULT_MAX_LENGTH_URL = 7000;
371
+ /** @internalRemarks Source: @deck.gl/carto */
372
+ const DEFAULT_TILE_RESOLUTION = 0.5;
373
+ /**
374
+ * @internalRemarks Source: @deck.gl/carto
375
+ * @internal
376
+ */
377
+ const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
378
+ /**
379
+ * @internalRemarks Source: @deck.gl/carto
380
+ * @internal
381
+ */
382
+ const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
383
+
374
384
  /**
375
385
  * Return more descriptive error from API
376
386
  * @internalRemarks Source: @carto/react-api
@@ -447,7 +457,7 @@ function dealWithApiError(_ref) {
447
457
  if (data.error === 'Column not found') {
448
458
  throw new InvalidColumnError(`${data.error} ${data.column_name}`);
449
459
  }
450
- if (data.error?.includes('Missing columns')) {
460
+ if (typeof data.error === 'string' && data.error?.includes('Missing columns')) {
451
461
  throw new InvalidColumnError(data.error);
452
462
  }
453
463
  switch (response.status) {
@@ -1074,22 +1084,6 @@ function buildQueryUrl(_ref4) {
1074
1084
  return buildV3Path(apiBaseUrl, 'v3', 'sql', connectionName, 'query');
1075
1085
  }
1076
1086
 
1077
- /******************************************************************************
1078
- * VERSIONS
1079
- */
1080
- /** @internal */
1081
- const V3_MINOR_VERSION = '3.4';
1082
- /**
1083
- * @internalRemarks Source: @deck.gl/carto
1084
- * @internal
1085
- */
1086
- const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
1087
- /**
1088
- * @internalRemarks Source: @deck.gl/carto
1089
- * @internal
1090
- */
1091
- const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
1092
-
1093
1087
  // deck.gl
1094
1088
  const requestWithParameters = function (_ref) {
1095
1089
  let {
@@ -1105,7 +1099,7 @@ const requestWithParameters = function (_ref) {
1105
1099
  // user-provided parameters.
1106
1100
  parameters = {
1107
1101
  v: V3_MINOR_VERSION,
1108
- client: DEFAULT_CLIENT,
1102
+ client: getClient(),
1109
1103
  ...(typeof deck !== 'undefined' && deck.VERSION && {
1110
1104
  deckglVersion: deck.VERSION
1111
1105
  }),
@@ -1286,7 +1280,7 @@ const baseSource = function (endpoint, options, urlParameters) {
1286
1280
  };
1287
1281
  const SOURCE_DEFAULTS = {
1288
1282
  apiBaseUrl: DEFAULT_API_BASE_URL,
1289
- clientId: DEFAULT_CLIENT,
1283
+ clientId: getClient(),
1290
1284
  format: 'tilejson',
1291
1285
  headers: {},
1292
1286
  maxLengthURL: DEFAULT_MAX_LENGTH_URL
@@ -1657,11 +1651,6 @@ const query = function (options) {
1657
1651
 
1658
1652
  exports.CartoAPIError = CartoAPIError;
1659
1653
  exports.DEFAULT_API_BASE_URL = DEFAULT_API_BASE_URL;
1660
- exports.DEFAULT_CLIENT = DEFAULT_CLIENT;
1661
- exports.DEFAULT_GEO_COLUMN = DEFAULT_GEO_COLUMN;
1662
- exports.DEFAULT_MAX_LENGTH_URL = DEFAULT_MAX_LENGTH_URL;
1663
- exports.DEFAULT_TILE_RESOLUTION = DEFAULT_TILE_RESOLUTION;
1664
- exports.DEFAULT_TILE_SIZE = DEFAULT_TILE_SIZE;
1665
1654
  exports.SOURCE_DEFAULTS = SOURCE_DEFAULTS;
1666
1655
  exports.WidgetBaseSource = WidgetBaseSource;
1667
1656
  exports.WidgetQuerySource = WidgetQuerySource;