@deck.gl/carto 8.7.0-beta.2 → 8.7.0-beta.6

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 (99) hide show
  1. package/dist/dist.dev.js +1425 -306
  2. package/dist/es5/api/index.js +6 -0
  3. package/dist/es5/api/index.js.map +1 -1
  4. package/dist/es5/api/layer-map.js +32 -17
  5. package/dist/es5/api/layer-map.js.map +1 -1
  6. package/dist/es5/api/maps-api-common.js +21 -1
  7. package/dist/es5/api/maps-api-common.js.map +1 -1
  8. package/dist/es5/api/maps-client.js +15 -18
  9. package/dist/es5/api/maps-client.js.map +1 -1
  10. package/dist/es5/api/maps-v3-client.js +241 -181
  11. package/dist/es5/api/maps-v3-client.js.map +1 -1
  12. package/dist/es5/api/parseMap.js +9 -12
  13. package/dist/es5/api/parseMap.js.map +1 -1
  14. package/dist/es5/basemap.js +7 -7
  15. package/dist/es5/basemap.js.map +1 -1
  16. package/dist/es5/config.js.map +1 -1
  17. package/dist/es5/index.js +15 -1
  18. package/dist/es5/index.js.map +1 -1
  19. package/dist/es5/layers/carto-layer.js +27 -16
  20. package/dist/es5/layers/carto-layer.js.map +1 -1
  21. package/dist/es5/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +79 -32
  22. package/dist/es5/layers/carto-tile-layer.js.map +1 -0
  23. package/dist/es5/layers/schema/carto-tile.js +197 -0
  24. package/dist/es5/layers/schema/carto-tile.js.map +1 -0
  25. package/dist/es5/style/color-bins-style.js +1 -1
  26. package/dist/es5/style/color-bins-style.js.map +1 -1
  27. package/dist/es5/style/color-categories-style.js +1 -1
  28. package/dist/es5/style/color-categories-style.js.map +1 -1
  29. package/dist/es5/style/color-continuous-style.js +1 -1
  30. package/dist/es5/style/color-continuous-style.js.map +1 -1
  31. package/dist/es5/style/palette.js +1 -6
  32. package/dist/es5/style/palette.js.map +1 -1
  33. package/dist/es5/style/utils.js +2 -6
  34. package/dist/es5/style/utils.js.map +1 -1
  35. package/dist/es5/utils.js +13 -0
  36. package/dist/es5/utils.js.map +1 -0
  37. package/dist/esm/api/index.js +1 -1
  38. package/dist/esm/api/index.js.map +1 -1
  39. package/dist/esm/api/layer-map.js +28 -12
  40. package/dist/esm/api/layer-map.js.map +1 -1
  41. package/dist/esm/api/maps-api-common.js +19 -0
  42. package/dist/esm/api/maps-api-common.js.map +1 -1
  43. package/dist/esm/api/maps-client.js +6 -10
  44. package/dist/esm/api/maps-client.js.map +1 -1
  45. package/dist/esm/api/maps-v3-client.js +73 -38
  46. package/dist/esm/api/maps-v3-client.js.map +1 -1
  47. package/dist/esm/api/parseMap.js +9 -8
  48. package/dist/esm/api/parseMap.js.map +1 -1
  49. package/dist/esm/basemap.js +7 -7
  50. package/dist/esm/basemap.js.map +1 -1
  51. package/dist/esm/config.js.map +1 -1
  52. package/dist/esm/index.js +3 -2
  53. package/dist/esm/index.js.map +1 -1
  54. package/dist/esm/layers/carto-layer.js +25 -13
  55. package/dist/esm/layers/carto-layer.js.map +1 -1
  56. package/dist/esm/layers/carto-tile-layer.js +141 -0
  57. package/dist/esm/layers/carto-tile-layer.js.map +1 -0
  58. package/dist/esm/layers/schema/carto-tile.js +190 -0
  59. package/dist/esm/layers/schema/carto-tile.js.map +1 -0
  60. package/dist/esm/style/color-bins-style.js +1 -1
  61. package/dist/esm/style/color-bins-style.js.map +1 -1
  62. package/dist/esm/style/color-categories-style.js +1 -1
  63. package/dist/esm/style/color-categories-style.js.map +1 -1
  64. package/dist/esm/style/color-continuous-style.js +1 -1
  65. package/dist/esm/style/color-continuous-style.js.map +1 -1
  66. package/dist/esm/style/palette.js +1 -6
  67. package/dist/esm/style/palette.js.map +1 -1
  68. package/dist/esm/style/utils.js +2 -6
  69. package/dist/esm/style/utils.js.map +1 -1
  70. package/dist/esm/utils.js +5 -0
  71. package/dist/esm/utils.js.map +1 -0
  72. package/dist.min.js +14 -14
  73. package/package.json +10 -3
  74. package/src/api/{index.js → index.ts} +1 -1
  75. package/src/api/{layer-map.js → layer-map.ts} +50 -23
  76. package/src/api/maps-api-common.ts +76 -0
  77. package/src/api/{maps-client.js → maps-client.ts} +55 -20
  78. package/src/api/{maps-v3-client.js → maps-v3-client.ts} +145 -57
  79. package/src/api/{parseMap.js → parseMap.ts} +8 -7
  80. package/src/basemap.ts +10 -0
  81. package/src/{config.js → config.ts} +22 -6
  82. package/src/{index.js → index.ts} +3 -1
  83. package/src/layers/carto-layer.js +30 -19
  84. package/src/layers/carto-tile-layer.js +121 -0
  85. package/src/layers/schema/carto-tile.js +195 -0
  86. package/src/style/color-bins-style.ts +26 -0
  87. package/src/style/{color-categories-style.js → color-categories-style.ts} +10 -4
  88. package/src/style/color-continuous-style.ts +25 -0
  89. package/src/style/{palette.js → palette.ts} +18 -15
  90. package/src/style/{utils.js → utils.ts} +7 -10
  91. package/src/utils.ts +5 -0
  92. package/dist/es5/layers/carto-dynamic-tile-layer.js.map +0 -1
  93. package/dist/esm/layers/carto-dynamic-tile-layer.js +0 -97
  94. package/dist/esm/layers/carto-dynamic-tile-layer.js.map +0 -1
  95. package/src/api/maps-api-common.js +0 -34
  96. package/src/basemap.js +0 -10
  97. package/src/layers/carto-dynamic-tile-layer.js +0 -86
  98. package/src/style/color-bins-style.js +0 -21
  99. 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,33 +502,33 @@ 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, 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
