@deck.gl/carto 8.7.0-beta.5 → 8.7.0

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.
Files changed (97) hide show
  1. package/dist/dist.dev.js +398 -343
  2. package/dist/es5/api/index.js.map +1 -1
  3. package/dist/es5/api/layer-map.js +8 -8
  4. package/dist/es5/api/layer-map.js.map +1 -1
  5. package/dist/es5/api/maps-api-common.js +15 -1
  6. package/dist/es5/api/maps-api-common.js.map +1 -1
  7. package/dist/es5/api/maps-client.js +15 -18
  8. package/dist/es5/api/maps-client.js.map +1 -1
  9. package/dist/es5/api/maps-v3-client.js +237 -177
  10. package/dist/es5/api/maps-v3-client.js.map +1 -1
  11. package/dist/es5/api/parseMap.js +5 -8
  12. package/dist/es5/api/parseMap.js.map +1 -1
  13. package/dist/es5/basemap.js +7 -7
  14. package/dist/es5/basemap.js.map +1 -1
  15. package/dist/es5/config.js.map +1 -1
  16. package/dist/es5/index.js +4 -4
  17. package/dist/es5/index.js.map +1 -1
  18. package/dist/es5/layers/carto-layer.js +20 -18
  19. package/dist/es5/layers/carto-layer.js.map +1 -1
  20. package/dist/es5/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +24 -24
  21. package/dist/es5/layers/carto-tile-layer.js.map +1 -0
  22. package/dist/es5/layers/schema/{carto-dynamic-tile.js → carto-tile.js} +1 -1
  23. package/dist/es5/layers/schema/carto-tile.js.map +1 -0
  24. package/dist/es5/style/color-bins-style.js +1 -1
  25. package/dist/es5/style/color-bins-style.js.map +1 -1
  26. package/dist/es5/style/color-categories-style.js +1 -1
  27. package/dist/es5/style/color-categories-style.js.map +1 -1
  28. package/dist/es5/style/color-continuous-style.js +1 -1
  29. package/dist/es5/style/color-continuous-style.js.map +1 -1
  30. package/dist/es5/style/palette.js +1 -6
  31. package/dist/es5/style/palette.js.map +1 -1
  32. package/dist/es5/style/utils.js +2 -6
  33. package/dist/es5/style/utils.js.map +1 -1
  34. package/dist/es5/utils.js +13 -0
  35. package/dist/es5/utils.js.map +1 -0
  36. package/dist/esm/api/index.js.map +1 -1
  37. package/dist/esm/api/layer-map.js +5 -4
  38. package/dist/esm/api/layer-map.js.map +1 -1
  39. package/dist/esm/api/maps-api-common.js +14 -0
  40. package/dist/esm/api/maps-api-common.js.map +1 -1
  41. package/dist/esm/api/maps-client.js +6 -10
  42. package/dist/esm/api/maps-client.js.map +1 -1
  43. package/dist/esm/api/maps-v3-client.js +72 -37
  44. package/dist/esm/api/maps-v3-client.js.map +1 -1
  45. package/dist/esm/api/parseMap.js +4 -3
  46. package/dist/esm/api/parseMap.js.map +1 -1
  47. package/dist/esm/basemap.js +7 -7
  48. package/dist/esm/basemap.js.map +1 -1
  49. package/dist/esm/config.js.map +1 -1
  50. package/dist/esm/index.js +2 -2
  51. package/dist/esm/index.js.map +1 -1
  52. package/dist/esm/layers/carto-layer.js +15 -17
  53. package/dist/esm/layers/carto-layer.js.map +1 -1
  54. package/dist/esm/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +16 -16
  55. package/dist/esm/layers/carto-tile-layer.js.map +1 -0
  56. package/dist/esm/layers/schema/{carto-dynamic-tile.js → carto-tile.js} +1 -1
  57. package/dist/esm/layers/schema/carto-tile.js.map +1 -0
  58. package/dist/esm/style/color-bins-style.js +1 -1
  59. package/dist/esm/style/color-bins-style.js.map +1 -1
  60. package/dist/esm/style/color-categories-style.js +1 -1
  61. package/dist/esm/style/color-categories-style.js.map +1 -1
  62. package/dist/esm/style/color-continuous-style.js +1 -1
  63. package/dist/esm/style/color-continuous-style.js.map +1 -1
  64. package/dist/esm/style/palette.js +1 -6
  65. package/dist/esm/style/palette.js.map +1 -1
  66. package/dist/esm/style/utils.js +2 -6
  67. package/dist/esm/style/utils.js.map +1 -1
  68. package/dist/esm/utils.js +5 -0
  69. package/dist/esm/utils.js.map +1 -0
  70. package/dist.min.js +4 -4
  71. package/package.json +8 -2
  72. package/src/api/{index.js → index.ts} +0 -0
  73. package/src/api/{layer-map.js → layer-map.ts} +25 -14
  74. package/src/api/maps-api-common.ts +76 -0
  75. package/src/api/{maps-client.js → maps-client.ts} +55 -20
  76. package/src/api/{maps-v3-client.js → maps-v3-client.ts} +146 -57
  77. package/src/api/{parseMap.js → parseMap.ts} +7 -6
  78. package/src/basemap.ts +10 -0
  79. package/src/{config.js → config.ts} +22 -6
  80. package/src/{index.js → index.ts} +2 -2
  81. package/src/layers/carto-layer.js +13 -12
  82. package/src/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +14 -14
  83. package/src/layers/schema/{carto-dynamic-tile.js → carto-tile.js} +0 -0
  84. package/src/style/color-bins-style.ts +26 -0
  85. package/src/style/{color-categories-style.js → color-categories-style.ts} +10 -4
  86. package/src/style/color-continuous-style.ts +25 -0
  87. package/src/style/{palette.js → palette.ts} +18 -15
  88. package/src/style/{utils.js → utils.ts} +7 -10
  89. package/src/utils.ts +5 -0
  90. package/dist/es5/layers/carto-dynamic-tile-layer.js.map +0 -1
  91. package/dist/es5/layers/schema/carto-dynamic-tile.js.map +0 -1
  92. package/dist/esm/layers/carto-dynamic-tile-layer.js.map +0 -1
  93. package/dist/esm/layers/schema/carto-dynamic-tile.js.map +0 -1
  94. package/src/api/maps-api-common.js +0 -41
  95. package/src/basemap.js +0 -10
  96. package/src/style/color-bins-style.js +0 -21
  97. package/src/style/color-continuous-style.js +0 -20
