@carto/api-client 0.4.0-alpha.5 → 0.4.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.
- package/CHANGELOG.md +8 -0
- 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 +3 -4
- 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
package/CHANGELOG.md
CHANGED
package/build/api-client.cjs
CHANGED
|
@@ -472,7 +472,7 @@ function dealWithApiError(_ref) {
|
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
/** @internalRemarks Source: @carto/react-api */
|
|
475
|
-
const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'timeseries', 'range', 'scatterplot', 'table'];
|
|
475
|
+
const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'pick', 'timeseries', 'range', 'scatterplot', 'table'];
|
|
476
476
|
const {
|
|
477
477
|
V3
|
|
478
478
|
} = exports.ApiVersion;
|
|
@@ -506,9 +506,10 @@ function executeModel(props) {
|
|
|
506
506
|
assert(type !== 'tileset', 'executeModel: Tilesets not supported');
|
|
507
507
|
let url = `${apiBaseUrl}/v3/sql/${connectionName}/model/${model}`;
|
|
508
508
|
const {
|
|
509
|
+
data,
|
|
509
510
|
filters,
|
|
510
511
|
filtersLogicalOperator = 'and',
|
|
511
|
-
|
|
512
|
+
geoColumn = DEFAULT_GEO_COLUMN
|
|
512
513
|
} = source;
|
|
513
514
|
const queryParameters = source.queryParameters ? JSON.stringify(source.queryParameters) : '';
|
|
514
515
|
const queryParams = {
|
|
@@ -520,9 +521,13 @@ function executeModel(props) {
|
|
|
520
521
|
filters: JSON.stringify(filters),
|
|
521
522
|
filtersLogicalOperator
|
|
522
523
|
};
|
|
524
|
+
// Picking Model API requires 'spatialDataColumn'.
|
|
525
|
+
if (model === 'pick') {
|
|
526
|
+
queryParams.spatialDataColumn = geoColumn;
|
|
527
|
+
}
|
|
523
528
|
// API supports multiple filters, we apply it only to geoColumn
|
|
524
529
|
const spatialFilters = source.spatialFilter ? {
|
|
525
|
-
[
|
|
530
|
+
[geoColumn]: source.spatialFilter
|
|
526
531
|
} : undefined;
|
|
527
532
|
if (spatialFilters) {
|
|
528
533
|
queryParams.spatialFilters = JSON.stringify(spatialFilters);
|
|
@@ -619,6 +624,58 @@ class WidgetBaseSource {
|
|
|
619
624
|
return Promise.reject(e);
|
|
620
625
|
}
|
|
621
626
|
}
|
|
627
|
+
/****************************************************************************
|
|
628
|
+
* FEATURES
|
|
629
|
+
*/
|
|
630
|
+
/**
|
|
631
|
+
* Given a list of feature IDs (as found in `_carto_feature_id`) returns all
|
|
632
|
+
* matching features. In datasets containing features with duplicate geometries,
|
|
633
|
+
* feature IDs may be duplicated (IDs are a hash of geometry) and so more
|
|
634
|
+
* results may be returned than IDs in the request.
|
|
635
|
+
* @internal
|
|
636
|
+
* @experimental
|
|
637
|
+
*/
|
|
638
|
+
getFeatures(options) {
|
|
639
|
+
try {
|
|
640
|
+
const _this2 = this;
|
|
641
|
+
const {
|
|
642
|
+
filterOwner,
|
|
643
|
+
spatialFilter,
|
|
644
|
+
abortController,
|
|
645
|
+
...params
|
|
646
|
+
} = options;
|
|
647
|
+
const {
|
|
648
|
+
columns,
|
|
649
|
+
dataType,
|
|
650
|
+
featureIds,
|
|
651
|
+
z,
|
|
652
|
+
limit,
|
|
653
|
+
tileResolution
|
|
654
|
+
} = params;
|
|
655
|
+
return Promise.resolve(executeModel({
|
|
656
|
+
model: 'pick',
|
|
657
|
+
source: {
|
|
658
|
+
..._this2.getModelSource(filterOwner),
|
|
659
|
+
spatialFilter
|
|
660
|
+
},
|
|
661
|
+
params: {
|
|
662
|
+
columns,
|
|
663
|
+
dataType,
|
|
664
|
+
featureIds,
|
|
665
|
+
z,
|
|
666
|
+
limit: limit || 1000,
|
|
667
|
+
tileResolution: tileResolution || DEFAULT_TILE_RESOLUTION
|
|
668
|
+
},
|
|
669
|
+
opts: {
|
|
670
|
+
abortController
|
|
671
|
+
}
|
|
672
|
+
}).then(res => ({
|
|
673
|
+
rows: normalizeObjectKeys(res.rows)
|
|
674
|
+
})));
|
|
675
|
+
} catch (e) {
|
|
676
|
+
return Promise.reject(e);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
622
679
|
/****************************************************************************
|
|
623
680
|
* FORMULA
|
|
624
681
|
*/
|
|
@@ -628,7 +685,7 @@ class WidgetBaseSource {
|
|
|
628
685
|
*/
|
|
629
686
|
getFormula(options) {
|
|
630
687
|
try {
|
|
631
|
-
const
|
|
688
|
+
const _this3 = this;
|
|
632
689
|
const {
|
|
633
690
|
filterOwner,
|
|
634
691
|
spatialFilter,
|
|
@@ -643,7 +700,7 @@ class WidgetBaseSource {
|
|
|
643
700
|
return Promise.resolve(executeModel({
|
|
644
701
|
model: 'formula',
|
|
645
702
|
source: {
|
|
646
|
-
...
|
|
703
|
+
..._this3.getModelSource(filterOwner),
|
|
647
704
|
spatialFilter
|
|
648
705
|
},
|
|
649
706
|
params: {
|
|
@@ -668,7 +725,7 @@ class WidgetBaseSource {
|
|
|
668
725
|
*/
|
|
669
726
|
getHistogram(options) {
|
|
670
727
|
try {
|
|
671
|
-
const
|
|
728
|
+
const _this4 = this;
|
|
672
729
|
const {
|
|
673
730
|
filterOwner,
|
|
674
731
|
spatialFilter,
|
|
@@ -683,7 +740,7 @@ class WidgetBaseSource {
|
|
|
683
740
|
return Promise.resolve(executeModel({
|
|
684
741
|
model: 'histogram',
|
|
685
742
|
source: {
|
|
686
|
-
...
|
|
743
|
+
..._this4.getModelSource(filterOwner),
|
|
687
744
|
spatialFilter
|
|
688
745
|
},
|
|
689
746
|
params: {
|
|
@@ -724,7 +781,7 @@ class WidgetBaseSource {
|
|
|
724
781
|
*/
|
|
725
782
|
getRange(options) {
|
|
726
783
|
try {
|
|
727
|
-
const
|
|
784
|
+
const _this5 = this;
|
|
728
785
|
const {
|
|
729
786
|
filterOwner,
|
|
730
787
|
spatialFilter,
|
|
@@ -737,7 +794,7 @@ class WidgetBaseSource {
|
|
|
737
794
|
return Promise.resolve(executeModel({
|
|
738
795
|
model: 'range',
|
|
739
796
|
source: {
|
|
740
|
-
...
|
|
797
|
+
..._this5.getModelSource(filterOwner),
|
|
741
798
|
spatialFilter
|
|
742
799
|
},
|
|
743
800
|
params: {
|
|
@@ -760,7 +817,7 @@ class WidgetBaseSource {
|
|
|
760
817
|
*/
|
|
761
818
|
getScatter(options) {
|
|
762
819
|
try {
|
|
763
|
-
const
|
|
820
|
+
const _this6 = this;
|
|
764
821
|
const {
|
|
765
822
|
filterOwner,
|
|
766
823
|
spatialFilter,
|
|
@@ -778,7 +835,7 @@ class WidgetBaseSource {
|
|
|
778
835
|
return Promise.resolve(executeModel({
|
|
779
836
|
model: 'scatterplot',
|
|
780
837
|
source: {
|
|
781
|
-
...
|
|
838
|
+
..._this6.getModelSource(filterOwner),
|
|
782
839
|
spatialFilter
|
|
783
840
|
},
|
|
784
841
|
params: {
|
|
@@ -811,7 +868,7 @@ class WidgetBaseSource {
|
|
|
811
868
|
*/
|
|
812
869
|
getTable(options) {
|
|
813
870
|
try {
|
|
814
|
-
const
|
|
871
|
+
const _this7 = this;
|
|
815
872
|
const {
|
|
816
873
|
filterOwner,
|
|
817
874
|
spatialFilter,
|
|
@@ -828,7 +885,7 @@ class WidgetBaseSource {
|
|
|
828
885
|
return Promise.resolve(executeModel({
|
|
829
886
|
model: 'table',
|
|
830
887
|
source: {
|
|
831
|
-
...
|
|
888
|
+
..._this7.getModelSource(filterOwner),
|
|
832
889
|
spatialFilter
|
|
833
890
|
},
|
|
834
891
|
params: {
|
|
@@ -859,7 +916,7 @@ class WidgetBaseSource {
|
|
|
859
916
|
*/
|
|
860
917
|
getTimeSeries(options) {
|
|
861
918
|
try {
|
|
862
|
-
const
|
|
919
|
+
const _this8 = this;
|
|
863
920
|
const {
|
|
864
921
|
filterOwner,
|
|
865
922
|
abortController,
|
|
@@ -880,7 +937,7 @@ class WidgetBaseSource {
|
|
|
880
937
|
return Promise.resolve(executeModel({
|
|
881
938
|
model: 'timeseries',
|
|
882
939
|
source: {
|
|
883
|
-
...
|
|
940
|
+
..._this8.getModelSource(filterOwner),
|
|
884
941
|
spatialFilter
|
|
885
942
|
},
|
|
886
943
|
params: {
|