@carto/api-client 0.5.8 → 0.5.9-alpha.PR193.1

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.
@@ -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;
@@ -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;
@@ -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) => {
@@ -5962,7 +5964,7 @@ async function baseSource(endpoint, options, urlParameters) {
5962
5964
  Authorization: `Bearer ${options.accessToken}`,
5963
5965
  ...options.headers
5964
5966
  };
5965
- const parameters = { client: clientId, ...urlParameters };
5967
+ const parameters = { client: clientId, ...options.tags, ...urlParameters };
5966
5968
  const errorContext = {
5967
5969
  requestType: "Map instantiation",
5968
5970
  connection: options.connectionName,
@@ -6164,7 +6166,8 @@ function executeModel(props) {
6164
6166
  filtersLogicalOperator = "and",
6165
6167
  spatialDataType = "geo",
6166
6168
  spatialDataColumn = DEFAULT_GEO_COLUMN,
6167
- spatialFiltersMode = "intersects"
6169
+ spatialFiltersMode = "intersects",
6170
+ tags
6168
6171
  } = source;
6169
6172
  const queryParams = {
6170
6173
  type,
@@ -6173,7 +6176,8 @@ function executeModel(props) {
6173
6176
  params,
6174
6177
  queryParameters: source.queryParameters || "",
6175
6178
  filters,
6176
- filtersLogicalOperator
6179
+ filtersLogicalOperator,
6180
+ tags
6177
6181
  };
6178
6182
  queryParams.spatialDataType = spatialDataType;
6179
6183
  queryParams.spatialDataColumn = spatialDataColumn;
@@ -6306,7 +6310,8 @@ var WidgetRemoteSource = class extends WidgetSource {
6306
6310
  filters: getApplicableFilters(filterOwner, filters || props.filters),
6307
6311
  filtersLogicalOperator: props.filtersLogicalOperator,
6308
6312
  spatialDataType: props.spatialDataType,
6309
- spatialDataColumn: props.spatialDataColumn
6313
+ spatialDataColumn: props.spatialDataColumn,
6314
+ tags: props.tags
6310
6315
  };
6311
6316
  }
6312
6317
  async getCategories(options) {
@@ -8083,7 +8088,8 @@ var query = async function(options) {
8083
8088
  localCache,
8084
8089
  connectionName,
8085
8090
  sqlQuery,
8086
- queryParameters
8091
+ queryParameters,
8092
+ internalParameters
8087
8093
  } = options;
8088
8094
  const urlParameters = { q: sqlQuery };
8089
8095
  if (queryParameters) {
@@ -8094,7 +8100,12 @@ var query = async function(options) {
8094
8100
  Authorization: `Bearer ${options.accessToken}`,
8095
8101
  ...options.headers
8096
8102
  };
8097
- const parameters = { client: clientId, ...urlParameters };
8103
+ const parameters = {
8104
+ client: clientId,
8105
+ ...options.tags,
8106
+ ...internalParameters,
8107
+ ...urlParameters
8108
+ };
8098
8109
  const errorContext = {
8099
8110
  requestType: "SQL",
8100
8111
  connection: options.connectionName,
@@ -8107,7 +8118,8 @@ var query = async function(options) {
8107
8118
  headers,
8108
8119
  errorContext,
8109
8120
  maxLengthURL,
8110
- localCache
8121
+ localCache,
8122
+ signal: options.signal
8111
8123
  });
8112
8124
  };
8113
8125