@@ -24,6 +24,8 @@ var _parseMap = require("./parseMap");
24
24
 
25
25
  var _core = require("@deck.gl/core");
26
26
 
27
+ var _utils = require("../utils");
28
+
27
29
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
28
30
 
29
31
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -37,12 +39,12 @@ function request(_x) {
37
39
 
38
40
  function _request() {
39
41
  _request = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(_ref) {
40
- var method, url, format, accessToken, body, response, headers, json;
42
+ var method, url, accessToken, body, headers;
41
43
  return _regenerator.default.wrap(function _callee$(_context) {
42
44
  while (1) {
43
45
  switch (_context.prev = _context.next) {
44
46
  case 0:
45
- method = _ref.method, url = _ref.url, format = _ref.format, accessToken = _ref.accessToken, body = _ref.body;
47
+ method = _ref.method, url = _ref.url, accessToken = _ref.accessToken, body = _ref.body;
46
48
  headers = {
47
49
  Accept: 'application/json'
48
50
  };
@@ -64,9 +66,7 @@ function _request() {
64
66
  });
65
67
 
66
68
  case 7:
67
- response = _context.sent;
68
- _context.next = 13;
69
- break;
69
+ return _context.abrupt("return", _context.sent);
70
70
 
71
71
  case 10:
72
72
  _context.prev = 10;
@@ -74,19 +74,42 @@ function _request() {
74
74
  throw new Error("Failed to connect to Maps API: ".concat(_context.t0));
75
75
 
76
76
  case 13:
77
- if (!(format === _mapsApiCommon.FORMATS.NDJSON)) {
78
- _context.next = 15;
79
- break;
80
- }
77
+ case "end":
78
+ return _context.stop();
79
+ }
80
+ }
81
+ }, _callee, null, [[4, 10]]);
82
+ }));
83
+ return _request.apply(this, arguments);
84
+ }
81
85
 
82
- return _context.abrupt("return", response);
86
+ function requestJson(_x2) {
87
+ return _requestJson.apply(this, arguments);
88
+ }
83
89
 
84
- case 15:
85
- _context.next = 17;
90
+ function _requestJson() {
91
+ _requestJson = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref2) {
92
+ var method, url, accessToken, body, response, json;
93
+ return _regenerator.default.wrap(function _callee2$(_context2) {
94
+ while (1) {
95
+ switch (_context2.prev = _context2.next) {
96
+ case 0:
97
+ method = _ref2.method, url = _ref2.url, accessToken = _ref2.accessToken, body = _ref2.body;
98
+ _context2.next = 3;
99
+ return request({
100
+ method: method,
101
+ url: url,
102
+ accessToken: accessToken,
103
+ body: body
104
+ });
105
+
106
+ case 3:
107
+ response = _context2.sent;
108
+ _context2.next = 6;
86
109
  return response.json();
87
110
 
88
- case 17:
89
- json = _context.sent;
111
+ case 6:
112
+ json = _context2.sent;
90
113
 
91
114
  if (!response.ok) {
92
115
  dealWithError({
@@ -95,21 +118,69 @@ function _request() {
95
118
  });
96
119
  }
97
120
 
98
- return _context.abrupt("return", json.rows ? json.rows : json);
121
+ return _context2.abrupt("return", json);
99
122
 
100
- case 20:
123
+ case 9:
101
124
  case "end":
102
- return _context.stop();
125
+ return _context2.stop();
103
126
  }
104
127
  }
105
- }, _callee, null, [[4, 10]]);
128
+ }, _callee2);
106
129
  }));
