@carto/api-client 0.5.10-alpha.PR193.4 → 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 +23 -34
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +3 -16
- package/build/api-client.d.ts +3 -16
- package/build/api-client.js +23 -34
- 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/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 +14 -6
- package/src/sources/base-source.ts +1 -1
- package/src/sources/types.ts +0 -3
- package/src/widget-sources/types.ts +5 -1
- package/src/widget-sources/widget-remote-source.ts +0 -1
package/build/api-client.d.cts
CHANGED
|
@@ -388,8 +388,6 @@ type SourceOptionalOptions = {
|
|
|
388
388
|
* By default, local in-memory caching is enabled.
|
|
389
389
|
*/
|
|
390
390
|
localCache?: LocalCacheOptions;
|
|
391
|
-
/** Additional tags appended to HTTP requests, available for analytics and audits. */
|
|
392
|
-
tags?: Record<string, string>;
|
|
393
391
|
};
|
|
394
392
|
type LocalCacheOptions = {
|
|
395
393
|
/**
|
|
@@ -689,26 +687,16 @@ type QueryResult = {
|
|
|
689
687
|
}[];
|
|
690
688
|
};
|
|
691
689
|
|
|
692
|
-
type QueryOptions = SourceOptions & QuerySourceOptions
|
|
693
|
-
/**
|
|
694
|
-
* @internal
|
|
695
|
-
* @experimental
|
|
696
|
-
* Used to append additional parameters to the SQL API request for features specific to providers or integrations.
|
|
697
|
-
*/
|
|
698
|
-
internalParameters?: Record<string, string | boolean | number>;
|
|
699
|
-
/** Used to abort the request. */
|
|
700
|
-
signal?: AbortSignal;
|
|
701
|
-
};
|
|
690
|
+
type QueryOptions = SourceOptions & QuerySourceOptions;
|
|
702
691
|
declare const query: (options: QueryOptions) => Promise<QueryResult>;
|
|
703
692
|
|
|
704
|
-
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache,
|
|
693
|
+
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
|
|
705
694
|
baseUrl: string;
|
|
706
695
|
parameters?: Record<string, unknown>;
|
|
707
696
|
headers?: Record<string, string>;
|
|
708
697
|
errorContext: APIErrorContext;
|
|
709
698
|
maxLengthURL?: number;
|
|
710
699
|
localCache?: LocalCacheOptions;
|
|
711
|
-
signal?: AbortSignal;
|
|
712
700
|
}): Promise<T>;
|
|
713
701
|
/**
|
|
714
702
|
* Clears the HTTP response cache for all requests using the default cache.
|
|
@@ -1351,7 +1339,7 @@ type FormulaResponse = {
|
|
|
1351
1339
|
};
|
|
1352
1340
|
/** Entry in the category widget response, see {@link WidgetRemoteSource#getCategories}. */
|
|
1353
1341
|
type CategoryResponseEntry = {
|
|
1354
|
-
name: string | null;
|
|
1342
|
+
name: string | number | null;
|
|
1355
1343
|
value: number;
|
|
1356
1344
|
};
|
|
1357
1345
|
/** Response from {@link WidgetRemoteSource#getCategories}. */
|
|
@@ -1469,7 +1457,6 @@ interface ModelSource {
|
|
|
1469
1457
|
spatialDataColumn?: string;
|
|
1470
1458
|
spatialDataType?: SpatialDataType;
|
|
1471
1459
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
1472
|
-
tags?: Record<string, string>;
|
|
1473
1460
|
}
|
|
1474
1461
|
|
|
1475
1462
|
type WidgetRemoteSourceProps = WidgetSourceProps;
|
package/build/api-client.d.ts
CHANGED
|
@@ -388,8 +388,6 @@ type SourceOptionalOptions = {
|
|
|
388
388
|
* By default, local in-memory caching is enabled.
|
|
389
389
|
*/
|
|
390
390
|
localCache?: LocalCacheOptions;
|
|
391
|
-
/** Additional tags appended to HTTP requests, available for analytics and audits. */
|
|
392
|
-
tags?: Record<string, string>;
|
|
393
391
|
};
|
|
394
392
|
type LocalCacheOptions = {
|
|
395
393
|
/**
|
|
@@ -689,26 +687,16 @@ type QueryResult = {
|
|
|
689
687
|
}[];
|
|
690
688
|
};
|
|
691
689
|
|
|
692
|
-
type QueryOptions = SourceOptions & QuerySourceOptions
|
|
693
|
-
/**
|
|
694
|
-
* @internal
|
|
695
|
-
* @experimental
|
|
696
|
-
* Used to append additional parameters to the SQL API request for features specific to providers or integrations.
|
|
697
|
-
*/
|
|
698
|
-
internalParameters?: Record<string, string | boolean | number>;
|
|
699
|
-
/** Used to abort the request. */
|
|
700
|
-
signal?: AbortSignal;
|
|
701
|
-
};
|
|
690
|
+
type QueryOptions = SourceOptions & QuerySourceOptions;
|
|
702
691
|
declare const query: (options: QueryOptions) => Promise<QueryResult>;
|
|
703
692
|
|
|
704
|
-
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache,
|
|
693
|
+
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
|
|
705
694
|
baseUrl: string;
|
|
706
695
|
parameters?: Record<string, unknown>;
|
|
707
696
|
headers?: Record<string, string>;
|
|
708
697
|
errorContext: APIErrorContext;
|
|
709
698
|
maxLengthURL?: number;
|
|
710
699
|
localCache?: LocalCacheOptions;
|
|
711
|
-
signal?: AbortSignal;
|
|
712
700
|
}): Promise<T>;
|
|
713
701
|
/**
|
|
714
702
|
* Clears the HTTP response cache for all requests using the default cache.
|
|
@@ -1351,7 +1339,7 @@ type FormulaResponse = {
|
|
|
1351
1339
|
};
|
|
1352
1340
|
/** Entry in the category widget response, see {@link WidgetRemoteSource#getCategories}. */
|
|
1353
1341
|
type CategoryResponseEntry = {
|
|
1354
|
-
name: string | null;
|
|
1342
|
+
name: string | number | null;
|
|
1355
1343
|
value: number;
|
|
1356
1344
|
};
|
|
1357
1345
|
/** Response from {@link WidgetRemoteSource#getCategories}. */
|
|
@@ -1469,7 +1457,6 @@ interface ModelSource {
|
|
|
1469
1457
|
spatialDataColumn?: string;
|
|
1470
1458
|
spatialDataType?: SpatialDataType;
|
|
1471
1459
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
1472
|
-
tags?: Record<string, string>;
|
|
1473
1460
|
}
|
|
1474
1461
|
|
|
1475
1462
|
type WidgetRemoteSourceProps = WidgetSourceProps;
|
package/build/api-client.js
CHANGED
|
@@ -5839,8 +5839,7 @@ async function requestWithParameters({
|
|
|
5839
5839
|
headers: customHeaders = {},
|
|
5840
5840
|
errorContext,
|
|
5841
5841
|
maxLengthURL = DEFAULT_MAX_LENGTH_URL,
|
|
5842
|
-
localCache
|
|
5843
|
-
signal
|
|
5842
|
+
localCache
|
|
5844
5843
|
}) {
|
|
5845
5844
|
parameters = {
|
|
5846
5845
|
v: V3_MINOR_VERSION,
|
|
@@ -5863,9 +5862,8 @@ async function requestWithParameters({
|
|
|
5863
5862
|
const fetchPromise = url.length > maxLengthURL ? fetch(baseUrl, {
|
|
5864
5863
|
method: "POST",
|
|
5865
5864
|
body: JSON.stringify(parameters),
|
|
5866
|
-
headers
|
|
5867
|
-
|
|
5868
|
-
}) : fetch(url, { headers, signal });
|
|
5865
|
+
headers
|
|
5866
|
+
}) : fetch(url, { headers });
|
|
5869
5867
|
let response;
|
|
5870
5868
|
let responseJson;
|
|
5871
5869
|
const jsonPromise = fetchPromise.then((_response) => {
|
|
@@ -5917,12 +5915,10 @@ function createURLWithParameters(baseUrlString, parameters) {
|
|
|
5917
5915
|
if (isPureObject(value) || Array.isArray(value)) {
|
|
5918
5916
|
baseUrl.searchParams.set(key, JSON.stringify(value));
|
|
5919
5917
|
} else {
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
);
|
|
5925
|
-
}
|
|
5918
|
+
baseUrl.searchParams.set(
|
|
5919
|
+
key,
|
|
5920
|
+
value.toString()
|
|
5921
|
+
);
|
|
5926
5922
|
}
|
|
5927
5923
|
}
|
|
5928
5924
|
return baseUrl.toString();
|
|
@@ -5966,7 +5962,7 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
5966
5962
|
Authorization: `Bearer ${options.accessToken}`,
|
|
5967
5963
|
...options.headers
|
|
5968
5964
|
};
|
|
5969
|
-
const parameters = { client: clientId, ...
|
|
5965
|
+
const parameters = { client: clientId, ...urlParameters };
|
|
5970
5966
|
const errorContext = {
|
|
5971
5967
|
requestType: "Map instantiation",
|
|
5972
5968
|
connection: options.connectionName,
|
|
@@ -6168,8 +6164,7 @@ function executeModel(props) {
|
|
|
6168
6164
|
filtersLogicalOperator = "and",
|
|
6169
6165
|
spatialDataType = "geo",
|
|
6170
6166
|
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
6171
|
-
spatialFiltersMode = "intersects"
|
|
6172
|
-
tags
|
|
6167
|
+
spatialFiltersMode = "intersects"
|
|
6173
6168
|
} = source;
|
|
6174
6169
|
const queryParams = {
|
|
6175
6170
|
type,
|
|
@@ -6178,8 +6173,7 @@ function executeModel(props) {
|
|
|
6178
6173
|
params,
|
|
6179
6174
|
queryParameters: source.queryParameters || "",
|
|
6180
6175
|
filters,
|
|
6181
|
-
filtersLogicalOperator
|
|
6182
|
-
...tags ?? {}
|
|
6176
|
+
filtersLogicalOperator
|
|
6183
6177
|
};
|
|
6184
6178
|
queryParams.spatialDataType = spatialDataType;
|
|
6185
6179
|
queryParams.spatialDataColumn = spatialDataColumn;
|
|
@@ -6312,8 +6306,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6312
6306
|
filters: getApplicableFilters(filterOwner, filters || props.filters),
|
|
6313
6307
|
filtersLogicalOperator: props.filtersLogicalOperator,
|
|
6314
6308
|
spatialDataType: props.spatialDataType,
|
|
6315
|
-
spatialDataColumn: props.spatialDataColumn
|
|
6316
|
-
tags: props.tags
|
|
6309
|
+
spatialDataColumn: props.spatialDataColumn
|
|
6317
6310
|
};
|
|
6318
6311
|
}
|
|
6319
6312
|
async getCategories(options) {
|
|
@@ -6800,17 +6793,20 @@ function groupValuesByColumn({
|
|
|
6800
6793
|
function getSorter(orderBy) {
|
|
6801
6794
|
switch (orderBy) {
|
|
6802
6795
|
case "frequency_asc":
|
|
6803
|
-
return (a, b) => a.value - b.value ||
|
|
6796
|
+
return (a, b) => a.value - b.value || nameCompare(a.name, b.name);
|
|
6804
6797
|
case "frequency_desc":
|
|
6805
|
-
return (a, b) => b.value - a.value ||
|
|
6798
|
+
return (a, b) => b.value - a.value || nameCompare(a.name, b.name);
|
|
6806
6799
|
case "alphabetical_asc":
|
|
6807
|
-
return (a, b) =>
|
|
6800
|
+
return (a, b) => nameCompare(a.name, b.name) || b.value - a.value;
|
|
6808
6801
|
case "alphabetical_desc":
|
|
6809
|
-
return (a, b) =>
|
|
6802
|
+
return (a, b) => nameCompare(b.name, a.name) || b.value - a.value;
|
|
6810
6803
|
}
|
|
6811
6804
|
}
|
|
6812
|
-
function
|
|
6813
|
-
|
|
6805
|
+
function nameCompare(a, b) {
|
|
6806
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
6807
|
+
return a - b;
|
|
6808
|
+
}
|
|
6809
|
+
return String(a ?? "null").localeCompare(String(b ?? "null"));
|
|
6814
6810
|
}
|
|
6815
6811
|
|
|
6816
6812
|
// src/utils/dateUtils.ts
|
|
@@ -8116,8 +8112,7 @@ var query = async function(options) {
|
|
|
8116
8112
|
localCache,
|
|
8117
8113
|
connectionName,
|
|
8118
8114
|
sqlQuery,
|
|
8119
|
-
queryParameters
|
|
8120
|
-
internalParameters
|
|
8115
|
+
queryParameters
|
|
8121
8116
|
} = options;
|
|
8122
8117
|
const urlParameters = { q: sqlQuery };
|
|
8123
8118
|
if (queryParameters) {
|
|
@@ -8128,12 +8123,7 @@ var query = async function(options) {
|
|
|
8128
8123
|
Authorization: `Bearer ${options.accessToken}`,
|
|
8129
8124
|
...options.headers
|
|
8130
8125
|
};
|
|
8131
|
-
const parameters = {
|
|
8132
|
-
client: clientId,
|
|
8133
|
-
...options.tags,
|
|
8134
|
-
...internalParameters,
|
|
8135
|
-
...urlParameters
|
|
8136
|
-
};
|
|
8126
|
+
const parameters = { client: clientId, ...urlParameters };
|
|
8137
8127
|
const errorContext = {
|
|
8138
8128
|
requestType: "SQL",
|
|
8139
8129
|
connection: options.connectionName,
|
|
@@ -8146,8 +8136,7 @@ var query = async function(options) {
|
|
|
8146
8136
|
headers,
|
|
8147
8137
|
errorContext,
|
|
8148
8138
|
maxLengthURL,
|
|
8149
|
-
localCache
|
|
8150
|
-
signal: options.signal
|
|
8139
|
+
localCache
|
|
8151
8140
|
});
|
|
8152
8141
|
};
|
|
8153
8142
|
|