@carto/api-client 0.0.1-1 → 0.0.1-2

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.
@@ -1,19 +1,32 @@
1
- const CLIENT_ID = 'carto-api-client';
2
- /** @internalRemarks Source: @carto/constants */
3
- var MapType;
4
- (function (MapType) {
5
- MapType["TABLE"] = "table";
6
- MapType["QUERY"] = "query";
7
- MapType["TILESET"] = "tileset";
8
- })(MapType || (MapType = {}));
9
- /** @internalRemarks Source: @carto/constants */
10
- var ApiVersion;
11
- (function (ApiVersion) {
12
- ApiVersion["V1"] = "v1";
13
- ApiVersion["V2"] = "v2";
14
- ApiVersion["V3"] = "v3";
15
- })(ApiVersion || (ApiVersion = {}));
16
- /** @internalRemarks Source: @carto/react-core */
1
+ /**
2
+ * @internal
3
+ * @internalRemarks Source: @carto/react-core
4
+ */
5
+ let client = 'carto-api-client';
6
+ /**
7
+ * Returns current client ID, used to categorize API requests. For internal use only.
8
+ *
9
+ * @internal
10
+ * @internalRemarks Source: @carto/react-core
11
+ */
12
+ function getClient() {
13
+ return client;
14
+ }
15
+ /**
16
+ * Sets current client ID, used to categorize API requests. For internal use only.
17
+ *
18
+ * @internal
19
+ * @internalRemarks Source: @carto/react-core
20
+ */
21
+ function setClient(c) {
22
+ client = c;
23
+ }
24
+
25
+ /**
26
+ * Defines a step size increment for use with {@link TimeSeriesRequestOptions}.
27
+ *
28
+ * @internalRemarks Source: @carto/react-core
29
+ */
17
30
  var GroupDateType;
18
31
  (function (GroupDateType) {
19
32
  GroupDateType["YEARS"] = "year";
@@ -24,7 +37,20 @@ var GroupDateType;
24
37
  GroupDateType["MINUTES"] = "minute";
25
38
  GroupDateType["SECONDS"] = "second";
26
39
  })(GroupDateType || (GroupDateType = {}));
27
- /** @internalRemarks Source: @carto/react-api, @deck.gl/carto */
40
+ /**
41
+ * Defines a comparator used when matching a column's values against given filter values.
42
+ *
43
+ * Example:
44
+ *
45
+ * ```javascript
46
+ * import { FilterType } from '@carto/api-client';
47
+ * const filters = {
48
+ * column_name: { [FilterType.IN]: { values: ['a', 'b', 'c'] } }
49
+ * };
50
+ * ```
51
+ *
52
+ * @internalRemarks Source: @carto/react-api, @deck.gl/carto
53
+ */
28
54
  var FilterType;
29
55
  (function (FilterType) {
30
56
  FilterType["IN"] = "in";
@@ -36,20 +62,6 @@ var FilterType;
36
62
  FilterType["STRING_SEARCH"] = "stringSearch";
37
63
  })(FilterType || (FilterType = {}));
38
64
 
