@carto/api-client 0.4.0-alpha.4 → 0.4.0-alpha.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.
@@ -59,6 +59,8 @@ var ApiVersion;
59
59
  ApiVersion["V2"] = "v2";
60
60
  ApiVersion["V3"] = "v3";
61
61
  })(ApiVersion || (ApiVersion = {}));
62
+ /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
63
+ const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
62
64
 
63
65
  const FILTER_TYPES = new Set(Object.values(FilterType));
64
66
  const isFilterType = type => FILTER_TYPES.has(type);
@@ -365,8 +367,10 @@ function _objectWithoutPropertiesLoose(r, e) {
365
367
  return t;
366
368
  }
367
369
 
368
- /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
369
- const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
370
+ /**
371
+ * Current version of @carto/api-client.
372
+ * @internal
373
+ */
370
374
  /** @internal */
371
375
  const V3_MINOR_VERSION = '3.4';
372
376
  /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
@@ -452,7 +456,7 @@ async function makeCall({
452
456
  }
453
457
 
454
458
  /** @internalRemarks Source: @carto/react-api */
455
- const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'timeseries', 'range', 'scatterplot', 'table'];
459
+ const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'pick', 'timeseries', 'range', 'scatterplot', 'table'];
456
460
  const {
457
461
  V3
458
462
  } = ApiVersion;
