@carto/api-client 0.4.0-alpha.5 → 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.
- package/build/api-client.cjs +72 -15
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +64 -12
- package/build/api-client.modern.js.map +1 -1
- package/build/models/model.d.ts +1 -1
- package/build/widget-sources/types.d.ts +46 -0
- package/build/widget-sources/widget-base-source.d.ts +13 -1
- package/package.json +2 -2
- package/src/models/model.ts +14 -5
- package/src/widget-sources/types.ts +51 -0
- package/src/widget-sources/widget-base-source.ts +43 -1
|
@@ -456,7 +456,7 @@ async function makeCall({
|
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
/** @internalRemarks Source: @carto/react-api */
|
|
459
|
-
const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'timeseries', 'range', 'scatterplot', 'table'];
|
|
459
|
+
const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'pick', 'timeseries', 'range', 'scatterplot', 'table'];
|
|
460
460
|
const {
|
|
461
461
|
V3
|
|
462
462
|
} = ApiVersion;
|
|
@@ -490,9 +490,10 @@ function executeModel(props) {
|
|
|
490
490
|
assert(type !== 'tileset', 'executeModel: Tilesets not supported');
|
|
491
491
|
let url = `${apiBaseUrl}/v3/sql/${connectionName}/model/${model}`;
|
|
492
492
|
const {
|
|
493
|
+
data,
|
|
493
494
|
filters,
|
|
494
495
|
filtersLogicalOperator = 'and',
|
|
495
|
-
|
|
496
|
+
geoColumn = DEFAULT_GEO_COLUMN
|
|
496
497
|
} = source;
|
|
497
498
|
const queryParameters = source.queryParameters ? JSON.stringify(source.queryParameters) : '';
|
|
498
499
|
const queryParams = {
|
|
@@ -504,9 +505,13 @@ function executeModel(props) {
|
|
|
504
505
|
filters: JSON.stringify(filters),
|
|
505
506
|
filtersLogicalOperator
|
|
506
507
|
};
|
|
508
|
+
// Picking Model API requires 'spatialDataColumn'.
|
|
509
|
+
if (model === 'pick') {
|
|
510
|
+
queryParams.spatialDataColumn = geoColumn;
|
|
511
|
+
}
|
|
507
512
|
// API supports multiple filters, we apply it only to geoColumn
|
|
508
513
|
const spatialFilters = source.spatialFilter ? {
|
|
509
|
-
[
|
|
514
|
+
[geoColumn]: source.spatialFilter
|
|
510
515
|
} : undefined;
|
|
511
516
|
if (spatialFilters) {
|
|
512
517
|
queryParams.spatialFilters = JSON.stringify(spatialFilters);
|
|
@@ -536,12 +541,13 @@ function executeModel(props) {
|
|
|
536
541
|
}
|
|
537
542
|
|
|
538
543
|
const _excluded$1 = ["filterOwner", "spatialFilter", "abortController"],
|
|
539
|
-
_excluded2 = ["filterOwner", "spatialFilter", "abortController"
|
|
540
|
-
_excluded3 = ["filterOwner", "spatialFilter", "abortController"],
|
|
544
|
+
_excluded2 = ["filterOwner", "spatialFilter", "abortController"],
|
|
545
|
+
_excluded3 = ["filterOwner", "spatialFilter", "abortController", "operationExp"],
|
|
541
546
|
_excluded4 = ["filterOwner", "spatialFilter", "abortController"],
|
|
542
547
|
_excluded5 = ["filterOwner", "spatialFilter", "abortController"],
|
|
543
548
|
_excluded6 = ["filterOwner", "spatialFilter", "abortController"],
|
|
544
|
-
_excluded7 = ["filterOwner", "
|
|
549
|
+
_excluded7 = ["filterOwner", "spatialFilter", "abortController"],
|
|
550
|
+
_excluded8 = ["filterOwner", "abortController", "spatialFilter"];
|
|
545
551
|
/**
|
|
546
552
|
* Source for Widget API requests on a data source defined by a SQL query.
|
|
547
553
|
*
|
|
@@ -599,6 +605,52 @@ class WidgetBaseSource {
|
|
|
599
605
|
}
|
|
600
606
|
}).then(res => normalizeObjectKeys(res.rows));
|
|
601
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
|
+
}
|
|
602
654
|
/****************************************************************************
|
|
603
655
|
* FORMULA
|
|
604
656
|
*/
|
|
@@ -613,7 +665,7 @@ class WidgetBaseSource {
|
|
|
613
665
|
abortController,
|
|
614
666
|
operationExp
|
|
615
667
|
} = options,
|
|
616
|
-
params = _objectWithoutPropertiesLoose(options,
|
|
668
|
+
params = _objectWithoutPropertiesLoose(options, _excluded3);
|
|
617
669
|
const {
|
|
618
670
|
column,
|
|
619
671
|
operation
|
|
@@ -646,7 +698,7 @@ class WidgetBaseSource {
|
|
|
646
698
|
spatialFilter,
|
|
647
699
|
abortController
|
|
648
700
|
} = options,
|
|
649
|
-
params = _objectWithoutPropertiesLoose(options,
|
|
701
|
+
params = _objectWithoutPropertiesLoose(options, _excluded4);
|
|
650
702
|
const {
|
|
651
703
|
column,
|
|
652
704
|
operation,
|
|
@@ -692,7 +744,7 @@ class WidgetBaseSource {
|
|
|
692
744
|
spatialFilter,
|
|
693
745
|
abortController
|
|
694
746
|
} = options,
|
|
695
|
-
params = _objectWithoutPropertiesLoose(options,
|
|
747
|
+
params = _objectWithoutPropertiesLoose(options, _excluded5);
|
|
696
748
|
const {
|
|
697
749
|
column
|
|
698
750
|
} = params;
|
|
@@ -722,7 +774,7 @@ class WidgetBaseSource {
|
|
|
722
774
|
spatialFilter,
|
|
723
775
|
abortController
|
|
724
776
|
} = options,
|
|
725
|
-
params = _objectWithoutPropertiesLoose(options,
|
|
777
|
+
params = _objectWithoutPropertiesLoose(options, _excluded6);
|
|
726
778
|
const {
|
|
727
779
|
xAxisColumn,
|
|
728
780
|
xAxisJoinOperation,
|
|
@@ -764,7 +816,7 @@ class WidgetBaseSource {
|
|
|
764
816
|
spatialFilter,
|
|
765
817
|
abortController
|
|
766
818
|
} = options,
|
|
767
|
-
params = _objectWithoutPropertiesLoose(options,
|
|
819
|
+
params = _objectWithoutPropertiesLoose(options, _excluded7);
|
|
768
820
|
const {
|
|
769
821
|
columns,
|
|
770
822
|
sortBy,
|
|
@@ -809,7 +861,7 @@ class WidgetBaseSource {
|
|
|
809
861
|
abortController,
|
|
810
862
|
spatialFilter
|
|
811
863
|
} = options,
|
|
812
|
-
params = _objectWithoutPropertiesLoose(options,
|
|
864
|
+
params = _objectWithoutPropertiesLoose(options, _excluded8);
|
|
813
865
|
const {
|
|
814
866
|
column,
|
|
815
867
|
operationColumn,
|