39
- /**
40
- * Default client
41
- * @internalRemarks Source: @carto/react-core
42
- */
43
- let client = CLIENT_ID;
44
- /** @internalRemarks Source: @carto/react-core */
45
- function getClient() {
46
- return client;
47
- }
48
- /** @internalRemarks Source: @carto/react-core */
49
- function setClient(c) {
50
- client = c;
51
- }
52
-
53
65
  function _extends() {
54
66
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
55
67
  for (var e = 1; e < arguments.length; e++) {
@@ -69,12 +81,9 @@ function _objectWithoutPropertiesLoose(r, e) {
69
81
  return t;
70
82
  }
71
83
 
72
- /**
73
- * Threshold to use GET requests, vs POST
74
- * @internalRemarks Source: @carto/constants
75
- * @internal
84
+ /******************************************************************************
85
+ * DEFAULTS
76
86
  */
77
- const REQUEST_GET_MAX_URL_LENGTH = 2048;
78
87
  /**
79
88
  * @internalRemarks Source: @carto/constants
80
89
  * @internal
@@ -85,6 +94,29 @@ const DEFAULT_API_BASE_URL$1 = 'https://gcp-us-east1.api.carto.com';
85
94
  * @internal
86
95
  */
87
96
  const DEFAULT_GEO_COLUMN = 'geom';
97
+ /******************************************************************************
98
+ * ENUMS
99
+ */
100
+ /**
101
+ * @internal
102
+ * @internalRemarks Source: @carto/constants
103
+ */
104
+ var MapType;
105
+ (function (MapType) {
106
+ MapType["TABLE"] = "table";
107
+ MapType["QUERY"] = "query";
108
+ MapType["TILESET"] = "tileset";
109
+ })(MapType || (MapType = {}));
110
+ /**
111
+ * @internal
112
+ * @internalRemarks Source: @carto/constants
113
+ */
114
+ var ApiVersion;
115
+ (function (ApiVersion) {
116
+ ApiVersion["V1"] = "v1";
117
+ ApiVersion["V2"] = "v2";
118
+ ApiVersion["V3"] = "v3";
119
+ })(ApiVersion || (ApiVersion = {}));
88
120
 
89
121
  const FILTER_TYPES = new Set(Object.values(FilterType));
90
122
  const isFilterType = type => FILTER_TYPES.has(type);
@@ -173,15 +205,9 @@ function dealWithApiError({
173
205
  }
174
206
  }
175
207
  /** @internalRemarks Source: @carto/react-api */
176
- function checkCredentials(credentials) {
177
- if (!credentials || !credentials.apiBaseUrl || !credentials.accessToken) {
178
- throw new Error('Missing or bad credentials provided');
179
- }
180
- }
181
- /** @internalRemarks Source: @carto/react-api */
182
208
  async function makeCall({
183
209
  url,
184
- credentials,
210
+ accessToken,
185
211
  opts
186
212
  }) {
187
213
  let response;
@@ -191,14 +217,14 @@ async function makeCall({
191
217
  var _opts$abortController;
192
218
  response = await fetch(url.toString(), _extends({
193
219
  headers: _extends({
194
- Authorization: `Bearer ${credentials.accessToken}`
195
- }, isPost ? {
220
+ Authorization: `Bearer ${accessToken}`
221
+ }, isPost && {
196
222
  'Content-Type': 'application/json'
197
- } : {})
198
- }, isPost ? {
223
+ })
224
+ }, isPost && {
199
225
  method: opts == null ? void 0 : opts.method,
200
226
  body: opts == null ? void 0 : opts.body
201
- } : {}, {
227
+ }, {
202
228
  signal: opts == null || (_opts$abortController = opts.abortController) == null ? void 0 : _opts$abortController.signal
203
229
  }, opts == null ? void 0 : opts.otherOptions));
204
230
  data = await response.json();
@@ -217,6 +243,10 @@ async function makeCall({
217
243
 
218
244
  /** @internalRemarks Source: @carto/react-api */
219
245
  const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'timeseries', 'range', 'scatterplot', 'table'];
246
+ const {
247
+ V3
248
+ } = ApiVersion;
249
+ const REQUEST_GET_MAX_URL_LENGTH = 2048;
220
250
  /**
221
251
  * Execute a SQL model request.
222
252
  * @internalRemarks Source: @carto/react-api
@@ -225,23 +255,29 @@ function executeModel(props) {
225
255
  assert(props.source, 'executeModel: missing source');
226
256
  assert(props.model, 'executeModel: missing model');
227
257
  assert(props.params, 'executeModel: missing params');
228
- assert(AVAILABLE_MODELS.indexOf(props.model) !== -1, `executeModel: model provided isn't valid. Available models: ${AVAILABLE_MODELS.join(', ')}`);
258
+ assert(AVAILABLE_MODELS.includes(props.model), `executeModel: model provided isn't valid. Available models: ${AVAILABLE_MODELS.join(', ')}`);
229
259
  const {
230
- source,
231
260
  model,
261
+ source,
232
262
  params,
233
- spatialFilter,
234
263
  opts
235
264
  } = props;
236
- checkCredentials(source.credentials);
237
- assert(source.credentials.apiVersion === ApiVersion.V3, 'SQL Model API is a feature only available in CARTO 3.');
238
- assert(source.type !== MapType.TILESET, 'executeModel: Tileset not supported');
239
- let url = `${source.credentials.apiBaseUrl}/v3/sql/${source.connection}/model/${model}`;
265
+ const {
266
+ type,
267
+ apiVersion,
268
+ apiBaseUrl,
269
+ accessToken,
270
+ connectionName
271
+ } = source;
272
+ assert(apiBaseUrl, 'executeModel: missing apiBaseUrl');
273
+ assert(accessToken, 'executeModel: missing accessToken');
274
+ assert(apiVersion === V3, 'executeModel: SQL Model API requires CARTO 3+');
275
+ assert(type !== MapType.TILESET, 'executeModel: Tilesets not supported');
276
+ let url = `${apiBaseUrl}/v3/sql/${connectionName}/model/${model}`;
240
277
  const {
241
278
  filters,
242
279
  filtersLogicalOperator = 'and',
243
- data,
244
- type
280
+ data
245
281
  } = source;
246
282
  const queryParameters = source.queryParameters ? JSON.stringify(source.queryParameters) : '';
247
283
  const queryParams = {
@@ -254,8 +290,8 @@ function executeModel(props) {
254
290
  filtersLogicalOperator
255
291
  };
256
292
  // API supports multiple filters, we apply it only to geoColumn
257
- const spatialFilters = spatialFilter ? {
258
- [source.geoColumn ? source.geoColumn : DEFAULT_GEO_COLUMN]: spatialFilter
293
+ const spatialFilters = source.spatialFilter ? {
294
+ [source.geoColumn ? source.geoColumn : DEFAULT_GEO_COLUMN]: source.spatialFilter
259
295
  } : undefined;
260
296
  if (spatialFilters) {
261
297
  queryParams.spatialFilters = JSON.stringify(spatialFilters);
@@ -275,7 +311,7 @@ function executeModel(props) {
275
311
  }
276
312
  return makeCall({
277
313
  url,
278
- credentials: source.credentials,
314
+ accessToken: source.accessToken,
279
315
  opts: _extends({}, opts, {
280
316
  method: isGet ? 'GET' : 'POST'
281
317
  }, !isGet && {
@@ -284,88 +320,112 @@ function executeModel(props) {
284
320
  });
285
321
  }
286
322
 
287
- const _excluded = ["filterOwner", "spatialFilter", "abortController", "operationExp"],
288
- _excluded2 = ["filterOwner", "spatialFilter", "abortController"],
323
+ const _excluded = ["filterOwner", "spatialFilter", "abortController"],
324
+ _excluded2 = ["filterOwner", "spatialFilter", "abortController", "operationExp"],
289
325
  _excluded3 = ["filterOwner", "spatialFilter", "abortController"],
290
326
  _excluded4 = ["filterOwner", "spatialFilter", "abortController"],
291
327
  _excluded5 = ["filterOwner", "spatialFilter", "abortController"],
292
- _excluded6 = ["filterOwner", "abortController", "spatialFilter"],
293
- _excluded7 = ["filterOwner", "spatialFilter", "abortController"];
328
+ _excluded6 = ["filterOwner", "spatialFilter", "abortController"],
329
+ _excluded7 = ["filterOwner", "abortController", "spatialFilter"];
330
+ /**
331
+ * Source for Widget API requests on a data source defined by a SQL query.
332
+ *
333
+ * Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
334
+ */
294
335
  class WidgetBaseSource {
295
336
  constructor(props) {
296
337
  this.props = void 0;
297
- this.credentials = void 0;
298
- this.connectionName = void 0;
299
338
  this.props = _extends({}, WidgetBaseSource.defaultProps, props);
300
- this.connectionName = props.connectionName;
301
- this.credentials = {
302
- apiVersion: props.apiVersion || ApiVersion.V3,
303
- apiBaseUrl: props.apiBaseUrl || DEFAULT_API_BASE_URL$1,
304
- clientId: props.clientId || getClient(),
339
+ }
340
+ _getModelSource(owner) {
341
+ const props = this.props;
342
+ return {
343
+ apiVersion: props.apiVersion,
344
+ apiBaseUrl: props.apiBaseUrl,
345
+ clientId: props.clientId,
305
346
  accessToken: props.accessToken,
306
- geoColumn: props.geoColumn || DEFAULT_GEO_COLUMN
347
+ connectionName: props.connectionName,
348
+ filters: getApplicableFilters(owner, props.filters),
349
+ filtersLogicalOperator: props.filtersLogicalOperator,
350
+ geoColumn: props.geoColumn
307
351
  };
308
352
  }
309
- getSource(owner) {
310
- return _extends({}, this.props, {
311
- credentials: this.credentials,
312
- connection: this.connectionName,
313
- filters: getApplicableFilters(owner, this.props.filters)
314
- });
315
- }
316
- async getFormula(props) {
353
+ /****************************************************************************
354
+ * CATEGORIES
355
+ */
356
+ /**
357
+ * Returns a list of labeled datapoints for categorical data. Suitable for
358
+ * charts including grouped bar charts, pie charts, and tree charts.
359
+ */
360
+ async getCategories(props) {
317
361
  const {
318
362
  filterOwner,
319
363
  spatialFilter,
320
- abortController,
321
- operationExp
364
+ abortController
322
365
  } = props,
323
366
  params = _objectWithoutPropertiesLoose(props, _excluded);
324
367
  const {
325
368
  column,
326
- operation
369
+ operation,
370
+ operationColumn
327
371
  } = params;
328
372
  return executeModel({
329
- model: 'formula',
330
- source: this.getSource(filterOwner),
331
- spatialFilter,
373
+ model: 'category',
374
+ source: _extends({}, this.getModelSource(filterOwner), {
375
+ spatialFilter
376
+ }),
332
377
  params: {
333
- column: column != null ? column : '*',
378
+ column,
334
379
  operation,
335
- operationExp
380
+ operationColumn: operationColumn || column
336
381
  },
337
382
  opts: {
338
383
  abortController
339
384
  }
340
- }).then(res => normalizeObjectKeys(res.rows[0]));
385
+ }).then(res => normalizeObjectKeys(res.rows));
341
386
  }
342
- async getCategories(props) {
387
+ /****************************************************************************
388
+ * FORMULA
389
+ */
390
+ /**
391
+ * Returns a scalar numerical statistic over all matching data. Suitable
392
+ * for 'headline' or 'scorecard' figures such as counts and sums.
393
+ */
394
+ async getFormula(props) {
343
395
  const {
344
396
  filterOwner,
345
397
  spatialFilter,
346
- abortController
398
+ abortController,
399
+ operationExp
347
400
  } = props,
348
401
  params = _objectWithoutPropertiesLoose(props, _excluded2);
349
402
  const {
350
403
  column,
351
- operation,
352
- operationColumn
404
+ operation
353
405
  } = params;
354
406
  return executeModel({
355
- model: 'category',
356
- source: this.getSource(filterOwner),
357
- spatialFilter,
407
+ model: 'formula',
408
+ source: _extends({}, this.getModelSource(filterOwner), {
409
+ spatialFilter
410
+ }),
358
411
  params: {
359
- column,
412
+ column: column != null ? column : '*',
360
413
  operation,
361
- operationColumn: operationColumn || column
414
+ operationExp
362
415
  },
363
416
  opts: {
364
417
  abortController
365
418
  }
366
- }).then(res => normalizeObjectKeys(res.rows));
419
+ }).then(res => normalizeObjectKeys(res.rows[0]));
367
420
  }
368
- async getRange(props) {
421
+ /****************************************************************************
422
+ * HISTOGRAM
423
+ */
424
+ /**
425
+ * Returns a list of labeled datapoints for 'bins' of data defined as ticks
426
+ * over a numerical range. Suitable for histogram charts.
427
+ */
428
+ async getHistogram(props) {
369
429
  const {
370
430
  filterOwner,
371
431
  spatialFilter,
@@ -373,21 +433,45 @@ class WidgetBaseSource {
373
433
  } = props,
374
434
  params = _objectWithoutPropertiesLoose(props, _excluded3);
375
435
  const {
376
- column
436
+ column,
437
+ operation,
438
+ ticks
377
439
  } = params;
378
- return executeModel({
379
- model: 'range',
380
- source: this.getSource(filterOwner),
381
- spatialFilter,
440
+ const data = await executeModel({
441
+ model: 'histogram',
442
+ source: _extends({}, this.getModelSource(filterOwner), {
443
+ spatialFilter
444
+ }),
382
445
  params: {
383
- column
446
+ column,
447
+ operation,
448
+ ticks
384
449
  },
385
450
  opts: {
386
451
  abortController
387
452
  }
388
- }).then(res => normalizeObjectKeys(res.rows[0]));
453
+ }).then(res => normalizeObjectKeys(res.rows));
454
+ if (data.length) {
455
+ // Given N ticks the API returns up to N+1 bins, omitting any empty bins. Bins
456
+ // include 1 bin below the lowest tick, N-1 between ticks, and 1 bin above the highest tick.
457
+ const result = Array(ticks.length + 1).fill(0);
458
+ data.forEach(({
459
+ tick,
460
+ value
461
+ }) => result[tick] = value);
462
+ return result;
463
+ }
464
+ return [];
389
465
  }
390
- async getTable(props) {
466
+ /****************************************************************************
467
+ * RANGE
468
+ */
469
+ /**
470
+ * Returns a range (min and max) for a numerical column of matching rows.
471
+ * Suitable for displaying certain 'headline' or 'scorecard' statistics,
472
+ * or rendering a range slider UI for filtering.
473
+ */
474
+ async getRange(props) {
391
475
  const {
392
476
  filterOwner,
393
477
  spatialFilter,
@@ -395,31 +479,28 @@ class WidgetBaseSource {
395
479
  } = props,
396
480
  params = _objectWithoutPropertiesLoose(props, _excluded4);
397
481
  const {
398
- columns,
399
- sortBy,
400
- sortDirection,
401
- page = 0,
402
- rowsPerPage = 10
482
+ column
403
483
  } = params;
404
484
  return executeModel({
405
- model: 'table',
406
- source: this.getSource(filterOwner),
407
- spatialFilter,
485
+ model: 'range',
486
+ source: _extends({}, this.getModelSource(filterOwner), {
487
+ spatialFilter
488
+ }),
408
489
  params: {
409
- column: columns,
410
- sortBy,
411
- sortDirection,
412
- limit: rowsPerPage,
413
- offset: page * rowsPerPage
490
+ column
414
491
  },
415
492
  opts: {
416
493
  abortController
417
494
  }
418
- }).then(res => ({
419
- rows: normalizeObjectKeys(res.rows),
420
- totalCount: res.metadata.total
421
- }));
495
+ }).then(res => normalizeObjectKeys(res.rows[0]));
422
496
  }
497
+ /****************************************************************************
498
+ * SCATTER
499
+ */
500
+ /**
501
+ * Returns a list of bivariate datapoints defined as numerical 'x' and 'y'
502
+ * values. Suitable for rendering scatter plots.
503
+ */
423
504
  async getScatter(props) {
424
505
  const {
425
506
  filterOwner,
@@ -437,8 +518,9 @@ class WidgetBaseSource {
437
518
  const HARD_LIMIT = 500;
438
519
  return executeModel({
439
520
  model: 'scatterplot',
440
- source: this.getSource(filterOwner),
441
- spatialFilter,
521
+ source: _extends({}, this.getModelSource(filterOwner), {
522
+ spatialFilter
523
+ }),
442
524
  params: {
443
525
  xAxisColumn,
444
526
  xAxisJoinOperation,
@@ -454,13 +536,61 @@ class WidgetBaseSource {
454
536
  y
455
537
  }) => [x, y]));
456
538
  }
539
+ /****************************************************************************
540
+ * TABLE
541
+ */
542
+ /**
543
+ * Returns a list of arbitrary data rows, with support for pagination and
544
+ * sorting. Suitable for displaying tables and lists.
545
+ */
546
+ async getTable(props) {
547
+ const {
548
+ filterOwner,
549
+ spatialFilter,
550
+ abortController
551
+ } = props,
552
+ params = _objectWithoutPropertiesLoose(props, _excluded6);
553
+ const {
554
+ columns,
555
+ sortBy,
556
+ sortDirection,
557
+ page = 0,
558
+ rowsPerPage = 10
559
+ } = params;
560
+ return executeModel({
561
+ model: 'table',
562
+ source: _extends({}, this.getModelSource(filterOwner), {
563
+ spatialFilter
564
+ }),
565
+ params: {
566
+ column: columns,
567
+ sortBy,
568
+ sortDirection,
569
+ limit: rowsPerPage,
570
+ offset: page * rowsPerPage
571
+ },
572
+ opts: {
573
+ abortController
574
+ }
575
+ }).then(res => ({
576
+ rows: normalizeObjectKeys(res.rows),
577
+ totalCount: res.metadata.total
578
+ }));
579
+ }
580
+ /****************************************************************************
581
+ * TIME SERIES
582
+ */
583
+ /**
584
+ * Returns a series of labeled numerical values, grouped into equally-sized
585
+ * time intervals. Suitable for rendering time series charts.
586
+ */
457
587
  async getTimeSeries(props) {
458
588
  const {
459
589
  filterOwner,
460
590
  abortController,
461
591
  spatialFilter
462
592
  } = props,
463
- params = _objectWithoutPropertiesLoose(props, _excluded6);
593
+ params = _objectWithoutPropertiesLoose(props, _excluded7);
464
594
  const {
465
595
  column,
466
596
  operationColumn,
@@ -474,8 +604,9 @@ class WidgetBaseSource {
474
604
  } = params;
475
605
  return executeModel({
476
606
  model: 'timeseries',
477
- source: this.getSource(filterOwner),
478
- spatialFilter,
607
+ source: _extends({}, this.getModelSource(filterOwner), {
608
+ spatialFilter
609
+ }),
479
610
  params: {
480
611
  column,
481
612
  stepSize,
@@ -498,61 +629,73 @@ class WidgetBaseSource {
498
629
  };
499
630
  });
500
631
  }
501
- async getHistogram(props) {
502
- const {
503
- filterOwner,
504
- spatialFilter,
505
- abortController
506
- } = props,
507
- params = _objectWithoutPropertiesLoose(props, _excluded7);
508
- const {
509
- column,
510
- operation,
511
- ticks
512
- } = params;
513
- const data = await executeModel({
514
- model: 'histogram',
515
- source: this.getSource(filterOwner),
516
- spatialFilter,
517
- params: {
518
- column,
519
- operation,
520
- ticks
521
- },
522
- opts: {
523
- abortController
524
- }
525
- }).then(res => normalizeObjectKeys(res.rows));
526
- if (data.length) {
527
- // Given N ticks the API returns up to N+1 bins, omitting any empty bins. Bins
528
- // include 1 bin below the lowest tick, N-1 between ticks, and 1 bin above the highest tick.
529
- const result = Array(ticks.length + 1).fill(0);
530
- data.forEach(({
531
- tick,
532
- value
533
- }) => result[tick] = value);
534
- return result;
535
- }
536
- return [];
537
- }
538
632
  }
539
633
  WidgetBaseSource.defaultProps = {
634
+ apiVersion: ApiVersion.V3,
635
+ apiBaseUrl: DEFAULT_API_BASE_URL$1,
636
+ clientId: getClient(),
540
637
  filters: {},
541
- filtersLogicalOperator: 'and'
638
+ filtersLogicalOperator: 'and',
639
+ geoColumn: DEFAULT_GEO_COLUMN
542
640
  };
543
641
 
642
+ /**
643
+ * Source for Widget API requests on a data source defined by a SQL query.
644
+ *
645
+ * Generally not intended to be constructed directly. Instead, call
646
+ * {@link vectorQuerySource}, {@link h3QuerySource}, or {@link quadbinQuerySource},
647
+ * which can be shared with map layers. Sources contain a `widgetSource` property,
648
+ * for use by widget implementations.
649
+ *
650
+ * Example:
651
+ *
652
+ * ```javascript
653
+ * import { vectorQuerySource } from '@carto/api-client';
654
+ *
655
+ * const data = vectorQuerySource({
656
+ * accessToken: '••••',
657
+ * connectionName: 'carto_dw',
658
+ * sqlQuery: 'SELECT * FROM carto-demo-data.demo_tables.retail_stores'
659
+ * });
660
+ *
661
+ * const { widgetSource } = await data;
662
+ * ```
663
+ */
544
664
  class WidgetQuerySource extends WidgetBaseSource {
545
- getSource(owner) {
546
- return _extends({}, super.getSource(owner), {
665
+ getModelSource(owner) {
666
+ return _extends({}, super._getModelSource(owner), {
547
667
  type: MapType.QUERY,
548
- data: this.props.sqlQuery
668
+ data: this.props.sqlQuery,
669
+ queryParameters: this.props.queryParameters
549
670
  });
550
671
  }
551
672
  }
552
673
 
674
+ /**
675
+ * Source for Widget API requests on a data source defined as a table.
676
+ *
677
+ * Generally not intended to be constructed directly. Instead, call
678
+ * {@link vectorTableSource}, {@link h3TableSource}, or {@link quadbinTableSource},
679
+ * which can be shared with map layers. Sources contain a `widgetSource` property,
680
+ * for use by widget implementations.
681
+ *
682
+ * Example:
683
+ *
684
+ * ```javascript
685
+ * import { vectorTableSource } from '@carto/api-client';
686
+ *
687
+ * const data = vectorTableSource({
688
+ * accessToken: '••••',
689
+ * connectionName: 'carto_dw',
690
+ * tableName: 'carto-demo-data.demo_tables.retail_stores'
691
+ * });
692
+ *
693
+ * const { widgetSource } = await data;
694
+ * ```
695
+ */
553
696
  class WidgetTableSource extends WidgetBaseSource {
554
- getSource(owner) {
555
- return _extends({}, super.getSource(owner), {
697
+ getModelSource(owner) {
698
+ return _extends({}, super._getModelSource(owner), {
556
699
  type: MapType.TABLE,
557
700
  data: this.props.tableName
558
701
  });
@@ -617,7 +760,7 @@ const V3_MINOR_VERSION = '3.4';
617
760
  const MAX_GET_LENGTH = 8192;
618
761
  const DEFAULT_PARAMETERS = {
619
762
  v: V3_MINOR_VERSION,
620
- deckglVersion: "0.0.1-1"
763
+ deckglVersion: "0.0.1-2"
621
764
  };
622
765
  const DEFAULT_HEADERS = {
623
766
  Accept: 'application/json',
@@ -1021,69 +1164,60 @@ const vectorTilesetSource$1 = async function (options) {
1021
1164
  vectorTilesetSource: vectorTilesetSource$1
1022
1165
  });
1023
1166
 
1024
- /******************************************************************************
1025
- * VECTOR SOURCES
1026
- */
1027
- /** Wrapper adding widget support to {@link _vectorTableSource}. */
1167
+ /** Wrapper adding Widget API support to [vectorTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
1028
1168
  async function vectorTableSource(props) {
1029
1169
  const response = await vectorTableSource$1(props);
1030
1170
  return _extends({}, response, {
1031
1171
  widgetSource: new WidgetTableSource(props)
1032
1172
  });
1033
1173
  }
1034
- /** Wrapper adding widget support to {@link _vectorQuerySource}. */
1174
+ /** Wrapper adding Widget API support to [vectorQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
1035
1175
  async function vectorQuerySource(props) {
1036
1176
  const response = await vectorQuerySource$1(props);
1037
1177
  return _extends({}, response, {
1038
1178
  widgetSource: new WidgetQuerySource(props)
1039
1179
  });
1040
1180
  }
1041
- /** Wrapper adding widget support to {@link _vectorTilesetSource}. */
1181
+ /** Wrapper adding Widget API support to [vectorTilesetSource](https://deck.gl/docs/api-reference/carto/data-sources). */
1042
1182
  async function vectorTilesetSource() {
1043
1183
  throw new Error('not implemented');
1044
1184
  }
1045
- /******************************************************************************
1046
- * H3 SOURCES
1047
- */
1048
- /** Wrapper adding widget support to {@link _h3TableSource}. */
1185
+ /** Wrapper adding Widget API support to [h3TableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
1049
1186
  async function h3TableSource(props) {
1050
1187
  const response = await h3TableSource$1(props);
1051
1188
  return _extends({}, response, {
1052
1189
  widgetSource: new WidgetTableSource(props)
1053
1190
  });
1054
1191
  }
1055
- /** Wrapper adding widget support to {@link _h3QuerySource}. */
1192
+ /** Wrapper adding Widget API support to [h3QuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
1056
1193
  async function h3QuerySource(props) {
1057
1194
  const response = await h3QuerySource$1(props);
1058
1195
  return _extends({}, response, {
1059
1196
  widgetSource: new WidgetQuerySource(props)
1060
1197
  });
1061
1198
  }
1062
- /** Wrapper adding widget support to {@link _h3TilesetSource}. */
1199
+ /** Wrapper adding Widget API support to [h3TilesetSource](https://deck.gl/docs/api-reference/carto/data-sources). */
1063
1200
  async function h3TilesetSource() {
1064
1201
  throw new Error('not implemented');
1065
1202
  }
1066
- /******************************************************************************
1067
- * QUADBIN SOURCES
1068
- */
1069
- /** Wrapper adding widget support to {@link _quadbinTableSource}. */
1203
+ /** Wrapper adding Widget API support to [quadbinTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
1070
1204
  async function quadbinTableSource(props) {
1071
1205
  const response = await quadbinTableSource$1(props);
1072
1206
  return _extends({}, response, {
1073
1207
  widgetSource: new WidgetTableSource(props)
1074
1208
  });
1075
1209
  }
1076
- /** Wrapper adding widget support to {@link _quadbinQuerySource}. */
1210
+ /** Wrapper adding Widget API support to [quadbinQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
1077
1211
  async function quadbinQuerySource(props) {
1078
1212
  const response = await quadbinQuerySource$1(props);
1079
1213
  return _extends({}, response, {
1080
1214
  widgetSource: new WidgetQuerySource(props)
1081
1215
  });
1082
1216
  }
1083
- /** Wrapper adding widget support to {@link _quadbinTilesetSource}. */
1217
+ /** Wrapper adding Widget API support to [quadbinTilesetSource](https://deck.gl/docs/api-reference/carto/data-sources). */
1084
1218
  async function quadbinTilesetSource() {
1085
1219
  throw new Error('not implemented');
1086
1220
  }
1087
1221
 
1088
- export { ApiVersion, CLIENT_ID, FilterType, GroupDateType, MapType, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, executeModel, getClient, h3QuerySource, h3TableSource, h3TilesetSource, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, setClient, vectorQuerySource, vectorTableSource, vectorTilesetSource };
1222
+ export { FilterType, GroupDateType, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, getClient, h3QuerySource, h3TableSource, h3TilesetSource, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, setClient, vectorQuerySource, vectorTableSource, vectorTilesetSource };
1089
1223
  //# sourceMappingURL=api-client.modern.js.map