@carto/api-client 0.5.11 → 0.5.13
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 +6 -0
- package/build/api-client.cjs +42 -14
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +24 -10
- package/build/api-client.d.ts +24 -10
- package/build/api-client.js +40 -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/constants.ts +8 -0
- package/src/sources/index.ts +1 -1
- package/src/sources/types.ts +4 -9
- package/src/widget-sources/widget-remote-source.ts +1 -0
package/build/api-client.d.cts
CHANGED
|
@@ -325,6 +325,15 @@ declare function buildStatsUrl({ attribute, apiBaseUrl, connectionName, source,
|
|
|
325
325
|
type: MapType;
|
|
326
326
|
}): string;
|
|
327
327
|
|
|
328
|
+
declare enum RasterBandColorinterp {
|
|
329
|
+
Gray = "gray",
|
|
330
|
+
Red = "red",
|
|
331
|
+
Green = "green",
|
|
332
|
+
Blue = "blue",
|
|
333
|
+
Alpha = "alpha",
|
|
334
|
+
Palette = "palette"
|
|
335
|
+
}
|
|
336
|
+
|
|
328
337
|
type SourceRequiredOptions = {
|
|
329
338
|
/** Carto platform access token. */
|
|
330
339
|
accessToken: string;
|
|
@@ -388,6 +397,8 @@ type SourceOptionalOptions = {
|
|
|
388
397
|
* By default, local in-memory caching is enabled.
|
|
389
398
|
*/
|
|
390
399
|
localCache?: LocalCacheOptions;
|
|
400
|
+
/** Additional tags appended to HTTP requests, available for analytics and audits. */
|
|
401
|
+
tags?: Record<string, string>;
|
|
391
402
|
};
|
|
392
403
|
type LocalCacheOptions = {
|
|
393
404
|
/**
|
|
@@ -622,14 +633,6 @@ type RasterMetadataBandStats = {
|
|
|
622
633
|
*/
|
|
623
634
|
version?: string;
|
|
624
635
|
};
|
|
625
|
-
declare enum RasterBandColorinterp {
|
|
626
|
-
Gray = "gray",
|
|
627
|
-
Red = "red",
|
|
628
|
-
Green = "green",
|
|
629
|
-
Blue = "blue",
|
|
630
|
-
Alpha = "alpha",
|
|
631
|
-
Palette = "palette"
|
|
632
|
-
}
|
|
633
636
|
type RasterBandType = 'uint8' | 'int8' | 'uint16' | 'int16' | 'uint32' | 'int32' | 'uint64' | 'int64' | 'float32' | 'float64';
|
|
634
637
|
type RasterMetadataBand = {
|
|
635
638
|
type: RasterBandType;
|
|
@@ -693,16 +696,26 @@ type QueryResult = {
|
|
|
693
696
|
}[];
|
|
694
697
|
};
|
|
695
698
|
|
|
696
|
-
type QueryOptions = SourceOptions & QuerySourceOptions
|
|
699
|
+
type QueryOptions = SourceOptions & QuerySourceOptions & {
|
|
700
|
+
/**
|
|
701
|
+
* @internal
|
|
702
|
+
* @experimental
|
|
703
|
+
* Used to append additional parameters to the SQL API request for features specific to providers or integrations.
|
|
704
|
+
*/
|
|
705
|
+
internalParameters?: Record<string, string | boolean | number>;
|
|
706
|
+
/** Used to abort the request. */
|
|
707
|
+
signal?: AbortSignal;
|
|
708
|
+
};
|
|
697
709
|
declare const query: (options: QueryOptions) => Promise<QueryResult>;
|
|
698
710
|
|
|
699
|
-
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
|
|
711
|
+
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, }: {
|
|
700
712
|
baseUrl: string;
|
|
701
713
|
parameters?: Record<string, unknown>;
|
|
702
714
|
headers?: Record<string, string>;
|
|
703
715
|
errorContext: APIErrorContext;
|
|
704
716
|
maxLengthURL?: number;
|
|
705
717
|
localCache?: LocalCacheOptions;
|
|
718
|
+
signal?: AbortSignal;
|
|
706
719
|
}): Promise<T>;
|
|
707
720
|
/**
|
|
708
721
|
* Clears the HTTP response cache for all requests using the default cache.
|
|
@@ -1463,6 +1476,7 @@ interface ModelSource {
|
|
|
1463
1476
|
spatialDataColumn?: string;
|
|
1464
1477
|
spatialDataType?: SpatialDataType;
|
|
1465
1478
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
1479
|
+
tags?: Record<string, string>;
|
|
1466
1480
|
}
|
|
1467
1481
|
|
|
1468
1482
|
type WidgetRemoteSourceProps = WidgetSourceProps;
|
package/build/api-client.d.ts
CHANGED
|
@@ -325,6 +325,15 @@ declare function buildStatsUrl({ attribute, apiBaseUrl, connectionName, source,
|
|
|
325
325
|
type: MapType;
|
|
326
326
|
}): string;
|
|
327
327
|
|
|
328
|
+
declare enum RasterBandColorinterp {
|
|
329
|
+
Gray = "gray",
|
|
330
|
+
Red = "red",
|
|
331
|
+
Green = "green",
|
|
332
|
+
Blue = "blue",
|
|
333
|
+
Alpha = "alpha",
|
|
334
|
+
Palette = "palette"
|
|
335
|
+
}
|
|
336
|
+
|
|
328
337
|
type SourceRequiredOptions = {
|
|
329
338
|
/** Carto platform access token. */
|
|
330
339
|
accessToken: string;
|
|
@@ -388,6 +397,8 @@ type SourceOptionalOptions = {
|
|
|
388
397
|
* By default, local in-memory caching is enabled.
|
|
389
398
|
*/
|
|
390
399
|
localCache?: LocalCacheOptions;
|
|
400
|
+
/** Additional tags appended to HTTP requests, available for analytics and audits. */
|
|
401
|
+
tags?: Record<string, string>;
|
|
391
402
|
};
|
|
392
403
|
type LocalCacheOptions = {
|
|
393
404
|
/**
|
|
@@ -622,14 +633,6 @@ type RasterMetadataBandStats = {
|
|
|
622
633
|
*/
|
|
623
634
|
version?: string;
|
|
624
635
|
};
|
|
625
|
-
declare enum RasterBandColorinterp {
|
|
626
|
-
Gray = "gray",
|
|
627
|
-
Red = "red",
|
|
628
|
-
Green = "green",
|
|
629
|
-
Blue = "blue",
|
|
630
|
-
Alpha = "alpha",
|
|
631
|
-
Palette = "palette"
|
|
632
|
-
}
|
|
633
636
|
type RasterBandType = 'uint8' | 'int8' | 'uint16' | 'int16' | 'uint32' | 'int32' | 'uint64' | 'int64' | 'float32' | 'float64';
|
|
634
637
|
type RasterMetadataBand = {
|
|
635
638
|
type: RasterBandType;
|
|
@@ -693,16 +696,26 @@ type QueryResult = {
|
|
|
693
696
|
}[];
|
|
694
697
|
};
|
|
695
698
|
|
|
696
|
-
type QueryOptions = SourceOptions & QuerySourceOptions
|
|
699
|
+
type QueryOptions = SourceOptions & QuerySourceOptions & {
|
|
700
|
+
/**
|
|
701
|
+
* @internal
|
|
702
|
+
* @experimental
|
|
703
|
+
* Used to append additional parameters to the SQL API request for features specific to providers or integrations.
|
|
704
|
+
*/
|
|
705
|
+
internalParameters?: Record<string, string | boolean | number>;
|
|
706
|
+
/** Used to abort the request. */
|
|
707
|
+
signal?: AbortSignal;
|
|
708
|
+
};
|
|
697
709
|
declare const query: (options: QueryOptions) => Promise<QueryResult>;
|
|
698
710
|
|
|
699
|
-
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
|
|
711
|
+
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, }: {
|
|
700
712
|
baseUrl: string;
|
|
701
713
|
parameters?: Record<string, unknown>;
|
|
702
714
|
headers?: Record<string, string>;
|
|
703
715
|
errorContext: APIErrorContext;
|
|
704
716
|
maxLengthURL?: number;
|
|
705
717
|
localCache?: LocalCacheOptions;
|
|
718
|
+
signal?: AbortSignal;
|
|
706
719
|
}): Promise<T>;
|
|
707
720
|
/**
|
|
708
721
|
* Clears the HTTP response cache for all requests using the default cache.
|
|
@@ -1463,6 +1476,7 @@ interface ModelSource {
|
|
|
1463
1476
|
spatialDataColumn?: string;
|
|
1464
1477
|
spatialDataType?: SpatialDataType;
|
|
1465
1478
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
1479
|
+
tags?: Record<string, string>;
|
|
1466
1480
|
}
|
|
1467
1481
|
|
|
1468
1482
|
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,
|
|
@@ -6002,6 +6006,17 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
6002
6006
|
return json;
|
|
6003
6007
|
}
|
|
6004
6008
|
|
|
6009
|
+
// src/sources/constants.ts
|
|
6010
|
+
var RasterBandColorinterp = /* @__PURE__ */ ((RasterBandColorinterp2) => {
|
|
6011
|
+
RasterBandColorinterp2["Gray"] = "gray";
|
|
6012
|
+
RasterBandColorinterp2["Red"] = "red";
|
|
6013
|
+
RasterBandColorinterp2["Green"] = "green";
|
|
6014
|
+
RasterBandColorinterp2["Blue"] = "blue";
|
|
6015
|
+
RasterBandColorinterp2["Alpha"] = "alpha";
|
|
6016
|
+
RasterBandColorinterp2["Palette"] = "palette";
|
|
6017
|
+
return RasterBandColorinterp2;
|
|
6018
|
+
})(RasterBandColorinterp || {});
|
|
6019
|
+
|
|
6005
6020
|
// src/sources/boundary-query-source.ts
|
|
6006
6021
|
var boundaryQuerySource = async function(options) {
|
|
6007
6022
|
const {
|
|
@@ -6164,7 +6179,8 @@ function executeModel(props) {
|
|
|
6164
6179
|
filtersLogicalOperator = "and",
|
|
6165
6180
|
spatialDataType = "geo",
|
|
6166
6181
|
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
6167
|
-
spatialFiltersMode = "intersects"
|
|
6182
|
+
spatialFiltersMode = "intersects",
|
|
6183
|
+
tags
|
|
6168
6184
|
} = source;
|
|
6169
6185
|
const queryParams = {
|
|
6170
6186
|
type,
|
|
@@ -6173,7 +6189,8 @@ function executeModel(props) {
|
|
|
6173
6189
|
params,
|
|
6174
6190
|
queryParameters: source.queryParameters || "",
|
|
6175
6191
|
filters,
|
|
6176
|
-
filtersLogicalOperator
|
|
6192
|
+
filtersLogicalOperator,
|
|
6193
|
+
...tags ?? {}
|
|
6177
6194
|
};
|
|
6178
6195
|
queryParams.spatialDataType = spatialDataType;
|
|
6179
6196
|
queryParams.spatialDataColumn = spatialDataColumn;
|
|
@@ -6306,7 +6323,8 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6306
6323
|
filters: getApplicableFilters(filterOwner, filters || props.filters),
|
|
6307
6324
|
filtersLogicalOperator: props.filtersLogicalOperator,
|
|
6308
6325
|
spatialDataType: props.spatialDataType,
|
|
6309
|
-
spatialDataColumn: props.spatialDataColumn
|
|
6326
|
+
spatialDataColumn: props.spatialDataColumn,
|
|
6327
|
+
tags: props.tags
|
|
6310
6328
|
};
|
|
6311
6329
|
}
|
|
6312
6330
|
async getCategories(options) {
|
|
@@ -8112,7 +8130,8 @@ var query = async function(options) {
|
|
|
8112
8130
|
localCache,
|
|
8113
8131
|
connectionName,
|
|
8114
8132
|
sqlQuery,
|
|
8115
|
-
queryParameters
|
|
8133
|
+
queryParameters,
|
|
8134
|
+
internalParameters
|
|
8116
8135
|
} = options;
|
|
8117
8136
|
const urlParameters = { q: sqlQuery };
|
|
8118
8137
|
if (queryParameters) {
|
|
@@ -8123,7 +8142,12 @@ var query = async function(options) {
|
|
|
8123
8142
|
Authorization: `Bearer ${options.accessToken}`,
|
|
8124
8143
|
...options.headers
|
|
8125
8144
|
};
|
|
8126
|
-
const parameters = {
|
|
8145
|
+
const parameters = {
|
|
8146
|
+
client: clientId,
|
|
8147
|
+
...options.tags,
|
|
8148
|
+
...internalParameters,
|
|
8149
|
+
...urlParameters
|
|
8150
|
+
};
|
|
8127
8151
|
const errorContext = {
|
|
8128
8152
|
requestType: "SQL",
|
|
8129
8153
|
connection: options.connectionName,
|
|
@@ -8136,7 +8160,8 @@ var query = async function(options) {
|
|
|
8136
8160
|
headers,
|
|
8137
8161
|
errorContext,
|
|
8138
8162
|
maxLengthURL,
|
|
8139
|
-
localCache
|
|
8163
|
+
localCache,
|
|
8164
|
+
signal: options.signal
|
|
8140
8165
|
});
|
|
8141
8166
|
};
|
|
8142
8167
|
|
|
@@ -10149,6 +10174,7 @@ export {
|
|
|
10149
10174
|
OPACITY_MAP,
|
|
10150
10175
|
OTHERS_CATEGORY_NAME,
|
|
10151
10176
|
Provider,
|
|
10177
|
+
RasterBandColorinterp,
|
|
10152
10178
|
SOURCE_DEFAULTS,
|
|
10153
10179
|
SchemaFieldType,
|
|
10154
10180
|
SpatialIndex,
|