@carto/api-client 0.5.1-alpha.2 → 0.5.2-alpha.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 +7 -2
- package/build/api-client.cjs +101 -106
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +46 -15
- package/build/api-client.d.ts +46 -15
- package/build/api-client.js +95 -105
- package/build/api-client.js.map +1 -1
- package/build/worker.js +38 -33
- package/build/worker.js.map +1 -1
- package/package.json +3 -3
- package/src/fetch-map/fetch-map.ts +1 -7
- package/src/fetch-map/parse-map.ts +2 -1
- package/src/fetch-map/source.ts +12 -3
- package/src/fetch-map/types.ts +3 -2
- package/src/filters.ts +37 -2
- package/src/index.ts +1 -0
- package/src/sources/base-source.ts +8 -22
- package/src/sources/boundary-query-source.ts +1 -5
- package/src/sources/boundary-table-source.ts +1 -5
- package/src/sources/h3-query-source.ts +1 -1
- package/src/sources/h3-table-source.ts +1 -1
- package/src/sources/h3-tileset-source.ts +2 -2
- package/src/sources/index.ts +18 -10
- package/src/sources/quadbin-query-source.ts +1 -1
- package/src/sources/quadbin-table-source.ts +1 -1
- package/src/sources/quadbin-tileset-source.ts +2 -2
- package/src/sources/raster-source.ts +3 -3
- package/src/sources/types.ts +6 -8
- package/src/sources/vector-query-source.ts +1 -1
- package/src/sources/vector-table-source.ts +1 -1
- package/src/sources/vector-tileset-source.ts +2 -2
- package/src/types-internal.ts +0 -24
- package/src/utils.ts +0 -35
- package/src/widget-sources/types.ts +2 -2
- package/src/widget-sources/widget-remote-source.ts +2 -1
- package/src/widget-sources/widget-tileset-source-impl.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
## 0.5
|
|
3
|
+
## 0.5
|
|
4
4
|
|
|
5
|
-
### 0.5.
|
|
5
|
+
### 0.5.1
|
|
6
|
+
|
|
7
|
+
- chore(types): Cleanup for tilesets, rasters, and backward-compatibility (#150)
|
|
8
|
+
- feat(fetchMap): Export legendSettings (#153)
|
|
9
|
+
|
|
10
|
+
### 0.5.0
|
|
6
11
|
|
|
7
12
|
- BREAKING CHANGE: Replace 'abortController' with 'signal' parameter (#110)
|
|
8
13
|
- feat: Add widget calculations for tileset sources (#50)
|
package/build/api-client.cjs
CHANGED
|
@@ -5531,21 +5531,25 @@ __export(src_exports, {
|
|
|
5531
5531
|
buildPublicMapUrl: () => buildPublicMapUrl,
|
|
5532
5532
|
buildStatsUrl: () => buildStatsUrl,
|
|
5533
5533
|
clearFilters: () => clearFilters,
|
|
5534
|
+
configureSource: () => configureSource,
|
|
5534
5535
|
createPolygonSpatialFilter: () => createPolygonSpatialFilter,
|
|
5535
5536
|
createViewportSpatialFilter: () => createViewportSpatialFilter,
|
|
5536
5537
|
fetchBasemapProps: () => fetchBasemapProps,
|
|
5537
5538
|
fetchMap: () => fetchMap,
|
|
5538
5539
|
filterFunctions: () => filterFunctions,
|
|
5539
5540
|
geojsonFeatures: () => geojsonFeatures,
|
|
5541
|
+
getApplicableFilters: () => getApplicableFilters,
|
|
5540
5542
|
getClient: () => getClient,
|
|
5541
5543
|
getColorAccessor: () => getColorAccessor,
|
|
5542
5544
|
getColorValueAccessor: () => getColorValueAccessor,
|
|
5545
|
+
getColumnNameFromGeoColumn: () => getColumnNameFromGeoColumn,
|
|
5543
5546
|
getDataFilterExtensionProps: () => getDataFilterExtensionProps,
|
|
5544
5547
|
getFilter: () => getFilter,
|
|
5545
5548
|
getIconUrlAccessor: () => getIconUrlAccessor,
|
|
5546
5549
|
getLayerProps: () => getLayerProps,
|
|
5547
5550
|
getMaxMarkerSize: () => getMaxMarkerSize,
|
|
5548
5551
|
getSizeAccessor: () => getSizeAccessor,
|
|
5552
|
+
getSpatialIndexFromGeoColumn: () => getSpatialIndexFromGeoColumn,
|
|
5549
5553
|
getTextAccessor: () => getTextAccessor,
|
|
5550
5554
|
groupValuesByColumn: () => groupValuesByColumn,
|
|
5551
5555
|
groupValuesByDateColumn: () => groupValuesByDateColumn,
|
|
@@ -5565,6 +5569,7 @@ __export(src_exports, {
|
|
|
5565
5569
|
rasterSource: () => rasterSource,
|
|
5566
5570
|
removeFilter: () => removeFilter,
|
|
5567
5571
|
requestWithParameters: () => requestWithParameters,
|
|
5572
|
+
scaleAggregationResLevel: () => scaleAggregationResLevel,
|
|
5568
5573
|
scatterPlot: () => scatterPlot,
|
|
5569
5574
|
setClient: () => setClient,
|
|
5570
5575
|
tileFeatures: () => tileFeatures,
|
|
@@ -11092,24 +11097,6 @@ function isValidBandValue(value, nodata) {
|
|
|
11092
11097
|
|
|
11093
11098
|
// src/utils.ts
|
|
11094
11099
|
init_cjs_shims();
|
|
11095
|
-
var FILTER_TYPES = new Set(Object.values(FilterType));
|
|
11096
|
-
var isFilterType = (type) => FILTER_TYPES.has(type);
|
|
11097
|
-
function getApplicableFilters(owner, filters) {
|
|
11098
|
-
if (!filters) return {};
|
|
11099
|
-
const applicableFilters = {};
|
|
11100
|
-
for (const column in filters) {
|
|
11101
|
-
for (const type in filters[column]) {
|
|
11102
|
-
if (!isFilterType(type)) continue;
|
|
11103
|
-
const filter = filters[column][type];
|
|
11104
|
-
const isApplicable = !owner || !filter?.owner || filter?.owner !== owner;
|
|
11105
|
-
if (filter && isApplicable) {
|
|
11106
|
-
applicableFilters[column] || (applicableFilters[column] = {});
|
|
11107
|
-
applicableFilters[column][type] = filter;
|
|
11108
|
-
}
|
|
11109
|
-
}
|
|
11110
|
-
}
|
|
11111
|
-
return applicableFilters;
|
|
11112
|
-
}
|
|
11113
11100
|
function normalizeObjectKeys(el) {
|
|
11114
11101
|
if (Array.isArray(el)) {
|
|
11115
11102
|
return el.map((value) => normalizeObjectKeys(value));
|
|
@@ -11501,7 +11488,6 @@ function excludeURLParameters(baseUrlString, parameters) {
|
|
|
11501
11488
|
// src/sources/base-source.ts
|
|
11502
11489
|
var SOURCE_DEFAULTS = {
|
|
11503
11490
|
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
11504
|
-
format: "tilejson",
|
|
11505
11491
|
headers: {},
|
|
11506
11492
|
maxLengthURL: DEFAULT_MAX_LENGTH_URL
|
|
11507
11493
|
};
|
|
@@ -11520,7 +11506,7 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
11520
11506
|
}
|
|
11521
11507
|
}
|
|
11522
11508
|
const baseUrl = buildSourceUrl(mergedOptions);
|
|
11523
|
-
const { clientId, maxLengthURL,
|
|
11509
|
+
const { clientId, maxLengthURL, localCache } = mergedOptions;
|
|
11524
11510
|
const headers = {
|
|
11525
11511
|
Authorization: `Bearer ${options.accessToken}`,
|
|
11526
11512
|
...options.headers
|
|
@@ -11540,7 +11526,7 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
11540
11526
|
maxLengthURL,
|
|
11541
11527
|
localCache
|
|
11542
11528
|
});
|
|
11543
|
-
const dataUrl = mapInstantiation
|
|
11529
|
+
const dataUrl = mapInstantiation.tilejson.url[0];
|
|
11544
11530
|
if (cache) {
|
|
11545
11531
|
cache.value = parseInt(
|
|
11546
11532
|
new URL(dataUrl).searchParams.get("cache") || "",
|
|
@@ -11548,21 +11534,7 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
11548
11534
|
);
|
|
11549
11535
|
}
|
|
11550
11536
|
errorContext.requestType = "Map data";
|
|
11551
|
-
|
|
11552
|
-
const json = await requestWithParameters({
|
|
11553
|
-
baseUrl: dataUrl,
|
|
11554
|
-
parameters: { client: clientId },
|
|
11555
|
-
headers,
|
|
11556
|
-
errorContext,
|
|
11557
|
-
maxLengthURL,
|
|
11558
|
-
localCache
|
|
11559
|
-
});
|
|
11560
|
-
if (accessToken) {
|
|
11561
|
-
json.accessToken = accessToken;
|
|
11562
|
-
}
|
|
11563
|
-
return json;
|
|
11564
|
-
}
|
|
11565
|
-
return await requestWithParameters({
|
|
11537
|
+
const json = await requestWithParameters({
|
|
11566
11538
|
baseUrl: dataUrl,
|
|
11567
11539
|
parameters: { client: clientId },
|
|
11568
11540
|
headers,
|
|
@@ -11570,6 +11542,10 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
11570
11542
|
maxLengthURL,
|
|
11571
11543
|
localCache
|
|
11572
11544
|
});
|
|
11545
|
+
if (accessToken) {
|
|
11546
|
+
json.accessToken = accessToken;
|
|
11547
|
+
}
|
|
11548
|
+
return json;
|
|
11573
11549
|
}
|
|
11574
11550
|
|
|
11575
11551
|
// src/sources/boundary-query-source.ts
|
|
@@ -11595,11 +11571,7 @@ var boundaryQuerySource = async function(options) {
|
|
|
11595
11571
|
if (queryParameters) {
|
|
11596
11572
|
urlParameters.queryParameters = queryParameters;
|
|
11597
11573
|
}
|
|
11598
|
-
return baseSource(
|
|
11599
|
-
"boundary",
|
|
11600
|
-
options,
|
|
11601
|
-
urlParameters
|
|
11602
|
-
);
|
|
11574
|
+
return baseSource("boundary", options, urlParameters);
|
|
11603
11575
|
};
|
|
11604
11576
|
|
|
11605
11577
|
// src/sources/boundary-table-source.ts
|
|
@@ -11616,11 +11588,7 @@ var boundaryTableSource = async function(options) {
|
|
|
11616
11588
|
if (filters) {
|
|
11617
11589
|
urlParameters.filters = filters;
|
|
11618
11590
|
}
|
|
11619
|
-
return baseSource(
|
|
11620
|
-
"boundary",
|
|
11621
|
-
options,
|
|
11622
|
-
urlParameters
|
|
11623
|
-
);
|
|
11591
|
+
return baseSource("boundary", options, urlParameters);
|
|
11624
11592
|
};
|
|
11625
11593
|
|
|
11626
11594
|
// src/sources/h3-query-source.ts
|
|
@@ -11815,6 +11783,83 @@ function objectToURLSearchParams(object) {
|
|
|
11815
11783
|
return params;
|
|
11816
11784
|
}
|
|
11817
11785
|
|
|
11786
|
+
// src/filters.ts
|
|
11787
|
+
init_cjs_shims();
|
|
11788
|
+
var FILTER_TYPES = new Set(Object.values(FilterType));
|
|
11789
|
+
var isFilterType = (type) => FILTER_TYPES.has(type);
|
|
11790
|
+
function addFilter(filters, { column, type, values, owner }) {
|
|
11791
|
+
if (!filters[column]) {
|
|
11792
|
+
filters[column] = {};
|
|
11793
|
+
}
|
|
11794
|
+
const filter = { values, owner };
|
|
11795
|
+
filters[column][type] = filter;
|
|
11796
|
+
return filters;
|
|
11797
|
+
}
|
|
11798
|
+
function removeFilter(filters, { column, owner }) {
|
|
11799
|
+
const filter = filters[column];
|
|
11800
|
+
if (!filter) {
|
|
11801
|
+
return filters;
|
|
11802
|
+
}
|
|
11803
|
+
if (owner) {
|
|
11804
|
+
for (const type of FILTER_TYPES) {
|
|
11805
|
+
if (owner === filter[type]?.owner) {
|
|
11806
|
+
delete filter[type];
|
|
11807
|
+
}
|
|
11808
|
+
}
|
|
11809
|
+
}
|
|
11810
|
+
if (!owner || isEmptyObject(filter)) {
|
|
11811
|
+
delete filters[column];
|
|
11812
|
+
}
|
|
11813
|
+
return filters;
|
|
11814
|
+
}
|
|
11815
|
+
function clearFilters(filters) {
|
|
11816
|
+
for (const column of Object.keys(filters)) {
|
|
11817
|
+
delete filters[column];
|
|
11818
|
+
}
|
|
11819
|
+
return filters;
|
|
11820
|
+
}
|
|
11821
|
+
function hasFilter(filters, { column, owner }) {
|
|
11822
|
+
const filter = filters[column];
|
|
11823
|
+
if (!filter) {
|
|
11824
|
+
return false;
|
|
11825
|
+
}
|
|
11826
|
+
if (!owner) {
|
|
11827
|
+
return true;
|
|
11828
|
+
}
|
|
11829
|
+
for (const type of FILTER_TYPES) {
|
|
11830
|
+
if (owner === filter[type]?.owner) {
|
|
11831
|
+
return true;
|
|
11832
|
+
}
|
|
11833
|
+
}
|
|
11834
|
+
return false;
|
|
11835
|
+
}
|
|
11836
|
+
function getFilter(filters, { column, type, owner }) {
|
|
11837
|
+
const filter = filters[column];
|
|
11838
|
+
if (!filter) {
|
|
11839
|
+
return null;
|
|
11840
|
+
}
|
|
11841
|
+
if (!owner || owner === filter[type]?.owner) {
|
|
11842
|
+
return filter[type] || null;
|
|
11843
|
+
}
|
|
11844
|
+
return null;
|
|
11845
|
+
}
|
|
11846
|
+
function getApplicableFilters(owner, filters) {
|
|
11847
|
+
if (!filters) return {};
|
|
11848
|
+
const applicableFilters = {};
|
|
11849
|
+
for (const column in filters) {
|
|
11850
|
+
for (const type in filters[column]) {
|
|
11851
|
+
if (!isFilterType(type)) continue;
|
|
11852
|
+
const filter = filters[column][type];
|
|
11853
|
+
const isApplicable = !owner || !filter?.owner || filter?.owner !== owner;
|
|
11854
|
+
if (filter && isApplicable) {
|
|
11855
|
+
applicableFilters[column] || (applicableFilters[column] = {});
|
|
11856
|
+
applicableFilters[column][type] = filter;
|
|
11857
|
+
}
|
|
11858
|
+
}
|
|
11859
|
+
}
|
|
11860
|
+
return applicableFilters;
|
|
11861
|
+
}
|
|
11862
|
+
|
|
11818
11863
|
// src/widget-sources/widget-remote-source.ts
|
|
11819
11864
|
var WidgetRemoteSource = class extends WidgetSource {
|
|
11820
11865
|
_getModelSource(filters, filterOwner) {
|
|
@@ -12909,6 +12954,9 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
12909
12954
|
return { rows: [], totalCount: 0 };
|
|
12910
12955
|
}
|
|
12911
12956
|
if (searchFilterColumn && searchFilterText) {
|
|
12957
|
+
console.warn(
|
|
12958
|
+
'WidgetTilesetSource: "searchFilterText" is deprecated, use "filters" and FilterType.STRING_SEARCH instead.'
|
|
12959
|
+
);
|
|
12912
12960
|
filteredFeatures = filteredFeatures.filter(
|
|
12913
12961
|
(row) => row[searchFilterColumn] && String(row[searchFilterColumn]).toLowerCase().includes(String(searchFilterText).toLowerCase())
|
|
12914
12962
|
);
|
|
@@ -14756,7 +14804,7 @@ function parseMap(json) {
|
|
|
14756
14804
|
const { keplerMapConfig, datasets, token } = json;
|
|
14757
14805
|
assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
|
|
14758
14806
|
const config2 = keplerMapConfig.config;
|
|
14759
|
-
const { filters, mapState, mapStyle, popupSettings } = config2;
|
|
14807
|
+
const { filters, mapState, mapStyle, popupSettings, legendSettings } = config2;
|
|
14760
14808
|
const { layers, layerBlending, interactionConfig } = config2.visState;
|
|
14761
14809
|
return {
|
|
14762
14810
|
id: json.id,
|
|
@@ -14768,6 +14816,7 @@ function parseMap(json) {
|
|
|
14768
14816
|
/** @deprecated Use `basemap`. */
|
|
14769
14817
|
mapStyle,
|
|
14770
14818
|
popupSettings,
|
|
14819
|
+
legendSettings,
|
|
14771
14820
|
token,
|
|
14772
14821
|
layers: layers.reverse().map(({ id, type, config: config3, visualChannels }) => {
|
|
14773
14822
|
try {
|
|
@@ -15488,65 +15537,6 @@ async function fetchMap({
|
|
|
15488
15537
|
return out;
|
|
15489
15538
|
}
|
|
15490
15539
|
|
|
15491
|
-
// src/filters.ts
|
|
15492
|
-
init_cjs_shims();
|
|
15493
|
-
function addFilter(filters, { column, type, values, owner }) {
|
|
15494
|
-
if (!filters[column]) {
|
|
15495
|
-
filters[column] = {};
|
|
15496
|
-
}
|
|
15497
|
-
const filter = { values, owner };
|
|
15498
|
-
filters[column][type] = filter;
|
|
15499
|
-
return filters;
|
|
15500
|
-
}
|
|
15501
|
-
function removeFilter(filters, { column, owner }) {
|
|
15502
|
-
const filter = filters[column];
|
|
15503
|
-
if (!filter) {
|
|
15504
|
-
return filters;
|
|
15505
|
-
}
|
|
15506
|
-
if (owner) {
|
|
15507
|
-
for (const type of Object.values(FilterType)) {
|
|
15508
|
-
if (owner === filter[type]?.owner) {
|
|
15509
|
-
delete filter[type];
|
|
15510
|
-
}
|
|
15511
|
-
}
|
|
15512
|
-
}
|
|
15513
|
-
if (!owner || isEmptyObject(filter)) {
|
|
15514
|
-
delete filters[column];
|
|
15515
|
-
}
|
|
15516
|
-
return filters;
|
|
15517
|
-
}
|
|
15518
|
-
function clearFilters(filters) {
|
|
15519
|
-
for (const column of Object.keys(filters)) {
|
|
15520
|
-
delete filters[column];
|
|
15521
|
-
}
|
|
15522
|
-
return filters;
|
|
15523
|
-
}
|
|
15524
|
-
function hasFilter(filters, { column, owner }) {
|
|
15525
|
-
const filter = filters[column];
|
|
15526
|
-
if (!filter) {
|
|
15527
|
-
return false;
|
|
15528
|
-
}
|
|
15529
|
-
if (!owner) {
|
|
15530
|
-
return true;
|
|
15531
|
-
}
|
|
15532
|
-
for (const type of Object.values(FilterType)) {
|
|
15533
|
-
if (owner === filter[type]?.owner) {
|
|
15534
|
-
return true;
|
|
15535
|
-
}
|
|
15536
|
-
}
|
|
15537
|
-
return false;
|
|
15538
|
-
}
|
|
15539
|
-
function getFilter(filters, { column, type, owner }) {
|
|
15540
|
-
const filter = filters[column];
|
|
15541
|
-
if (!filter) {
|
|
15542
|
-
return null;
|
|
15543
|
-
}
|
|
15544
|
-
if (!owner || owner === filter[type]?.owner) {
|
|
15545
|
-
return filter[type] || null;
|
|
15546
|
-
}
|
|
15547
|
-
return null;
|
|
15548
|
-
}
|
|
15549
|
-
|
|
15550
15540
|
// src/geo.ts
|
|
15551
15541
|
init_cjs_shims();
|
|
15552
15542
|
|
|
@@ -15722,21 +15712,25 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
15722
15712
|
buildPublicMapUrl,
|
|
15723
15713
|
buildStatsUrl,
|
|
15724
15714
|
clearFilters,
|
|
15715
|
+
configureSource,
|
|
15725
15716
|
createPolygonSpatialFilter,
|
|
15726
15717
|
createViewportSpatialFilter,
|
|
15727
15718
|
fetchBasemapProps,
|
|
15728
15719
|
fetchMap,
|
|
15729
15720
|
filterFunctions,
|
|
15730
15721
|
geojsonFeatures,
|
|
15722
|
+
getApplicableFilters,
|
|
15731
15723
|
getClient,
|
|
15732
15724
|
getColorAccessor,
|
|
15733
15725
|
getColorValueAccessor,
|
|
15726
|
+
getColumnNameFromGeoColumn,
|
|
15734
15727
|
getDataFilterExtensionProps,
|
|
15735
15728
|
getFilter,
|
|
15736
15729
|
getIconUrlAccessor,
|
|
15737
15730
|
getLayerProps,
|
|
15738
15731
|
getMaxMarkerSize,
|
|
15739
15732
|
getSizeAccessor,
|
|
15733
|
+
getSpatialIndexFromGeoColumn,
|
|
15740
15734
|
getTextAccessor,
|
|
15741
15735
|
groupValuesByColumn,
|
|
15742
15736
|
groupValuesByDateColumn,
|
|
@@ -15756,6 +15750,7 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
15756
15750
|
rasterSource,
|
|
15757
15751
|
removeFilter,
|
|
15758
15752
|
requestWithParameters,
|
|
15753
|
+
scaleAggregationResLevel,
|
|
15759
15754
|
scatterPlot,
|
|
15760
15755
|
setClient,
|
|
15761
15756
|
tileFeatures,
|