@carto/api-client 0.5.9-alpha.PR193.2 → 0.5.9-alpha.orderby.1
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 +47 -33
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +14 -18
- package/build/api-client.d.ts +14 -18
- package/build/api-client.js +46 -33
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +21 -3
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +21 -3
- package/build/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/api/query.ts +2 -19
- package/src/api/request-with-parameters.ts +5 -10
- package/src/models/model.ts +0 -3
- package/src/operations/groupBy.ts +31 -2
- package/src/sources/base-source.ts +1 -1
- package/src/sources/types.ts +0 -3
- package/src/widget-sources/types.ts +12 -0
- package/src/widget-sources/widget-remote-source.ts +9 -3
- package/src/widget-sources/widget-tileset-source-impl.ts +2 -0
package/build/api-client.cjs
CHANGED
|
@@ -159,6 +159,7 @@ __export(src_exports, {
|
|
|
159
159
|
getLayerProps: () => getLayerProps,
|
|
160
160
|
getMaxMarkerSize: () => getMaxMarkerSize,
|
|
161
161
|
getSizeAccessor: () => getSizeAccessor,
|
|
162
|
+
getSorter: () => getSorter,
|
|
162
163
|
getSpatialIndexFromGeoColumn: () => getSpatialIndexFromGeoColumn,
|
|
163
164
|
getTextAccessor: () => getTextAccessor,
|
|
164
165
|
groupValuesByColumn: () => groupValuesByColumn,
|
|
@@ -6083,8 +6084,7 @@ async function requestWithParameters({
|
|
|
6083
6084
|
headers: customHeaders = {},
|
|
6084
6085
|
errorContext,
|
|
6085
6086
|
maxLengthURL = DEFAULT_MAX_LENGTH_URL,
|
|
6086
|
-
localCache
|
|
6087
|
-
signal
|
|
6087
|
+
localCache
|
|
6088
6088
|
}) {
|
|
6089
6089
|
parameters = {
|
|
6090
6090
|
v: V3_MINOR_VERSION,
|
|
@@ -6107,9 +6107,8 @@ async function requestWithParameters({
|
|
|
6107
6107
|
const fetchPromise = url.length > maxLengthURL ? fetch(baseUrl, {
|
|
6108
6108
|
method: "POST",
|
|
6109
6109
|
body: JSON.stringify(parameters),
|
|
6110
|
-
headers
|
|
6111
|
-
|
|
6112
|
-
}) : fetch(url, { headers, signal });
|
|
6110
|
+
headers
|
|
6111
|
+
}) : fetch(url, { headers });
|
|
6113
6112
|
let response;
|
|
6114
6113
|
let responseJson;
|
|
6115
6114
|
const jsonPromise = fetchPromise.then((_response) => {
|
|
@@ -6161,12 +6160,10 @@ function createURLWithParameters(baseUrlString, parameters) {
|
|
|
6161
6160
|
if (isPureObject(value) || Array.isArray(value)) {
|
|
6162
6161
|
baseUrl.searchParams.set(key, JSON.stringify(value));
|
|
6163
6162
|
} else {
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
);
|
|
6169
|
-
}
|
|
6163
|
+
baseUrl.searchParams.set(
|
|
6164
|
+
key,
|
|
6165
|
+
value.toString()
|
|
6166
|
+
);
|
|
6170
6167
|
}
|
|
6171
6168
|
}
|
|
6172
6169
|
return baseUrl.toString();
|
|
@@ -6210,7 +6207,7 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
6210
6207
|
Authorization: `Bearer ${options.accessToken}`,
|
|
6211
6208
|
...options.headers
|
|
6212
6209
|
};
|
|
6213
|
-
const parameters = { client: clientId, ...
|
|
6210
|
+
const parameters = { client: clientId, ...urlParameters };
|
|
6214
6211
|
const errorContext = {
|
|
6215
6212
|
requestType: "Map instantiation",
|
|
6216
6213
|
connection: options.connectionName,
|
|
@@ -6431,8 +6428,7 @@ function executeModel(props) {
|
|
|
6431
6428
|
filtersLogicalOperator = "and",
|
|
6432
6429
|
spatialDataType = "geo",
|
|
6433
6430
|
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
6434
|
-
spatialFiltersMode = "intersects"
|
|
6435
|
-
tags
|
|
6431
|
+
spatialFiltersMode = "intersects"
|
|
6436
6432
|
} = source;
|
|
6437
6433
|
const queryParams = {
|
|
6438
6434
|
type,
|
|
@@ -6441,8 +6437,7 @@ function executeModel(props) {
|
|
|
6441
6437
|
params,
|
|
6442
6438
|
queryParameters: source.queryParameters || "",
|
|
6443
6439
|
filters,
|
|
6444
|
-
filtersLogicalOperator
|
|
6445
|
-
tags
|
|
6440
|
+
filtersLogicalOperator
|
|
6446
6441
|
};
|
|
6447
6442
|
queryParams.spatialDataType = spatialDataType;
|
|
6448
6443
|
queryParams.spatialDataColumn = spatialDataColumn;
|
|
@@ -6577,8 +6572,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6577
6572
|
filters: getApplicableFilters(filterOwner, filters || props.filters),
|
|
6578
6573
|
filtersLogicalOperator: props.filtersLogicalOperator,
|
|
6579
6574
|
spatialDataType: props.spatialDataType,
|
|
6580
|
-
spatialDataColumn: props.spatialDataColumn
|
|
6581
|
-
tags: props.tags
|
|
6575
|
+
spatialDataColumn: props.spatialDataColumn
|
|
6582
6576
|
};
|
|
6583
6577
|
}
|
|
6584
6578
|
async getCategories(options) {
|
|
@@ -6591,7 +6585,14 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6591
6585
|
rawResult,
|
|
6592
6586
|
...params
|
|
6593
6587
|
} = options;
|
|
6594
|
-
const {
|
|
6588
|
+
const {
|
|
6589
|
+
column,
|
|
6590
|
+
operation: operation2,
|
|
6591
|
+
operationColumn,
|
|
6592
|
+
operationExp,
|
|
6593
|
+
othersThreshold,
|
|
6594
|
+
orderBy
|
|
6595
|
+
} = params;
|
|
6595
6596
|
if (operation2 === AggregationTypes.Custom) {
|
|
6596
6597
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6597
6598
|
}
|
|
@@ -6607,7 +6608,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6607
6608
|
operation: operation2,
|
|
6608
6609
|
operationExp,
|
|
6609
6610
|
operationColumn: operationColumn || column,
|
|
6610
|
-
othersThreshold
|
|
6611
|
+
othersThreshold,
|
|
6612
|
+
orderBy
|
|
6611
6613
|
},
|
|
6612
6614
|
opts: { signal, headers: this.props.headers }
|
|
6613
6615
|
});
|
|
@@ -7027,7 +7029,8 @@ function groupValuesByColumn({
|
|
|
7027
7029
|
joinOperation,
|
|
7028
7030
|
keysColumn,
|
|
7029
7031
|
operation: operation2,
|
|
7030
|
-
othersThreshold
|
|
7032
|
+
othersThreshold,
|
|
7033
|
+
orderBy = "frequency_desc"
|
|
7031
7034
|
}) {
|
|
7032
7035
|
if (Array.isArray(data) && data.length === 0) {
|
|
7033
7036
|
return { rows: null };
|
|
@@ -7051,7 +7054,7 @@ function groupValuesByColumn({
|
|
|
7051
7054
|
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
7052
7055
|
name,
|
|
7053
7056
|
value: targetOperation(value)
|
|
7054
|
-
})).sort((
|
|
7057
|
+
})).sort(getSorter(orderBy));
|
|
7055
7058
|
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
7056
7059
|
const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
|
|
7057
7060
|
return {
|
|
@@ -7065,6 +7068,21 @@ function groupValuesByColumn({
|
|
|
7065
7068
|
rows: allCategories
|
|
7066
7069
|
};
|
|
7067
7070
|
}
|
|
7071
|
+
function getSorter(orderBy) {
|
|
7072
|
+
switch (orderBy) {
|
|
7073
|
+
case "frequency_asc":
|
|
7074
|
+
return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
|
|
7075
|
+
case "frequency_desc":
|
|
7076
|
+
return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
|
|
7077
|
+
case "alphabetical_asc":
|
|
7078
|
+
return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
|
|
7079
|
+
case "alphabetical_desc":
|
|
7080
|
+
return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
|
|
7081
|
+
}
|
|
7082
|
+
}
|
|
7083
|
+
function localeCompare(a, b) {
|
|
7084
|
+
return (a ?? "null").localeCompare(b ?? "null");
|
|
7085
|
+
}
|
|
7068
7086
|
|
|
7069
7087
|
// src/operations/groupByDate.ts
|
|
7070
7088
|
init_cjs_shims();
|
|
@@ -7639,6 +7657,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7639
7657
|
filterOwner,
|
|
7640
7658
|
spatialFilter,
|
|
7641
7659
|
othersThreshold,
|
|
7660
|
+
orderBy = "frequency_desc",
|
|
7642
7661
|
rawResult
|
|
7643
7662
|
}) {
|
|
7644
7663
|
const filteredFeatures = this._getFilteredFeatures(
|
|
@@ -7656,7 +7675,8 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7656
7675
|
joinOperation,
|
|
7657
7676
|
keysColumn: column,
|
|
7658
7677
|
operation: operation2,
|
|
7659
|
-
othersThreshold
|
|
7678
|
+
othersThreshold,
|
|
7679
|
+
orderBy
|
|
7660
7680
|
});
|
|
7661
7681
|
if (rawResult) {
|
|
7662
7682
|
return result;
|
|
@@ -8391,8 +8411,7 @@ var query = async function(options) {
|
|
|
8391
8411
|
localCache,
|
|
8392
8412
|
connectionName,
|
|
8393
8413
|
sqlQuery,
|
|
8394
|
-
queryParameters
|
|
8395
|
-
internalParameters
|
|
8414
|
+
queryParameters
|
|
8396
8415
|
} = options;
|
|
8397
8416
|
const urlParameters = { q: sqlQuery };
|
|
8398
8417
|
if (queryParameters) {
|
|
@@ -8403,12 +8422,7 @@ var query = async function(options) {
|
|
|
8403
8422
|
Authorization: `Bearer ${options.accessToken}`,
|
|
8404
8423
|
...options.headers
|
|
8405
8424
|
};
|
|
8406
|
-
const parameters = {
|
|
8407
|
-
client: clientId,
|
|
8408
|
-
...options.tags,
|
|
8409
|
-
...internalParameters,
|
|
8410
|
-
...urlParameters
|
|
8411
|
-
};
|
|
8425
|
+
const parameters = { client: clientId, ...urlParameters };
|
|
8412
8426
|
const errorContext = {
|
|
8413
8427
|
requestType: "SQL",
|
|
8414
8428
|
connection: options.connectionName,
|
|
@@ -8421,8 +8435,7 @@ var query = async function(options) {
|
|
|
8421
8435
|
headers,
|
|
8422
8436
|
errorContext,
|
|
8423
8437
|
maxLengthURL,
|
|
8424
|
-
localCache
|
|
8425
|
-
signal: options.signal
|
|
8438
|
+
localCache
|
|
8426
8439
|
});
|
|
8427
8440
|
};
|
|
8428
8441
|
|
|
@@ -10518,6 +10531,7 @@ function hashBuckets(initialCount) {
|
|
|
10518
10531
|
getLayerProps,
|
|
10519
10532
|
getMaxMarkerSize,
|
|
10520
10533
|
getSizeAccessor,
|
|
10534
|
+
getSorter,
|
|
10521
10535
|
getSpatialIndexFromGeoColumn,
|
|
10522
10536
|
getTextAccessor,
|
|
10523
10537
|
groupValuesByColumn,
|