530
  connection = dataset.connectionName, source = dataset.source, type = dataset.type;
467
- _context6.next = 3;
531
+ _context8.next = 3;
468
532
  return _fetchDataUrl({
469
533
  credentials: _objectSpread(_objectSpread({}, credentials), {}, {
470
534
  accessToken: accessToken
@@ -476,129 +540,125 @@ function _fetchMapDataset2() {
476
540
  });
477
541
 
478
542
  case 3:
479
- _yield$_fetchDataUrl2 = _context6.sent;
543
+ _yield$_fetchDataUrl2 = _context8.sent;
480
544
  url = _yield$_fetchDataUrl2.url;
481
545
  mapFormat = _yield$_fetchDataUrl2.mapFormat;
482
- cache = parseInt(new URLSearchParams(url).get('cache'), 10);
546
+ cache = parseInt(new URL(url).searchParams.get('cache') || '', 10);
483
547
 
484
548
  if (!(cache && dataset.cache === cache)) {
485
- _context6.next = 9;
549
+ _context8.next = 9;
486
550
  break;
487
551
  }
488
552
 
489
- return _context6.abrupt("return", false);
553
+ return _context8.abrupt("return", false);
490
554
 
491
555
  case 9:
492
556
  dataset.cache = cache;
493
- _context6.next = 12;
494
- return request({
557
+ _context8.next = 12;
558
+ return requestData({
495
559
  url: url,
496
560
  format: mapFormat,
497
561
  accessToken: accessToken
498
562
  });
499
563
 
500
564
  case 12:
501
- data = _context6.sent;
502
- dataset.data = data;
503
- return _context6.abrupt("return", true);
565
+ dataset.data = _context8.sent;
566
+ return _context8.abrupt("return", true);
504
567
 
505
- case 15:
568
+ case 14:
506
569
  case "end":
507
- return _context6.stop();
570
+ return _context8.stop();
508
571
  }
509
572
  }
510
- }, _callee6);
573
+ }, _callee8);
511
574
  }));