107
- return _request.apply(this, arguments);
130
+ return _requestJson.apply(this, arguments);
131
+ }
132
+
133
+ function requestData(_x3) {
134
+ return _requestData.apply(this, arguments);
135
+ }
136
+
137
+ function _requestData() {
138
+ _requestData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(_ref3) {
139
+ var method, url, accessToken, format, body, data;
140
+ return _regenerator.default.wrap(function _callee3$(_context3) {
141
+ while (1) {
142
+ switch (_context3.prev = _context3.next) {
143
+ case 0:
144
+ method = _ref3.method, url = _ref3.url, accessToken = _ref3.accessToken, format = _ref3.format, body = _ref3.body;
145
+
146
+ if (!(format === _mapsApiCommon.FORMATS.NDJSON)) {
147
+ _context3.next = 3;
148
+ break;
149
+ }
150
+
151
+ return _context3.abrupt("return", request({
152
+ method: method,
153
+ url: url,
154
+ accessToken: accessToken,
155
+ body: body
156
+ }));
157
+
158
+ case 3:
159
+ _context3.next = 5;
160
+ return requestJson({
161
+ method: method,
162
+ url: url,
163
+ accessToken: accessToken,
164
+ body: body
165
+ });
166
+
167
+ case 5:
168
+ data = _context3.sent;
169
+ return _context3.abrupt("return", data.rows ? data.rows : data);
170
+
171
+ case 7:
172
+ case "end":
173
+ return _context3.stop();
174
+ }
175
+ }
176
+ }, _callee3);
177
+ }));
178
+ return _requestData.apply(this, arguments);
108
179
  }
109
180
 
