@carto/api-client 0.5.7-alpha.1 → 0.5.7-alpha.3
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 +32 -11
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +14 -6
- package/build/api-client.d.ts +14 -6
- package/build/api-client.js +28 -11
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +25 -9
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +25 -9
- package/build/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/operations/groupBy.ts +24 -6
- package/src/widget-sources/constants.ts +6 -0
- package/src/widget-sources/index.ts +1 -0
- package/src/widget-sources/types.ts +3 -3
- package/src/widget-sources/widget-remote-source.ts +3 -2
- package/src/widget-sources/widget-tileset-source-impl.ts +2 -0
package/build/api-client.cjs
CHANGED
|
@@ -107,6 +107,7 @@ __export(src_exports, {
|
|
|
107
107
|
FEATURE_GEOM_PROPERTY: () => FEATURE_GEOM_PROPERTY,
|
|
108
108
|
FilterType: () => FilterType,
|
|
109
109
|
OPACITY_MAP: () => OPACITY_MAP,
|
|
110
|
+
OTHERS_CATEGORY_NAME: () => OTHERS_CATEGORY_NAME,
|
|
110
111
|
Provider: () => Provider,
|
|
111
112
|
SOURCE_DEFAULTS: () => SOURCE_DEFAULTS,
|
|
112
113
|
SchemaFieldType: () => SchemaFieldType,
|
|
@@ -6528,7 +6529,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6528
6529
|
spatialFiltersMode,
|
|
6529
6530
|
...params
|
|
6530
6531
|
} = options;
|
|
6531
|
-
const { column, operation: operation2, operationColumn, operationExp,
|
|
6532
|
+
const { column, operation: operation2, operationColumn, operationExp, othersThreshold } = params;
|
|
6532
6533
|
if (operation2 === AggregationTypes.Custom) {
|
|
6533
6534
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6534
6535
|
}
|
|
@@ -6544,7 +6545,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6544
6545
|
operation: operation2,
|
|
6545
6546
|
operationExp,
|
|
6546
6547
|
operationColumn: operationColumn || column,
|
|
6547
|
-
|
|
6548
|
+
othersThreshold
|
|
6548
6549
|
},
|
|
6549
6550
|
opts: { signal, headers: this.props.headers }
|
|
6550
6551
|
}).then((res) => normalizeObjectKeys(res.rows));
|
|
@@ -6947,12 +6948,19 @@ function normalizeSortByOptions({
|
|
|
6947
6948
|
|
|
6948
6949
|
// src/operations/groupBy.ts
|
|
6949
6950
|
init_cjs_shims();
|
|
6951
|
+
|
|
6952
|
+
// src/widget-sources/constants.ts
|
|
6953
|
+
init_cjs_shims();
|
|
6954
|
+
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
6955
|
+
|
|
6956
|
+
// src/operations/groupBy.ts
|
|
6950
6957
|
function groupValuesByColumn({
|
|
6951
6958
|
data,
|
|
6952
6959
|
valuesColumns,
|
|
6953
6960
|
joinOperation,
|
|
6954
6961
|
keysColumn,
|
|
6955
|
-
operation: operation2
|
|
6962
|
+
operation: operation2,
|
|
6963
|
+
othersThreshold
|
|
6956
6964
|
}) {
|
|
6957
6965
|
if (Array.isArray(data) && data.length === 0) {
|
|
6958
6966
|
return null;
|
|
@@ -6970,13 +6978,23 @@ function groupValuesByColumn({
|
|
|
6970
6978
|
return accumulator;
|
|
6971
6979
|
}, /* @__PURE__ */ new Map());
|
|
6972
6980
|
const targetOperation = aggregationFunctions[operation2];
|
|
6973
|
-
if (targetOperation) {
|
|
6974
|
-
return
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6981
|
+
if (!targetOperation) {
|
|
6982
|
+
return [];
|
|
6983
|
+
}
|
|
6984
|
+
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
6985
|
+
name,
|
|
6986
|
+
value: targetOperation(value)
|
|
6987
|
+
}));
|
|
6988
|
+
allCategories.sort((a, b) => b.value - a.value);
|
|
6989
|
+
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
6990
|
+
const otherNames = allCategories.map((entry) => entry.name).slice(othersThreshold);
|
|
6991
|
+
const otherValue = otherNames.flatMap((name) => groups.get(name));
|
|
6992
|
+
allCategories.push({
|
|
6993
|
+
name: OTHERS_CATEGORY_NAME,
|
|
6994
|
+
value: targetOperation(otherValue)
|
|
6995
|
+
});
|
|
6978
6996
|
}
|
|
6979
|
-
return
|
|
6997
|
+
return allCategories;
|
|
6980
6998
|
}
|
|
6981
6999
|
|
|
6982
7000
|
// src/operations/groupByDate.ts
|
|
@@ -7550,7 +7568,8 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7550
7568
|
joinOperation,
|
|
7551
7569
|
filters,
|
|
7552
7570
|
filterOwner,
|
|
7553
|
-
spatialFilter
|
|
7571
|
+
spatialFilter,
|
|
7572
|
+
othersThreshold
|
|
7554
7573
|
}) {
|
|
7555
7574
|
const filteredFeatures = this._getFilteredFeatures(
|
|
7556
7575
|
spatialFilter,
|
|
@@ -7566,7 +7585,8 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7566
7585
|
valuesColumns: normalizeColumns(operationColumn || column),
|
|
7567
7586
|
joinOperation,
|
|
7568
7587
|
keysColumn: column,
|
|
7569
|
-
operation: operation2
|
|
7588
|
+
operation: operation2,
|
|
7589
|
+
othersThreshold
|
|
7570
7590
|
});
|
|
7571
7591
|
return groups || [];
|
|
7572
7592
|
}
|
|
@@ -10299,6 +10319,7 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
10299
10319
|
FEATURE_GEOM_PROPERTY,
|
|
10300
10320
|
FilterType,
|
|
10301
10321
|
OPACITY_MAP,
|
|
10322
|
+
OTHERS_CATEGORY_NAME,
|
|
10302
10323
|
Provider,
|
|
10303
10324
|
SOURCE_DEFAULTS,
|
|
10304
10325
|
SchemaFieldType,
|