512
575
  return _fetchMapDataset2.apply(this, arguments);
513
576
  }
514
577
 
515
- function fillInMapDatasets(_x10, _x11, _x12) {
578
+ function fillInMapDatasets(_x12, _x13, _x14) {
516
579
  return _fillInMapDatasets.apply(this, arguments);
517
580
  }
518
581
 
519
582
  function _fillInMapDatasets() {
520
- _fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(_ref9, clientId, credentials) {
583
+ _fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(_ref11, clientId, credentials) {
521
584
  var datasets, token, promises;
522
- return _regenerator.default.wrap(function _callee7$(_context7) {
585
+ return _regenerator.default.wrap(function _callee9$(_context9) {
523
586
  while (1) {
524
- switch (_context7.prev = _context7.next) {
587
+ switch (_context9.prev = _context9.next) {
525
588
  case 0:
526
- datasets = _ref9.datasets, token = _ref9.token;
589
+ datasets = _ref11.datasets, token = _ref11.token;
527
590
  promises = datasets.map(function (dataset) {
528
591
  return _fetchMapDataset(dataset, token, credentials, clientId);
529
592
  });
530
- _context7.next = 4;
593
+ _context9.next = 4;
531
594
  return Promise.all(promises);
532
595
 
533
596
  case 4:
534
- return _context7.abrupt("return", _context7.sent);
597
+ return _context9.abrupt("return", _context9.sent);
535
598
 
536
599
  case 5:
537
600
  case "end":
538
- return _context7.stop();
601
+ return _context9.stop();
539
602
  }
540
603
  }
541
- }, _callee7);
604
+ }, _callee9);
542
605
  }));
543
606
  return _fillInMapDatasets.apply(this, arguments);
544
607
  }
545
608
 
546
- function fetchMap(_x13) {
609
+ function fetchMap(_x15) {
547
610
  return _fetchMap.apply(this, arguments);
548
611
  }
549
612
 
550
613
  function _fetchMap() {
551
- _fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(_ref10) {
552
- var cartoMapId, clientId, credentials, autoRefresh, onNewData, defaultCredentials, localCreds, url, map, stopAutoRefresh, intervalId;
553
- return _regenerator.default.wrap(function _callee9$(_context9) {
614
+ _fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee11(_ref12) {
615
+ var cartoMapId, clientId, credentials, autoRefresh, onNewData, defaultCredentials, localCreds, accessToken, url, map, stopAutoRefresh, intervalId;
616
+ return _regenerator.default.wrap(function _callee11$(_context11) {
554
617
  while (1) {
555
- switch (_context9.prev = _context9.next) {
618
+ switch (_context11.prev = _context11.next) {
556
619
  case 0:
557
- cartoMapId = _ref10.cartoMapId, clientId = _ref10.clientId, credentials = _ref10.credentials, autoRefresh = _ref10.autoRefresh, onNewData = _ref10.onNewData;
620
+ cartoMapId = _ref12.cartoMapId, clientId = _ref12.clientId, credentials = _ref12.credentials, autoRefresh = _ref12.autoRefresh, onNewData = _ref12.onNewData;
558
621
  defaultCredentials = (0, _config.getDefaultCredentials)();
559
622
  localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
560
-
561
- _core.log.assert(cartoMapId, "Must define CARTO map id: fetchMap({cartoMapId: 'XXXX-XXXX-XXXX'})");
562
-
563
- _core.log.assert(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
564
-
565
- _core.log.assert(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
623
+ accessToken = localCreds.accessToken;
624
+ (0, _utils.assert)(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
625
+ (0, _utils.assert)(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
626
+ (0, _utils.assert)(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
566
627
 
567
628
  if (!localCreds.mapsUrl) {
568
629
  localCreds.mapsUrl = (0, _config.buildMapsUrlFromBase)(localCreds.apiBaseUrl);
569
630
  }
570
631
 
571
632
  if (autoRefresh || onNewData) {
572
- _core.log.assert(onNewData, 'Must define `onNewData` when using autoRefresh');
573
-
574
- _core.log.assert(typeof onNewData === 'function', '`onNewData` must be a function');
575
-
576
- _core.log.assert(autoRefresh > 0, '`autoRefresh` must be a positive number');
633
+ (0, _utils.assert)(onNewData, 'Must define `onNewData` when using autoRefresh');
634
+ (0, _utils.assert)(typeof onNewData === 'function', '`onNewData` must be a function');
635
+ (0, _utils.assert)(typeof autoRefresh === 'number' && autoRefresh > 0, '`autoRefresh` must be a positive number');
577
636
  }
578
637
 
579
638
  url = "".concat(localCreds.mapsUrl, "/public/").concat(cartoMapId);
580
- _context9.next = 11;
581
- return request({
582
- url: url
639
+ _context11.next = 12;
640
+ return requestJson({
641
+ url: url,
642
+ accessToken: accessToken
583
643
  });
584
644
 
585
- case 11:
586
- map = _context9.sent;
645
+ case 12:
646
+ map = _context11.sent;
587
647
 
588
648
  if (autoRefresh) {
589
- intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8() {
649
+ intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee10() {
590
650
  var changed;
591
- return _regenerator.default.wrap(function _callee8$(_context8) {
651
+ return _regenerator.default.wrap(function _callee10$(_context10) {
592
652
  while (1) {
593
- switch (_context8.prev = _context8.next) {
653
+ switch (_context10.prev = _context10.next) {
594
654
  case 0:
595
- _context8.next = 2;
596
- return fillInMapDatasets(map, clientId, credentials);
655
+ _context10.next = 2;
656
+ return fillInMapDatasets(map, clientId, localCreds);
597
657
 
598
658
  case 2:
599
- changed = _context8.sent;
659
+ changed = _context10.sent;
600
660
 
601
- if (changed.some(function (v) {
661
+ if (onNewData && changed.some(function (v) {
602
662
  return v === true;
603
663
  })) {
604
664
  onNewData((0, _parseMap.parseMap)(map));
@@ -606,10 +666,10 @@ function _fetchMap() {
606
666
 
607
667
  case 4:
608
668
  case "end":
609
- return _context8.stop();
669
+ return _context10.stop();
610
670
  }
611
671
  }
612
- }, _callee8);
672
+ }, _callee10);
613
673
  })), autoRefresh * 1000);
614
674
 
615
675
  stopAutoRefresh = function stopAutoRefresh() {
@@ -617,20 +677,20 @@ function _fetchMap() {
617
677
  };
618
678
  }
619
679
 
620
- _context9.next = 15;
621
- return fillInMapDatasets(map, clientId, credentials);
680
+ _context11.next = 16;
681
+ return fillInMapDatasets(map, clientId, localCreds);
622
682
 
623
- case 15:
624
- return _context9.abrupt("return", _objectSpread(_objectSpread({}, (0, _parseMap.parseMap)(map)), {
683
+ case 16:
684
+ return _context11.abrupt("return", _objectSpread(_objectSpread({}, (0, _parseMap.parseMap)(map)), {
625
685
  stopAutoRefresh: stopAutoRefresh
626
686
  }));
627
687
 
628
- case 16:
688
+ case 17:
629
689
  case "end":
630
- return _context9.stop();
690
+ return _context11.stop();
631
691
  }
632
692
  }
633
- }, _callee9);
693
+ }, _callee11);
634
694
  }));
635
695
  return _fetchMap.apply(this, arguments);
636
696
  }