@carto/api-client 0.5.10 → 0.5.12

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
  /**
@@ -523,7 +525,7 @@ interface Tilejson {
523
525
  minzoom: number;
524
526
  maxzoom: number;
525
527
  bounds: [left: number, bottom: number, right: number, top: number];
526
- center: [longitute: number, latitude: number, zoom: number];
528
+ center: [longitude: number, latitude: number, zoom: number];
527
529
  vector_layers: VectorLayer[];
528
530
  minresolution: number;
529
531
  maxresolution: number;
@@ -635,6 +637,11 @@ type RasterMetadataBand = {
635
637
  type: RasterBandType;
636
638
  name: string;
637
639
  stats: RasterMetadataBandStats;
640
+ /**
641
+ * Optional table of mappings from (integer) band values to (string) human
642
+ * readable labels. Values found in tiles are NOT guaranteed to have labels.
643
+ */
644
+ valuelabels?: Record<string, string>;
638
645
  /**
639
646
  * Known values:
640
647
  * * `palette`: use unique value and `colortable` ad default mapping
@@ -658,10 +665,11 @@ type RasterMetadata = {
658
665
  block_resolution: number;
659
666
  minresolution: number;
660
667
  maxresolution: number;
668
+ /** @deprecated Use {@link RasterMetadataBand.nodata} from {@link RasterMetadata.bands}. */
661
669
  nodata: number | string;
662
670
  bands: RasterMetadataBand[];
663
671
  bounds: [left: number, bottom: number, right: number, top: number];
664
- center: [longitute: number, latitude: number, zoom: number];
672
+ center: [longitude: number, latitude: number, zoom: number];
665
673
  width: number;
666
674
  height: number;
667
675
  block_width: number;
@@ -687,16 +695,26 @@ type QueryResult = {
687
695
  }[];
688
696
  };
689
697
 
690
- type QueryOptions = SourceOptions & QuerySourceOptions;
698
+ type QueryOptions = SourceOptions & QuerySourceOptions & {
699
+ /**
700
+ * @internal
701
+ * @experimental
702
+ * Used to append additional parameters to the SQL API request for features specific to providers or integrations.
703
+ */
704
+ internalParameters?: Record<string, string | boolean | number>;
705
+ /** Used to abort the request. */
706
+ signal?: AbortSignal;
707
+ };
691
708
  declare const query: (options: QueryOptions) => Promise<QueryResult>;
692
709
 
693
- declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
710
+ declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, }: {
694
711
  baseUrl: string;
695
712
  parameters?: Record<string, unknown>;
696
713
  headers?: Record<string, string>;
697
714
  errorContext: APIErrorContext;
698
715
  maxLengthURL?: number;
699
716
  localCache?: LocalCacheOptions;
717
+ signal?: AbortSignal;
700
718
  }): Promise<T>;
701
719
  /**
702
720
  * Clears the HTTP response cache for all requests using the default cache.
@@ -1457,6 +1475,7 @@ interface ModelSource {
1457
1475
  spatialDataColumn?: string;
1458
1476
  spatialDataType?: SpatialDataType;
1459
1477
  spatialFiltersMode?: SpatialFilterPolyfillMode;
1478
+ tags?: Record<string, string>;
1460
1479
  }
1461
1480
 
1462
1481
  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
  /**
@@ -523,7 +525,7 @@ interface Tilejson {
523
525
  minzoom: number;
524
526
  maxzoom: number;
525
527
  bounds: [left: number, bottom: number, right: number, top: number];
526
- center: [longitute: number, latitude: number, zoom: number];
528
+ center: [longitude: number, latitude: number, zoom: number];
527
529
  vector_layers: VectorLayer[];
528
530
  minresolution: number;
529
531
  maxresolution: number;
@@ -635,6 +637,11 @@ type RasterMetadataBand = {
635
637
  type: RasterBandType;
636
638
  name: string;
637
639
  stats: RasterMetadataBandStats;
640
+ /**
641
+ * Optional table of mappings from (integer) band values to (string) human
642
+ * readable labels. Values found in tiles are NOT guaranteed to have labels.
643
+ */
644
+ valuelabels?: Record<string, string>;
638
645
  /**
639
646
  * Known values:
640
647
  * * `palette`: use unique value and `colortable` ad default mapping
@@ -658,10 +665,11 @@ type RasterMetadata = {
658
665
  block_resolution: number;
659
666
  minresolution: number;
660
667
  maxresolution: number;
668
+ /** @deprecated Use {@link RasterMetadataBand.nodata} from {@link RasterMetadata.bands}. */
661
669
  nodata: number | string;