@@ -486,9 +490,10 @@ function executeModel(props) {
486
490
  assert(type !== 'tileset', 'executeModel: Tilesets not supported');
487
491
  let url = `${apiBaseUrl}/v3/sql/${connectionName}/model/${model}`;
488
492
  const {
493
+ data,
489
494
  filters,
490
495
  filtersLogicalOperator = 'and',
491
- data
496
+ geoColumn = DEFAULT_GEO_COLUMN
492
497
  } = source;
493
498
  const queryParameters = source.queryParameters ? JSON.stringify(source.queryParameters) : '';
494
499
  const queryParams = {
@@ -500,9 +505,13 @@ function executeModel(props) {
500
505
  filters: JSON.stringify(filters),
501
506
  filtersLogicalOperator
502
507
  };
508
+ // Picking Model API requires 'spatialDataColumn'.
509
+ if (model === 'pick') {
510
+ queryParams.spatialDataColumn = geoColumn;
511
+ }
503
512
  // API supports multiple filters, we apply it only to geoColumn
504
513
  const spatialFilters = source.spatialFilter ? {
505
- [source.geoColumn ? source.geoColumn : DEFAULT_GEO_COLUMN]: source.spatialFilter
514
+ [geoColumn]: source.spatialFilter
506
515
  } : undefined;
507
516
  if (spatialFilters) {
508
517
  queryParams.spatialFilters = JSON.stringify(spatialFilters);
@@ -532,12 +541,13 @@ function executeModel(props) {
532
541
  }
533
542
 
534
543
  const _excluded$1 = ["filterOwner", "spatialFilter", "abortController"],
535
- _excluded2 = ["filterOwner", "spatialFilter", "abortController", "operationExp"],
536
- _excluded3 = ["filterOwner", "spatialFilter", "abortController"],
544
+ _excluded2 = ["filterOwner", "spatialFilter", "abortController"],
545
+ _excluded3 = ["filterOwner", "spatialFilter", "abortController", "operationExp"],
537
546
  _excluded4 = ["filterOwner", "spatialFilter", "abortController"],
538
547
  _excluded5 = ["filterOwner", "spatialFilter", "abortController"],
539
548
  _excluded6 = ["filterOwner", "spatialFilter", "abortController"],
540
- _excluded7 = ["filterOwner", "abortController", "spatialFilter"];
549
+ _excluded7 = ["filterOwner", "spatialFilter", "abortController"],
550
+ _excluded8 = ["filterOwner", "abortController", "spatialFilter"];
541
551
  /**
542
552
  * Source for Widget API requests on a data source defined by a SQL query.
543
553
  *
@@ -595,6 +605,52 @@ class WidgetBaseSource {
595
605
  }
596
606
  }).then(res => normalizeObjectKeys(res.rows));
597
607
  }
608
+ /****************************************************************************
609
+ * FEATURES
610
+ */
611
+ /**
612
+ * Given a list of feature IDs (as found in `_carto_feature_id`) returns all
613
+ * matching features. In datasets containing features with duplicate geometries,
614
+ * feature IDs may be duplicated (IDs are a hash of geometry) and so more
615
+ * results may be returned than IDs in the request.
616
+ * @internal
617
+ * @experimental
618
+ */
619
+ async getFeatures(options) {
620
+ const {
621
+ filterOwner,
622
+ spatialFilter,
623
+ abortController
624
+ } = options,
625
+ params = _objectWithoutPropertiesLoose(options, _excluded2);
626
+ const {
627
+ columns,
628
+ dataType,
629
+ featureIds,
630
+ z,
631
+ limit,
632
+ tileResolution
633
+ } = params;
634
+ return executeModel({
635
+ model: 'pick',
636
+ source: _extends({}, this.getModelSource(filterOwner), {
637
+ spatialFilter
638
+ }),
639
+ params: {
640
+ columns,
641
+ dataType,
642
+ featureIds,
643
+ z,
644
+ limit: limit || 1000,
645
+ tileResolution: tileResolution || DEFAULT_TILE_RESOLUTION
646
+ },
647
+ opts: {
648
+ abortController
649
+ }
650
+ }).then(res => ({
651
+ rows: normalizeObjectKeys(res.rows)
652
+ }));
653
+ }
598
654
  /****************************************************************************
599
655
  * FORMULA
600
656
  */
@@ -609,7 +665,7 @@ class WidgetBaseSource {
609
665
  abortController,
610
666
  operationExp
611
667
  } = options,
612
- params = _objectWithoutPropertiesLoose(options, _excluded2);
668
+ params = _objectWithoutPropertiesLoose(options, _excluded3);
613
669
  const {
614
670
  column,
615
671
  operation
@@ -642,7 +698,7 @@ class WidgetBaseSource {
642
698
  spatialFilter,
643
699
  abortController
644
700
  } = options,
645
- params = _objectWithoutPropertiesLoose(options, _excluded3);
701
+ params = _objectWithoutPropertiesLoose(options, _excluded4);
646
702
  const {
647
703
  column,
648
704
  operation,
@@ -688,7 +744,7 @@ class WidgetBaseSource {
688
744
  spatialFilter,
689
745
  abortController
690
746
  } = options,
691
- params = _objectWithoutPropertiesLoose(options, _excluded4);
747
+ params = _objectWithoutPropertiesLoose(options, _excluded5);
692
748
  const {
693
749
  column
694
750
  } = params;
@@ -718,7 +774,7 @@ class WidgetBaseSource {
718
774
  spatialFilter,
719
775
  abortController
720
776
  } = options,
721
- params = _objectWithoutPropertiesLoose(options, _excluded5);
777
+ params = _objectWithoutPropertiesLoose(options, _excluded6);
722
778
  const {
723
779
  xAxisColumn,
724
780
  xAxisJoinOperation,
@@ -760,7 +816,7 @@ class WidgetBaseSource {
760
816
  spatialFilter,
761
817
  abortController
762
818
  } = options,
763
- params = _objectWithoutPropertiesLoose(options, _excluded6);
819
+ params = _objectWithoutPropertiesLoose(options, _excluded7);
764
820
  const {
765
821
  columns,
766
822
  sortBy,
@@ -805,7 +861,7 @@ class WidgetBaseSource {
805
861
  abortController,
806
862
  spatialFilter
807
863
  } = options,
808
- params = _objectWithoutPropertiesLoose(options, _excluded7);
864
+ params = _objectWithoutPropertiesLoose(options, _excluded8);
809
865
  const {
810
866
  column,
811
867
  operationColumn,
@@ -1480,5 +1536,5 @@ const query = async function query(options) {
1480
1536
  });
1481
1537
  };
1482
1538
 
1483
- export { ApiVersion, CartoAPIError, FilterType, SOURCE_DEFAULTS, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, addFilter, boundaryQuerySource, boundaryTableSource, buildPublicMapUrl, buildStatsUrl, clearFilters, createPolygonSpatialFilter, createViewportSpatialFilter, getClient, getFilter, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, setClient, vectorQuerySource, vectorTableSource, vectorTilesetSource };
1539
+ export { ApiVersion, CartoAPIError, DEFAULT_API_BASE_URL, FilterType, SOURCE_DEFAULTS, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, addFilter, boundaryQuerySource, boundaryTableSource, buildPublicMapUrl, buildStatsUrl, clearFilters, createPolygonSpatialFilter, createViewportSpatialFilter, getClient, getFilter, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, setClient, vectorQuerySource, vectorTableSource, vectorTilesetSource };
1484
1540
  //# sourceMappingURL=api-client.modern.js.map