@carto/api-client 0.5.9 → 0.5.10-alpha.PR193.4

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.
@@ -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.
@@ -1457,6 +1469,7 @@ interface ModelSource {
1457
1469
  spatialDataColumn?: string;
1458
1470
  spatialDataType?: SpatialDataType;
1459
1471
  spatialFiltersMode?: SpatialFilterPolyfillMode;
1472
+ tags?: Record<string, string>;
1460
1473
  }
1461
1474
 
1462
1475
  type WidgetRemoteSourceProps = WidgetSourceProps;
@@ -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.
@@ -1457,6 +1469,7 @@ interface ModelSource {
1457
1469
  spatialDataColumn?: string;
1458
1470
  spatialDataType?: SpatialDataType;
1459
1471
  spatialFiltersMode?: SpatialFilterPolyfillMode;
1472
+ tags?: Record<string, string>;
1460
1473
  }
1461
1474
 
1462
1475
  type WidgetRemoteSourceProps = WidgetSourceProps;
@@ -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
- }) : fetch(url, { headers });
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
- baseUrl.searchParams.set(
5919
- key,
5920
- value.toString()
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) {
@@ -8109,7 +8116,8 @@ var query = async function(options) {
8109
8116
  localCache,
8110
8117
  connectionName,
8111
8118
  sqlQuery,
8112
- queryParameters
8119
+ queryParameters,
8120
+ internalParameters
8113
8121
  } = options;
8114
8122
  const urlParameters = { q: sqlQuery };
8115
8123
  if (queryParameters) {
@@ -8120,7 +8128,12 @@ var query = async function(options) {
8120
8128
  Authorization: `Bearer ${options.accessToken}`,
8121
8129
  ...options.headers
8122
8130
  };
8123
- const parameters = { client: clientId, ...urlParameters };
8131
+ const parameters = {
8132
+ client: clientId,
8133
+ ...options.tags,
8134
+ ...internalParameters,
8135
+ ...urlParameters
8136
+ };
8124
8137
  const errorContext = {
8125
8138
  requestType: "SQL",
8126
8139
  connection: options.connectionName,
@@ -8133,7 +8146,8 @@ var query = async function(options) {
8133
8146
  headers,
8134
8147
  errorContext,
8135
8148
  maxLengthURL,
8136
- localCache
8149
+ localCache,
8150
+ signal: options.signal
8137
8151
  });
8138
8152
  };
8139
8153