@carto/api-client 0.5.19 → 0.5.21
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 +9 -3
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.js +9 -3
- package/build/api-client.js.map +1 -1
- package/package.json +1 -1
- package/src/api/query.ts +5 -2
- package/src/fetch-map/fetch-map.ts +2 -2
- package/src/fetch-map/layer-map.ts +13 -3
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.21",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
package/src/api/query.ts
CHANGED
|
@@ -24,7 +24,10 @@ export type QueryOptions = SourceOptions &
|
|
|
24
24
|
/** Used to abort the request. */
|
|
25
25
|
signal?: AbortSignal;
|
|
26
26
|
};
|
|
27
|
-
type UrlParameters = {
|
|
27
|
+
type UrlParameters = {
|
|
28
|
+
q: string;
|
|
29
|
+
queryParameters?: Record<string, unknown> | unknown[];
|
|
30
|
+
};
|
|
28
31
|
|
|
29
32
|
export const query = async function (
|
|
30
33
|
options: QueryOptions
|
|
@@ -42,7 +45,7 @@ export const query = async function (
|
|
|
42
45
|
const urlParameters: UrlParameters = {q: sqlQuery};
|
|
43
46
|
|
|
44
47
|
if (queryParameters) {
|
|
45
|
-
urlParameters.queryParameters =
|
|
48
|
+
urlParameters.queryParameters = queryParameters;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
const baseUrl = buildQueryUrl({apiBaseUrl, connectionName});
|
|
@@ -70,14 +70,14 @@ async function _fetchTilestats(
|
|
|
70
70
|
const baseUrl = buildStatsUrl({attribute, apiBaseUrl, ...dataset});
|
|
71
71
|
const client = new URLSearchParams(data.tiles[0]).get('client');
|
|
72
72
|
const headers = {Authorization: `Bearer ${context.accessToken}`};
|
|
73
|
-
const parameters: Record<string,
|
|
73
|
+
const parameters: Record<string, unknown> = {};
|
|
74
74
|
if (client) {
|
|
75
75
|
parameters.client = client;
|
|
76
76
|
}
|
|
77
77
|
if (type === 'query') {
|
|
78
78
|
parameters.q = source;
|
|
79
79
|
if (queryParameters) {
|
|
80
|
-
parameters.queryParameters =
|
|
80
|
+
parameters.queryParameters = queryParameters;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
const stats = await requestWithParameters({
|
|
@@ -240,9 +240,19 @@ function domainFromAttribute(
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
if (scaleType === 'quantile' && attribute.quantiles) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
const quantiles: Record<number, number[]> =
|
|
244
|
+
'global' in attribute.quantiles
|
|
245
|
+
? attribute.quantiles.global
|
|
246
|
+
: attribute.quantiles;
|
|
247
|
+
|
|
248
|
+
// Stats API doesn't provide quantile[2] - which would be effecively [min, median, max]
|
|
249
|
+
// so let's derive median from Quartiles (quantile[4]), of which second is median
|
|
250
|
+
if (scaleLength === 2 && !quantiles[2] && quantiles[4]?.length === 5) {
|
|
251
|
+
return [quantiles[4][0], quantiles[4][2], quantiles[4][4]];
|
|
252
|
+
}
|
|
253
|
+
if (quantiles[scaleLength]) {
|
|
254
|
+
return quantiles[scaleLength];
|
|
255
|
+
}
|
|
246
256
|
}
|
|
247
257
|
|
|
248
258
|
let {min} = attribute;
|