110
- function dealWithError(_ref2) {
111
- var response = _ref2.response,
112
- error = _ref2.error;
181
+ function dealWithError(_ref4) {
182
+ var response = _ref4.response,
183
+ error = _ref4.error;
113
184
 
114
185
  switch (response.status) {
115
186
  case 400:
@@ -124,13 +195,13 @@ function dealWithError(_ref2) {
124
195
  }
125
196
  }
126
197
 
127
- function getParameters(_ref3) {
128
- var type = _ref3.type,
129
- source = _ref3.source,
130
- geoColumn = _ref3.geoColumn,
131
- columns = _ref3.columns,
132
- schema = _ref3.schema,
133
- clientId = _ref3.clientId;
198
+ function getParameters(_ref5) {
199
+ var type = _ref5.type,
200
+ source = _ref5.source,
201
+ geoColumn = _ref5.geoColumn,
202
+ columns = _ref5.columns,
203
+ schema = _ref5.schema,
204
+ clientId = _ref5.clientId;
134
205
  var parameters = [(0, _mapsApiCommon.encodeParameter)('client', clientId || DEFAULT_CLIENT)];
135
206
 
136
207
  if (schema) {
@@ -153,18 +224,18 @@ function getParameters(_ref3) {
153
224
  return parameters.join('&');
154
225
  }
155
226
 
156
- function mapInstantiation(_x2) {
227
+ function mapInstantiation(_x4) {
157
228
  return _mapInstantiation.apply(this, arguments);
158
229
  }
159
230
 
160
231
  function _mapInstantiation() {
161
- _mapInstantiation = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref4) {
162
- var type, source, connection, credentials, geoColumn, columns, schema, clientId, baseUrl, url, accessToken, format, body;
163
- return _regenerator.default.wrap(function _callee2$(_context2) {
232
+ _mapInstantiation = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(_ref6) {
233
+ var type, source, connection, credentials, geoColumn, columns, schema, clientId, baseUrl, url, accessToken, body;
234
+ return _regenerator.default.wrap(function _callee4$(_context4) {
164
235
  while (1) {
165
- switch (_context2.prev = _context2.next) {
236
+ switch (_context4.prev = _context4.next) {
166
237
  case 0:
167
- type = _ref4.type, source = _ref4.source, connection = _ref4.connection, credentials = _ref4.credentials, geoColumn = _ref4.geoColumn, columns = _ref4.columns, schema = _ref4.schema, clientId = _ref4.clientId;
238
+ type = _ref6.type, source = _ref6.source, connection = _ref6.connection, credentials = _ref6.credentials, geoColumn = _ref6.geoColumn, columns = _ref6.columns, schema = _ref6.schema, clientId = _ref6.clientId;
168
239
  baseUrl = "".concat(credentials.mapsUrl, "/").concat(connection, "/").concat(type);
169
240
  url = "".concat(baseUrl, "?").concat(getParameters({
170
241
  type: type,
@@ -175,10 +246,9 @@ function _mapInstantiation() {
175
246
  clientId: clientId
176
247
  }));
177
248
  accessToken = credentials.accessToken;
178
- format = 'json';
179
249
 
180
250
  if (!(url.length > MAX_GET_LENGTH && type === _mapsApiCommon.MAP_TYPES.QUERY)) {
181
- _context2.next = 10;
251
+ _context4.next = 9;
182
252
  break;
183
253
  }
184
254
 
@@ -186,35 +256,33 @@ function _mapInstantiation() {
186
256
  q: source,
187
257
  client: clientId || DEFAULT_CLIENT
188
258
  });
189
- _context2.next = 9;
190
- return request({
259
+ _context4.next = 8;
260
+ return requestJson({
191
261
  method: 'POST',
192
262
  url: baseUrl,
193
- format: format,
194
263
  accessToken: accessToken,
195
264
  body: body
196
265
  });
197
266
 
198
- case 9:
199
- return _context2.abrupt("return", _context2.sent);
267
+ case 8:
268
+ return _context4.abrupt("return", _context4.sent);
200
269
 
201
- case 10:
202
- _context2.next = 12;
203
- return request({
270
+ case 9:
271
+ _context4.next = 11;
272
+ return requestJson({
204
273
  url: url,
205
- format: format,
206
274
  accessToken: accessToken
207
275
  });
208
276
 
209
- case 12:
210
- return _context2.abrupt("return", _context2.sent);
277
+ case 11:
278
+ return _context4.abrupt("return", _context4.sent);
211
279
 
212
- case 13:
280
+ case 12:
213
281
  case "end":
214
- return _context2.stop();
282
+ return _context4.stop();
215
283
  }
216
284
  }
217
- }, _callee2);
285
+ }, _callee4);
218
286
  }));
219
287
  return _mapInstantiation.apply(this, arguments);
220
288
  }
@@ -229,39 +297,33 @@ function getUrlFromMetadata(metadata, format) {
229
297
  return null;
230
298
  }
231
299
 
232
- function checkFetchLayerDataParameters(_ref5) {
233
- var type = _ref5.type,
234
- source = _ref5.source,
235
- connection = _ref5.connection,
236
- localCreds = _ref5.localCreds;
237
-
238
- _core.log.assert(connection, 'Must define connection');
239
-
240
- _core.log.assert(type, 'Must define a type');
241
-
242
- _core.log.assert(source, 'Must define a source');
243
-
244
- _core.log.assert(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
245
-
246
- _core.log.assert(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
247
-
248
- _core.log.assert(localCreds.accessToken, 'Must define an accessToken');
300
+ function checkFetchLayerDataParameters(_ref7) {
301
+ var type = _ref7.type,
302
+ source = _ref7.source,
303
+ connection = _ref7.connection,
304
+ credentials = _ref7.credentials;
305
+ (0, _utils.assert)(connection, 'Must define connection');
306
+ (0, _utils.assert)(type, 'Must define a type');
307
+ (0, _utils.assert)(source, 'Must define a source');
308
+ (0, _utils.assert)(credentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
309
+ (0, _utils.assert)(credentials.apiBaseUrl, 'Must define apiBaseUrl');
310
+ (0, _utils.assert)(credentials.accessToken, 'Must define an accessToken');
249
311
  }
250
312
 
251
- function fetchLayerData(_x3) {
313
+ function fetchLayerData(_x5) {
252
314
  return _fetchLayerData.apply(this, arguments);
253
315
  }
254
316
 
255
317
  function _fetchLayerData() {
256
- _fetchLayerData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(_ref6) {
318
+ _fetchLayerData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(_ref8) {
257
319
  var type, source, connection, credentials, geoColumn, columns, format, schema, clientId, _yield$_fetchDataUrl, url, accessToken, mapFormat, metadata, data, result;
258
320
 
259
- return _regenerator.default.wrap(function _callee3$(_context3) {
321
+ return _regenerator.default.wrap(function _callee5$(_context5) {
260
322
  while (1) {
261
- switch (_context3.prev = _context3.next) {
323
+ switch (_context5.prev = _context5.next) {
262
324
  case 0:
263
- type = _ref6.type, source = _ref6.source, connection = _ref6.connection, credentials = _ref6.credentials, geoColumn = _ref6.geoColumn, columns = _ref6.columns, format = _ref6.format, schema = _ref6.schema, clientId = _ref6.clientId;
264
- _context3.next = 3;
325
+ type = _ref8.type, source = _ref8.source, connection = _ref8.connection, credentials = _ref8.credentials, geoColumn = _ref8.geoColumn, columns = _ref8.columns, format = _ref8.format, schema = _ref8.schema, clientId = _ref8.clientId;
326
+ _context5.next = 3;
265
327
  return _fetchDataUrl({
266
328
  type: type,
267
329
  source: source,
@@ -275,20 +337,20 @@ function _fetchLayerData() {
275
337
  });
276
338
 
277
339
  case 3:
278
- _yield$_fetchDataUrl = _context3.sent;
340
+ _yield$_fetchDataUrl = _context5.sent;
279
341
  url = _yield$_fetchDataUrl.url;
280
342
  accessToken = _yield$_fetchDataUrl.accessToken;
281
343
  mapFormat = _yield$_fetchDataUrl.mapFormat;
282
344
  metadata = _yield$_fetchDataUrl.metadata;
283
- _context3.next = 10;
284
- return request({
345
+ _context5.next = 10;
346
+ return requestData({
285
347
  url: url,
286
348
  format: mapFormat,
287
349
  accessToken: accessToken
288
350
  });
289
351
 
290
352
  case 10:
291
- data = _context3.sent;
353
+ data = _context5.sent;
292
354
  result = {
293
355
  data: data,
294
356
  format: mapFormat
@@ -298,45 +360,45 @@ function _fetchLayerData() {
298
360
  result.schema = metadata.schema;
299
361
  }
300
362
 
301
- return _context3.abrupt("return", result);
363
+ return _context5.abrupt("return", result);
302
364
 
303
365
  case 14:
304
366
  case "end":
305
- return _context3.stop();
367
+ return _context5.stop();
306
368
  }
307
369
  }
308
- }, _callee3);
370
+ }, _callee5);
309
371
  }));
310
372
  return _fetchLayerData.apply(this, arguments);
311
373
  }
312
374
 
313
- function _fetchDataUrl(_x4) {
375
+ function _fetchDataUrl(_x6) {
314
376
  return _fetchDataUrl2.apply(this, arguments);
315
377
  }
316
378
 
317
379
  function _fetchDataUrl2() {
318
- _fetchDataUrl2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(_ref7) {
380
+ _fetchDataUrl2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(_ref9) {
319
381
  var type, source, connection, credentials, geoColumn, columns, format, schema, clientId, defaultCredentials, localCreds, metadata, url, mapFormat, prioritizedFormats, _i, _prioritizedFormats, f, accessToken;
320
382
 
321
- return _regenerator.default.wrap(function _callee4$(_context4) {
383
+ return _regenerator.default.wrap(function _callee6$(_context6) {
322
384
  while (1) {
323
- switch (_context4.prev = _context4.next) {
385
+ switch (_context6.prev = _context6.next) {
324
386
  case 0:
325
- type = _ref7.type, source = _ref7.source, connection = _ref7.connection, credentials = _ref7.credentials, geoColumn = _ref7.geoColumn, columns = _ref7.columns, format = _ref7.format, schema = _ref7.schema, clientId = _ref7.clientId;
387
+ type = _ref9.type, source = _ref9.source, connection = _ref9.connection, credentials = _ref9.credentials, geoColumn = _ref9.geoColumn, columns = _ref9.columns, format = _ref9.format, schema = _ref9.schema, clientId = _ref9.clientId;
326
388
  defaultCredentials = (0, _config.getDefaultCredentials)();
327
389
  localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
328
390
  checkFetchLayerDataParameters({
329
391
  type: type,
330
392
  source: source,
331
393
  connection: connection,
332
- localCreds: localCreds
394
+ credentials: localCreds
333
395
  });
334
396
 
335
397
  if (!localCreds.mapsUrl) {
336
398
  localCreds.mapsUrl = (0, _config.buildMapsUrlFromBase)(localCreds.apiBaseUrl);
337
399
  }
338
400
 
339
- _context4.next = 7;
401
+ _context6.next = 7;
340
402
  return mapInstantiation({
341
403
  type: type,
342
404
  source: source,
@@ -349,28 +411,27 @@ function _fetchDataUrl2() {
349
411
  });
350
412
 
351
413
  case 7:
352
- metadata = _context4.sent;
414
+ metadata = _context6.sent;
415
+ url = null;
353
416
 
354
417
  if (!format) {
355
- _context4.next = 14;
418
+ _context6.next = 15;
356
419
  break;
357
420
  }
358
421
 
359
422
  mapFormat = format;
360
423
  url = getUrlFromMetadata(metadata, format);
361
-
362
- _core.log.assert(url, "Format ".concat(format, " not available"));
363
-
364
- _context4.next = 25;
424
+ (0, _utils.assert)(url, "Format ".concat(format, " not available"));
425
+ _context6.next = 27;
365
426
  break;
366
427
 
367
- case 14:
428
+ case 15:
368
429
  prioritizedFormats = [_mapsApiCommon.FORMATS.GEOJSON, _mapsApiCommon.FORMATS.JSON, _mapsApiCommon.FORMATS.NDJSON, _mapsApiCommon.FORMATS.TILEJSON];
369
430
  _i = 0, _prioritizedFormats = prioritizedFormats;
370
431
 
371
- case 16:
432
+ case 17:
372
433
  if (!(_i < _prioritizedFormats.length)) {
373
- _context4.next = 25;
434
+ _context6.next = 26;
374
435
  break;
375
436
  }
376
437
 
@@ -378,53 +439,56 @@ function _fetchDataUrl2() {
378
439
  url = getUrlFromMetadata(metadata, f);
379
440
 
380
441
  if (!url) {
381
- _context4.next = 22;
442
+ _context6.next = 23;
382
443
  break;
383
444
  }
384
445
 
385
446
  mapFormat = f;
386
- return _context4.abrupt("break", 25);
447
+ return _context6.abrupt("break", 26);
387
448
 
388
- case 22:
449
+ case 23:
389
450
  _i++;
390
- _context4.next = 16;
451
+ _context6.next = 17;
391
452
  break;
392
453
 
393
- case 25:
454
+ case 26:
455
+ (0, _utils.assert)(url && mapFormat, 'Unsupported data formats received from backend.');
456
+
457
+ case 27:
394
458
  accessToken = localCreds.accessToken;
395
- return _context4.abrupt("return", {
459
+ return _context6.abrupt("return", {
396
460
  url: url,
397
461
  accessToken: accessToken,
398
462
  mapFormat: mapFormat,
399
463
  metadata: metadata
400
464
  });
401
465
 
402
- case 27:
466
+ case 29:
403
467
  case "end":
404
- return _context4.stop();
468
+ return _context6.stop();
405
469
  }
406
470
  }
407
- }, _callee4);
471
+ }, _callee6);
408
472
  }));
409
473
  return _fetchDataUrl2.apply(this, arguments);
410
474
  }
411
475
 
412
- function getData(_x5) {
476
+ function getData(_x7) {
413
477
  return _getData.apply(this, arguments);
414
478
  }
415
479
 
416
480
  function _getData() {
417
- _getData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(_ref8) {
481
+ _getData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(_ref10) {
418
482
  var type, source, connection, credentials, geoColumn, columns, format, clientId, layerData;
419
- return _regenerator.default.wrap(function _callee5$(_context5) {
483
+ return _regenerator.default.wrap(function _callee7$(_context7) {
420
484
  while (1) {
421
- switch (_context5.prev = _context5.next) {
485
+ switch (_context7.prev = _context7.next) {
422
486
  case 0:
423
- type = _ref8.type, source = _ref8.source, connection = _ref8.connection, credentials = _ref8.credentials, geoColumn = _ref8.geoColumn, columns = _ref8.columns, format = _ref8.format, clientId = _ref8.clientId;
487
+ type = _ref10.type, source = _ref10.source, connection = _ref10.connection, credentials = _ref10.credentials, geoColumn = _ref10.geoColumn, columns = _ref10.columns, format = _ref10.format, clientId = _ref10.clientId;
424
488
 
425
489
  _core.log.deprecated('getData', 'fetchLayerData')();
426
490
 
427
- _context5.next = 4;
491
+ _context7.next = 4;
428
492
  return fetchLayerData({
429
493
  type: type,
430
494
  source: source,
@@ -438,169 +502,165 @@ function _getData() {
438
502
  });
439
503
 
440
504
  case 4:
441
- layerData = _context5.sent;
442
- return _context5.abrupt("return", layerData.data);
505
+ layerData = _context7.sent;
506
+ return _context7.abrupt("return", layerData.data);
443
507
 
444
508
  case 6:
445
509
  case "end":
446
- return _context5.stop();
510
+ return _context7.stop();
447
511
  }
448
512
  }
449
- }, _callee5);
513
+ }, _callee7);
450
514
  }));
451
515
  return _getData.apply(this, arguments);
452
516
  }
453
517
 
454
- function _fetchMapDataset(_x6, _x7, _x8, _x9) {
518
+ function _fetchMapDataset(_x8, _x9, _x10, _x11) {
455
519
  return _fetchMapDataset2.apply(this, arguments);
456
520
  }
457
521
 
458
522
  function _fetchMapDataset2() {
459
- _fetchMapDataset2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(dataset, accessToken, credentials, clientId) {
460
- var connection, source, type, _yield$_fetchDataUrl2, url, mapFormat, cache, data;
523
+ _fetchMapDataset2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8(dataset, accessToken, credentials, clientId) {
524
+ var connection, columns, geoColumn, source, type, _yield$_fetchDataUrl2, url, mapFormat, cache;
461
525
 
462
- return _regenerator.default.wrap(function _callee6$(_context6) {
526
+ return _regenerator.default.wrap(function _callee8$(_context8) {
463
527
  while (1) {
464
- switch (_context6.prev = _context6.next) {
528
+ switch (_context8.prev = _context8.next) {
465
529
  case 0:
466
- connection = dataset.connectionName, source = dataset.source, type = dataset.type;
467
- _context6.next = 3;
530
+ connection = dataset.connectionName, columns = dataset.columns, geoColumn = dataset.geoColumn, source = dataset.source, type = dataset.type;
531
+ _context8.next = 3;
468
532
  return _fetchDataUrl({
469
533
  credentials: _objectSpread(_objectSpread({}, credentials), {}, {
470
534
  accessToken: accessToken
471
535
  }),
472
536
  connection: connection,
537
+ columns: columns,
538
+ geoColumn: geoColumn,
473
539
  source: source,
474
540
  type: type,
475
541
  clientId: clientId
476
542
  });
477
543
 
478
544
  case 3:
479
- _yield$_fetchDataUrl2 = _context6.sent;
545
+ _yield$_fetchDataUrl2 = _context8.sent;
480
546
  url = _yield$_fetchDataUrl2.url;
481
547
  mapFormat = _yield$_fetchDataUrl2.mapFormat;
482
- cache = parseInt(new URL(url).searchParams.get('cache'), 10);
548
+ cache = parseInt(new URL(url).searchParams.get('cache') || '', 10);
483
549
 
484
550
  if (!(cache && dataset.cache === cache)) {
485
- _context6.next = 9;
551
+ _context8.next = 9;
486
552
  break;
487
553
  }
488
554
 
489
- return _context6.abrupt("return", false);
555
+ return _context8.abrupt("return", false);
490
556
 
491
557
  case 9:
492
558
  dataset.cache = cache;
493
- _context6.next = 12;
494
- return request({
559
+ _context8.next = 12;
560
+ return requestData({
495
561
  url: url,
496
562
  format: mapFormat,
497
563
  accessToken: accessToken
498
564
  });
499
565
 
500
566
  case 12:
501
- data = _context6.sent;
502
- dataset.data = data;
503
- return _context6.abrupt("return", true);
567
+ dataset.data = _context8.sent;
568
+ return _context8.abrupt("return", true);
504
569
 
505
- case 15:
570
+ case 14:
506
571
  case "end":
507
- return _context6.stop();
572
+ return _context8.stop();
508
573
  }
509
574
  }
510
- }, _callee6);
575
+ }, _callee8);
511
576
  }));
512
577
  return _fetchMapDataset2.apply(this, arguments);
513
578
  }
514
579
 
515
- function fillInMapDatasets(_x10, _x11, _x12) {
580
+ function fillInMapDatasets(_x12, _x13, _x14) {
516
581
  return _fillInMapDatasets.apply(this, arguments);
517
582
  }
518
583
 
519
584
  function _fillInMapDatasets() {
520
- _fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(_ref9, clientId, credentials) {
585
+ _fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(_ref11, clientId, credentials) {
521
586
  var datasets, token, promises;
522
- return _regenerator.default.wrap(function _callee7$(_context7) {
587
+ return _regenerator.default.wrap(function _callee9$(_context9) {
523
588
  while (1) {
524
- switch (_context7.prev = _context7.next) {
589
+ switch (_context9.prev = _context9.next) {
525
590
  case 0:
526
- datasets = _ref9.datasets, token = _ref9.token;
591
+ datasets = _ref11.datasets, token = _ref11.token;
527
592
  promises = datasets.map(function (dataset) {
528
593
  return _fetchMapDataset(dataset, token, credentials, clientId);
529
594
  });
530
- _context7.next = 4;
595
+ _context9.next = 4;
531
596
  return Promise.all(promises);
532
597
 
533
598
  case 4:
534
- return _context7.abrupt("return", _context7.sent);
599
+ return _context9.abrupt("return", _context9.sent);
535
600
 
536
601
  case 5:
537
602
  case "end":
538
- return _context7.stop();
603
+ return _context9.stop();
539
604
  }
540
605
  }
541
- }, _callee7);
606
+ }, _callee9);
542
607
  }));
543
608
  return _fillInMapDatasets.apply(this, arguments);
544
609
  }
545
610
 
546
- function fetchMap(_x13) {
611
+ function fetchMap(_x15) {
547
612
  return _fetchMap.apply(this, arguments);
548
613
  }
549
614
 
550
615
  function _fetchMap() {
551
- _fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(_ref10) {
616
+ _fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee11(_ref12) {
552
617
  var cartoMapId, clientId, credentials, autoRefresh, onNewData, defaultCredentials, localCreds, accessToken, url, map, stopAutoRefresh, intervalId;
553
- return _regenerator.default.wrap(function _callee9$(_context9) {
618
+ return _regenerator.default.wrap(function _callee11$(_context11) {
554
619
  while (1) {
555
- switch (_context9.prev = _context9.next) {
620
+ switch (_context11.prev = _context11.next) {
556
621
  case 0:
557
- cartoMapId = _ref10.cartoMapId, clientId = _ref10.clientId, credentials = _ref10.credentials, autoRefresh = _ref10.autoRefresh, onNewData = _ref10.onNewData;
622
+ cartoMapId = _ref12.cartoMapId, clientId = _ref12.clientId, credentials = _ref12.credentials, autoRefresh = _ref12.autoRefresh, onNewData = _ref12.onNewData;
558
623
  defaultCredentials = (0, _config.getDefaultCredentials)();
559
624
  localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
560
625
  accessToken = localCreds.accessToken;
561
-
562
- _core.log.assert(cartoMapId, "Must define CARTO map id: fetchMap({cartoMapId: 'XXXX-XXXX-XXXX'})");
563
-
564
- _core.log.assert(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
565
-
566
- _core.log.assert(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
626
+ (0, _utils.assert)(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
627
+ (0, _utils.assert)(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
628
+ (0, _utils.assert)(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
567
629
 
568
630
  if (!localCreds.mapsUrl) {
569
631
  localCreds.mapsUrl = (0, _config.buildMapsUrlFromBase)(localCreds.apiBaseUrl);
570
632
  }
571
633
 
572
634
  if (autoRefresh || onNewData) {
573
- _core.log.assert(onNewData, 'Must define `onNewData` when using autoRefresh');
574
-
575
- _core.log.assert(typeof onNewData === 'function', '`onNewData` must be a function');
576
-
577
- _core.log.assert(autoRefresh > 0, '`autoRefresh` must be a positive number');
635
+ (0, _utils.assert)(onNewData, 'Must define `onNewData` when using autoRefresh');
636
+ (0, _utils.assert)(typeof onNewData === 'function', '`onNewData` must be a function');
637
+ (0, _utils.assert)(typeof autoRefresh === 'number' && autoRefresh > 0, '`autoRefresh` must be a positive number');
578
638
  }
579
639
 
580
640
  url = "".concat(localCreds.mapsUrl, "/public/").concat(cartoMapId);
581
- _context9.next = 12;
582
- return request({
641
+ _context11.next = 12;
642
+ return requestJson({
583
643
  url: url,
584
644
  accessToken: accessToken
585
645
  });
586
646
 
587
647
  case 12:
588
- map = _context9.sent;
648
+ map = _context11.sent;
589
649
 
590
650
  if (autoRefresh) {
591
- intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8() {
651
+ intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee10() {
592
652
  var changed;
593
- return _regenerator.default.wrap(function _callee8$(_context8) {
653
+ return _regenerator.default.wrap(function _callee10$(_context10) {
594
654
  while (1) {
595
- switch (_context8.prev = _context8.next) {
655
+ switch (_context10.prev = _context10.next) {
596
656
  case 0:
597
- _context8.next = 2;
598
- return fillInMapDatasets(map, clientId, credentials);
657
+ _context10.next = 2;
658
+ return fillInMapDatasets(map, clientId, localCreds);
599
659
 
600
660
  case 2:
601
- changed = _context8.sent;
661
+ changed = _context10.sent;
602
662
 
603
- if (changed.some(function (v) {
663
+ if (onNewData && changed.some(function (v) {
604
664
  return v === true;
605
665
  })) {
606
666
  onNewData((0, _parseMap.parseMap)(map));
@@ -608,10 +668,10 @@ function _fetchMap() {
608
668
 
609
669
  case 4:
610
670
  case "end":
611
- return _context8.stop();
671
+ return _context10.stop();
612
672
  }
613
673
  }
614
- }, _callee8);
674
+ }, _callee10);
615
675
  })), autoRefresh * 1000);
616
676
 
617
677
  stopAutoRefresh = function stopAutoRefresh() {
@@ -619,20 +679,20 @@ function _fetchMap() {
619
679
  };
620
680
  }
621
681
 
622
- _context9.next = 16;
623
- return fillInMapDatasets(map, clientId, credentials);
682
+ _context11.next = 16;
683
+ return fillInMapDatasets(map, clientId, localCreds);
624
684
 
625
685
  case 16:
626
- return _context9.abrupt("return", _objectSpread(_objectSpread({}, (0, _parseMap.parseMap)(map)), {
686
+ return _context11.abrupt("return", _objectSpread(_objectSpread({}, (0, _parseMap.parseMap)(map)), {
627
687
  stopAutoRefresh: stopAutoRefresh
628
688
  }));
629
689
 
630
690
  case 17:
631
691
  case "end":
632
- return _context9.stop();
692
+ return _context11.stop();
633
693
  }
634
694
  }
635
- }, _callee9);
695
+ }, _callee11);
636
696
  }));
637
697
  return _fetchMap.apply(this, arguments);
638
698
  }