662
670
  bands: RasterMetadataBand[];
663
671
  bounds: [left: number, bottom: number, right: number, top: number];
664
- center: [longitute: number, latitude: number, zoom: number];
672
+ center: [longitude: number, latitude: number, zoom: number];
665
673
  width: number;
666
674
  height: number;
667
675
  block_width: number;
@@ -687,16 +695,26 @@ type QueryResult = {
687
695
  }[];
688
696
  };
689
697
 
690
- type QueryOptions = SourceOptions & QuerySourceOptions;
698
+ type QueryOptions = SourceOptions & QuerySourceOptions & {
699
+ /**
700
+ * @internal
701
+ * @experimental
702
+ * Used to append additional parameters to the SQL API request for features specific to providers or integrations.
703
+ */
704
+ internalParameters?: Record<string, string | boolean | number>;
705
+ /** Used to abort the request. */
706
+ signal?: AbortSignal;
707
+ };
691
708
  declare const query: (options: QueryOptions) => Promise<QueryResult>;
692
709
 
693
- declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
710
+ declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, }: {
694
711
  baseUrl: string;
695
712
  parameters?: Record<string, unknown>;
696
713
  headers?: Record<string, string>;
697
714
  errorContext: APIErrorContext;
698
715
  maxLengthURL?: number;
699
716
  localCache?: LocalCacheOptions;
717
+ signal?: AbortSignal;
700
718
  }): Promise<T>;
701
719
  /**
702
720
  * Clears the HTTP response cache for all requests using the default cache.
@@ -1457,6 +1475,7 @@ interface ModelSource {
1457
1475
  spatialDataColumn?: string;
1458
1476
  spatialDataType?: SpatialDataType;
1459
1477
  spatialFiltersMode?: SpatialFilterPolyfillMode;
1478
+ tags?: Record<string, string>;
1460
1479
  }
1461
1480
 
1462
1481
  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) {
@@ -8112,7 +8119,8 @@ var query = async function(options) {
8112
8119
  localCache,
8113
8120
  connectionName,
8114
8121
  sqlQuery,
8115
- queryParameters
8122
+ queryParameters,
8123
+ internalParameters
8116
8124
  } = options;
8117
8125
  const urlParameters = { q: sqlQuery };
8118
8126
  if (queryParameters) {
@@ -8123,7 +8131,12 @@ var query = async function(options) {
8123
8131
  Authorization: `Bearer ${options.accessToken}`,
8124
8132
  ...options.headers
8125
8133
  };
8126
- const parameters = { client: clientId, ...urlParameters };
8134
+ const parameters = {
8135
+ client: clientId,
8136
+ ...options.tags,
8137
+ ...internalParameters,
8138
+ ...urlParameters
8139
+ };
8127
8140
  const errorContext = {
8128
8141
  requestType: "SQL",
8129
8142
  connection: options.connectionName,
@@ -8136,7 +8149,8 @@ var query = async function(options) {
8136
8149
  headers,
8137
8150
  errorContext,
8138
8151
  maxLengthURL,
8139
- localCache
8152
+ localCache,
8153
+ signal: options.signal
8140
8154
  });
8141
8155
  };
8142
8156