@carto/api-client 0.5.8 → 0.5.9-alpha.PR193.2
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 +28 -14
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +15 -2
- package/build/api-client.d.ts +15 -2
- package/build/api-client.js +28 -14
- package/build/api-client.js.map +1 -1
- package/package.json +1 -1
- package/src/api/query.ts +19 -2
- package/src/api/request-with-parameters.ts +10 -5
- package/src/models/model.ts +3 -0
- package/src/sources/base-source.ts +1 -1
- package/src/sources/types.ts +3 -0
- package/src/widget-sources/widget-remote-source.ts +1 -0
package/build/api-client.d.cts
CHANGED
|
@@ -388,6 +388,8 @@ 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>;
|
|
391
393
|
};
|
|
392
394
|
type LocalCacheOptions = {
|
|
393
395
|
/**
|
|
@@ -687,16 +689,26 @@ type QueryResult = {
|
|
|
687
689
|
}[];
|
|
688
690
|
};
|
|
689
691
|
|
|
690
|
-
type QueryOptions = SourceOptions & QuerySourceOptions
|
|
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
|
+
};
|
|
691
702
|
declare const query: (options: QueryOptions) => Promise<QueryResult>;
|
|
692
703
|
|
|
693
|
-
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
|
|
704
|
+
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, }: {
|
|
694
705
|
baseUrl: string;
|
|
695
706
|
parameters?: Record<string, unknown>;
|
|
696
707
|
headers?: Record<string, string>;
|
|
697
708
|
errorContext: APIErrorContext;
|
|
698
709
|
maxLengthURL?: number;
|
|
699
710
|
localCache?: LocalCacheOptions;
|
|
711
|
+
signal?: AbortSignal;
|
|
700
712
|
}): Promise<T>;
|
|
701
713
|
/**
|
|
702
714
|
* Clears the HTTP response cache for all requests using the default cache.
|
|
@@ -1450,6 +1462,7 @@ interface ModelSource {
|
|
|
1450
1462
|
spatialDataColumn?: string;
|
|
1451
1463
|
spatialDataType?: SpatialDataType;
|
|
1452
1464
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
1465
|
+
tags?: Record<string, string>;
|
|
1453
1466
|
}
|
|
1454
1467
|
|
|
1455
1468
|
type WidgetRemoteSourceProps = WidgetSourceProps;
|
package/build/api-client.d.ts
CHANGED
|
@@ -388,6 +388,8 @@ 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>;
|
|
391
393
|
};
|
|
392
394
|
type LocalCacheOptions = {
|
|
393
395
|
/**
|
|
@@ -687,16 +689,26 @@ type QueryResult = {
|
|
|
687
689
|
}[];
|
|
688
690
|
};
|
|
689
691
|
|
|
690
|
-
type QueryOptions = SourceOptions & QuerySourceOptions
|
|
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
|
+
};
|
|
691
702
|
declare const query: (options: QueryOptions) => Promise<QueryResult>;
|
|
692
703
|
|
|
693
|
-
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
|
|
704
|
+
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, }: {
|
|
694
705
|
baseUrl: string;
|
|
695
706
|
parameters?: Record<string, unknown>;
|
|
696
707
|
headers?: Record<string, string>;
|
|
697
708
|
errorContext: APIErrorContext;
|
|
698
709
|
maxLengthURL?: number;
|
|
699
710
|
localCache?: LocalCacheOptions;
|
|
711
|
+
signal?: AbortSignal;
|
|
700
712
|
}): Promise<T>;
|
|
701
713
|
/**
|
|
702
714
|
* Clears the HTTP response cache for all requests using the default cache.
|
|
@@ -1450,6 +1462,7 @@ interface ModelSource {
|
|
|
1450
1462
|
spatialDataColumn?: string;
|
|
1451
1463
|
spatialDataType?: SpatialDataType;
|
|
1452
1464
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
1465
|
+
tags?: Record<string, string>;
|
|
1453
1466
|
}
|
|
1454
1467
|
|
|
1455
1468
|
type WidgetRemoteSourceProps = WidgetSourceProps;
|
package/build/api-client.js
CHANGED
|
@@ -5839,7 +5839,8 @@ async function requestWithParameters({
|
|
|
5839
5839
|
headers: customHeaders = {},
|
|
5840
5840
|
errorContext,
|
|
5841
5841
|
maxLengthURL = DEFAULT_MAX_LENGTH_URL,
|
|
5842
|
-
localCache
|
|
5842
|
+
localCache,
|
|
5843
|
+
signal
|
|
5843
5844
|
}) {
|
|
5844
5845
|
parameters = {
|
|
5845
5846
|
v: V3_MINOR_VERSION,
|
|
@@ -5862,8 +5863,9 @@ async function requestWithParameters({
|
|
|
5862
5863
|
const fetchPromise = url.length > maxLengthURL ? fetch(baseUrl, {
|
|
5863
5864
|
method: "POST",
|
|
5864
5865
|
body: JSON.stringify(parameters),
|
|
5865
|
-
headers
|
|
5866
|
-
|
|
5866
|
+
headers,
|
|
5867
|
+
signal
|
|
5868
|
+
}) : fetch(url, { headers, signal });
|
|
5867
5869
|
let response;
|
|
5868
5870
|
let responseJson;
|
|
5869
5871
|
const jsonPromise = fetchPromise.then((_response) => {
|
|
@@ -5915,10 +5917,12 @@ function createURLWithParameters(baseUrlString, parameters) {
|
|
|
5915
5917
|
if (isPureObject(value) || Array.isArray(value)) {
|
|
5916
5918
|
baseUrl.searchParams.set(key, JSON.stringify(value));
|
|
5917
5919
|
} else {
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5920
|
+
if (value !== null && value !== void 0) {
|
|
5921
|
+
baseUrl.searchParams.set(
|
|
5922
|
+
key,
|
|
5923
|
+
value.toString()
|
|
5924
|
+
);
|
|
5925
|
+
}
|
|
5922
5926
|
}
|
|
5923
5927
|
}
|
|
5924
5928
|
return baseUrl.toString();
|
|
@@ -5962,7 +5966,7 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
5962
5966
|
Authorization: `Bearer ${options.accessToken}`,
|
|
5963
5967
|
...options.headers
|
|
5964
5968
|
};
|
|
5965
|
-
const parameters = { client: clientId, ...urlParameters };
|
|
5969
|
+
const parameters = { client: clientId, ...options.tags, ...urlParameters };
|
|
5966
5970
|
const errorContext = {
|
|
5967
5971
|
requestType: "Map instantiation",
|
|
5968
5972
|
connection: options.connectionName,
|
|
@@ -6164,7 +6168,8 @@ function executeModel(props) {
|
|
|
6164
6168
|
filtersLogicalOperator = "and",
|
|
6165
6169
|
spatialDataType = "geo",
|
|
6166
6170
|
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
6167
|
-
spatialFiltersMode = "intersects"
|
|
6171
|
+
spatialFiltersMode = "intersects",
|
|
6172
|
+
tags
|
|
6168
6173
|
} = source;
|
|
6169
6174
|
const queryParams = {
|
|
6170
6175
|
type,
|
|
@@ -6173,7 +6178,8 @@ function executeModel(props) {
|
|
|
6173
6178
|
params,
|
|
6174
6179
|
queryParameters: source.queryParameters || "",
|
|
6175
6180
|
filters,
|
|
6176
|
-
filtersLogicalOperator
|
|
6181
|
+
filtersLogicalOperator,
|
|
6182
|
+
tags
|
|
6177
6183
|
};
|
|
6178
6184
|
queryParams.spatialDataType = spatialDataType;
|
|
6179
6185
|
queryParams.spatialDataColumn = spatialDataColumn;
|
|
@@ -6306,7 +6312,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6306
6312
|
filters: getApplicableFilters(filterOwner, filters || props.filters),
|
|
6307
6313
|
filtersLogicalOperator: props.filtersLogicalOperator,
|
|
6308
6314
|
spatialDataType: props.spatialDataType,
|
|
6309
|
-
spatialDataColumn: props.spatialDataColumn
|
|
6315
|
+
spatialDataColumn: props.spatialDataColumn,
|
|
6316
|
+
tags: props.tags
|
|
6310
6317
|
};
|
|
6311
6318
|
}
|
|
6312
6319
|
async getCategories(options) {
|
|
@@ -8083,7 +8090,8 @@ var query = async function(options) {
|
|
|
8083
8090
|
localCache,
|
|
8084
8091
|
connectionName,
|
|
8085
8092
|
sqlQuery,
|
|
8086
|
-
queryParameters
|
|
8093
|
+
queryParameters,
|
|
8094
|
+
internalParameters
|
|
8087
8095
|
} = options;
|
|
8088
8096
|
const urlParameters = { q: sqlQuery };
|
|
8089
8097
|
if (queryParameters) {
|
|
@@ -8094,7 +8102,12 @@ var query = async function(options) {
|
|
|
8094
8102
|
Authorization: `Bearer ${options.accessToken}`,
|
|
8095
8103
|
...options.headers
|
|
8096
8104
|
};
|
|
8097
|
-
const parameters = {
|
|
8105
|
+
const parameters = {
|
|
8106
|
+
client: clientId,
|
|
8107
|
+
...options.tags,
|
|
8108
|
+
...internalParameters,
|
|
8109
|
+
...urlParameters
|
|
8110
|
+
};
|
|
8098
8111
|
const errorContext = {
|
|
8099
8112
|
requestType: "SQL",
|
|
8100
8113
|
connection: options.connectionName,
|
|
@@ -8107,7 +8120,8 @@ var query = async function(options) {
|
|
|
8107
8120
|
headers,
|
|
8108
8121
|
errorContext,
|
|
8109
8122
|
maxLengthURL,
|
|
8110
|
-
localCache
|
|
8123
|
+
localCache,
|
|
8124
|
+
signal: options.signal
|
|
8111
8125
|
});
|
|
8112
8126
|
};
|
|
8113
8127
|
|