@carto/api-client 0.5.9 → 0.5.10
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 +4 -0
- package/build/api-client.cjs +9 -6
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +1 -1
- package/build/api-client.d.ts +1 -1
- package/build/api-client.js +9 -6
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +9 -6
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +9 -6
- package/build/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/operations/groupBy.ts +14 -6
- package/src/widget-sources/types.ts +5 -1
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"homepage": "https://github.com/CartoDB/carto-api-client#readme",
|
|
9
9
|
"author": "Don McCurdy <donmccurdy@carto.com>",
|
|
10
10
|
"packageManager": "yarn@4.3.1",
|
|
11
|
-
"version": "0.5.
|
|
11
|
+
"version": "0.5.10",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -85,19 +85,27 @@ export function getSorter(
|
|
|
85
85
|
switch (orderBy) {
|
|
86
86
|
case 'frequency_asc':
|
|
87
87
|
// 'value ASC, name ASC'
|
|
88
|
-
return (a, b) => a.value - b.value ||
|
|
88
|
+
return (a, b) => a.value - b.value || nameCompare(a.name, b.name);
|
|
89
89
|
case 'frequency_desc':
|
|
90
90
|
// 'value DESC, name ASC'
|
|
91
|
-
return (a, b) => b.value - a.value ||
|
|
91
|
+
return (a, b) => b.value - a.value || nameCompare(a.name, b.name);
|
|
92
92
|
case 'alphabetical_asc':
|
|
93
93
|
// 'name ASC, value DESC'
|
|
94
|
-
return (a, b) =>
|
|
94
|
+
return (a, b) => nameCompare(a.name, b.name) || b.value - a.value;
|
|
95
95
|
case 'alphabetical_desc':
|
|
96
96
|
// 'name DESC, value DESC'
|
|
97
|
-
return (a, b) =>
|
|
97
|
+
return (a, b) => nameCompare(b.name, a.name) || b.value - a.value;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
function
|
|
102
|
-
|
|
101
|
+
function nameCompare(
|
|
102
|
+
a?: CategoryResponseEntry['name'],
|
|
103
|
+
b?: CategoryResponseEntry['name']
|
|
104
|
+
) {
|
|
105
|
+
// Despite the naming of 'alphabetical_*' sort options, we still want to
|
|
106
|
+
// sort numeric category names (usually raster datasets) numerically.
|
|
107
|
+
if (typeof a === 'number' && typeof b === 'number') {
|
|
108
|
+
return a - b;
|
|
109
|
+
}
|
|
110
|
+
return String(a ?? 'null').localeCompare(String(b ?? 'null'));
|
|
103
111
|
}
|
|
@@ -221,7 +221,11 @@ export type FeaturesResponse = {rows: Record<string, unknown>[]};
|
|
|
221
221
|
export type FormulaResponse = {value: number | null};
|
|
222
222
|
|
|
223
223
|
/** Entry in the category widget response, see {@link WidgetRemoteSource#getCategories}. */
|
|
224
|
-
export type CategoryResponseEntry = {
|
|
224
|
+
export type CategoryResponseEntry = {
|
|
225
|
+
name: string | number | null;
|
|
226
|
+
value: number;
|
|
227
|
+
};
|
|
228
|
+
|
|
225
229
|
/** Response from {@link WidgetRemoteSource#getCategories}. */
|
|
226
230
|
export type CategoryResponse = CategoryResponseEntry[];
|
|
227
231
|
|