@carto/api-client 0.5.30-alpha.b195e7f.118 → 0.5.30

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.
@@ -187,21 +187,13 @@ type AggregationType = 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
187
187
  /** A spatial filter expressed as a GeoJSON polygon, applied client- or server-side. */
188
188
  type GeometrySpatialFilter = Polygon | MultiPolygon;
189
189
  /**
190
- * Filter restricting a widget query to a set of spatial-index cells (H3 or
191
- * Quadbin). Used for point-and-click selection on cell-rendered layers. Sent to
192
- * the server-side model API only; maps-api chooses the SQL strategy from
193
- * `spatialDataType`, so the same payload works for both natively-indexed
194
- * sources and point/geometry sources dynamically aggregated into cells.
195
- *
196
- * @privateRemarks Source: @carto/query-builder (SpatialIndexFilter)
190
+ * Filter restricting a widget query to a selection of spatial-index cells,
191
+ * e.g. from point-and-click on an H3 or Quadbin layer.
197
192
  */
198
193
  interface SpatialIndexFilter {
199
- /**
200
- * Selected cell ids. h3 = hex string; h3int = `BigInt(\`0x${id}\`)`; quadbin
201
- * = decimal or `0x`-hex string.
202
- */
194
+ /** Selected cell ids. */
203
195
  indexes: string[];
204
- /** Must match the column type; `h3` and `h3int` are interchangeable. */
196
+ /** Spatial index type of the filtered column. */
205
197
  type: 'h3' | 'h3int' | 'quadbin';
206
198
  }
207
199
  /** @privateRemarks Source: @carto/react-api */
@@ -311,6 +303,54 @@ type _DataFilterExtensionProps = {
311
303
  */
312
304
  declare function getDataFilterExtensionProps(filters: Filters, filtersLogicalOperator?: FilterLogicalOperator): _DataFilterExtensionProps;
313
305
 
306
+ /**
307
+ * How requests to the CARTO APIs are authenticated.
308
+ *
309
+ * - `'token'` (default): every request carries `Authorization: Bearer <accessToken>`.
310
+ * - `'session'`: requests carry NO Authorization header and are sent with
311
+ * `credentials: 'same-origin'`. Authentication is delegated to the server
312
+ * behind `apiBaseUrl` — typically a same-origin proxy that attaches the
313
+ * credential server-side from a session cookie. Used by CARTO hosted apps
314
+ * (`apiBaseUrl: '/app/_proxy/<slug>'`) and other single-origin deployments
315
+ * where the access token must never be exposed to JavaScript.
316
+ */
317
+ type AuthMode = 'token' | 'session';
318
+ /**
319
+ * Authentication options shared by sources, queries, widget sources and
320
+ * fetchMap:
321
+ *
322
+ * - token mode (default): `accessToken` is required.
323
+ * - session mode: `authMode: 'session'` and no `accessToken`.
324
+ *
325
+ * Validated at request time by {@link buildAuthHeaders}.
326
+ */
327
+ type AuthOptions = {
328
+ /** Carto platform access token. Required unless `authMode` is `'session'`. */
329
+ accessToken?: string;
330
+ /** @default 'token' */
331
+ authMode?: AuthMode;
332
+ };
333
+ /**
334
+ * Builds the Authorization headers for a request: a Bearer header in token
335
+ * mode, no auth headers at all in session mode (the server-side session
336
+ * middleware must see the header absent to engage). Also validates the
337
+ * options, so every request path fails fast on a misconfiguration.
338
+ */
339
+ declare function buildAuthHeaders(options: AuthOptions): Record<string, string>;
340
+ /**
341
+ * `fetch()` credentials for the given auth mode. Session mode must send the
342
+ * cookie explicitly; token mode preserves today's behavior (unset).
343
+ */
344
+ declare function getAuthCredentials(authMode?: AuthMode): RequestCredentials | undefined;
345
+ /**
346
+ * Rewrites an absolute CARTO API URL (e.g. a tilejson `tiles[]` template or
347
+ * the map-instantiation `dataUrl`, which always point at the tenant API host)
348
+ * onto the configured `apiBaseUrl`. In session mode the browser cannot reach
349
+ * the API host directly — every request must go through the same-origin
350
+ * proxy that `apiBaseUrl` points at. Relative URLs are returned unchanged.
351
+ */
352
+ declare function rewriteUrlForSessionMode(url: string, apiBaseUrl: string): string;
353
+
314
354
  type APIRequestType = 'Map data' | 'Map instantiation' | 'Public map' | 'Tile stats' | 'SQL' | 'Basemap style';
315
355
  type APIErrorContext = {
316
356
  requestType: APIRequestType;
@@ -360,9 +400,7 @@ declare enum RasterBandColorinterp {
360
400
  Palette = "palette"
361
401
  }
362
402
 
363
- type SourceRequiredOptions = {
364
- /** Carto platform access token. */
365
- accessToken: string;
403
+ type SourceRequiredOptions = AuthOptions & {
366
404
  /** Data warehouse connection name in Carto platform. */
367
405
  connectionName: string;
368
406
  };
@@ -734,7 +772,13 @@ type RasterMetadata = {
734
772
  pixel_resolution: number;
735
773
  };
736
774
  type TilejsonResult = Tilejson & {
737
- accessToken: string;
775
+ /**
776
+ * Access token used to fetch the tiles. Absent when the source was created
777
+ * with `authMode: 'session'` — tile URLs are then rewritten onto the
778
+ * configured `apiBaseUrl` and authenticated by the server (session cookie),
779
+ * so consumers must not attach an Authorization header.
780
+ */
781
+ accessToken?: string;
738
782
  schema: SchemaField[];
739
783
  };
740
784
  type QueryResult = {
@@ -762,7 +806,7 @@ type QueryOptions = SourceOptions & QuerySourceOptions & {
762
806
  };
763
807
  declare const query: (options: QueryOptions) => Promise<QueryResult>;
764
808
 
765
- declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, }: {
809
+ declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, credentials, }: {
766
810
  baseUrl: string;
767
811
  parameters?: Record<string, unknown>;
768
812
  headers?: Record<string, string>;
@@ -770,6 +814,8 @@ declare function requestWithParameters<T = any>({ baseUrl, parameters, headers:
770
814
  maxLengthURL?: number;
771
815
  localCache?: LocalCacheOptions;
772
816
  signal?: AbortSignal;
817
+ /** Forwarded to `fetch()`. Session auth mode passes 'same-origin'. */
818
+ credentials?: RequestCredentials;
773
819
  }): Promise<T>;
774
820
  /**
775
821
  * Clears the HTTP response cache for all requests using the default cache.
@@ -1706,7 +1752,8 @@ interface ModelSource {
1706
1752
  type: MapType;
1707
1753
  apiVersion: ApiVersion;
1708
1754
  apiBaseUrl: string;
1709
- accessToken: string;
1755
+ accessToken?: string;
1756
+ authMode?: AuthMode;
1710
1757
  clientId: string;
1711
1758
  connectionName: string;
1712
1759
  data: string;
@@ -2159,6 +2206,22 @@ declare function _getHexagonResolution(viewport: {
2159
2206
  zoom: number;
2160
2207
  latitude: number;
2161
2208
  }, tileSize: number): number;
2209
+ /**
2210
+ * Quadbin level at which the maps-api dynamic tiler implicitly aggregates a
2211
+ * point source for a given tile zoom and resolution. Lets a client reproduce
2212
+ * that level — and so the aggregation cell a point falls into — without an
2213
+ * extra round-trip to the server.
2214
+ *
2215
+ * Ported verbatim from the maps-api dynamic tiler (`getPointsAggregationLevel`).
2216
+ * The base offset mirrors the server default of
2217
+ * `MAPS_API_V3_DYNAMIC_TILES_POINTS_AGGREGATION_LEVEL`; a deployment that
2218
+ * overrides that env var drifts from this computation.
2219
+ * @internal
2220
+ */
2221
+ declare function getPointsAggregationLevel({ tileResolution, zoomLevel, }: {
2222
+ tileResolution: TileResolution;
2223
+ zoomLevel: number;
2224
+ }): number;
2162
2225
 
2163
2226
  /** @privateRemarks Source: @carto/react-core */
2164
2227
  type AggregationFunction = (values: unknown[] | FeatureData[], keys?: string[] | string, joinOperation?: AggregationType) => number;
@@ -2299,4 +2362,4 @@ declare function getColumnNameFromGeoColumn(geoColumn: string | null | undefined
2299
2362
  */
2300
2363
  declare function getSpatialIndexFromGeoColumn(geoColumn: string): SpatialIndex | null;
2301
2364
 
2302
- export { type APIErrorContext, type APIRequestType, AUDIT_TAGS, type AddFilterOptions, type AggregationFunction, type AggregationType, AggregationTypes, type AggregationsRequestOptions, type AggregationsResponse, ApiVersion, type Attribute, _default as BASEMAP, type BaseRequestOptions, type Basemap, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CARTO_SOURCES, CartoAPIError, type CategoryOrderBy, type CategoryRequestOptions, type CategoryResponse, type CategoryResponseEntry, type CategoryResponseRaw, CellSet, type ColumnsOption, type D3Scale, DEFAULT_API_BASE_URL, type ExtentRequestOptions, type ExtentResponse, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type FetchMapOptions, type FetchMapResult, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, type FilterOptions, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GeometrySpatialFilter, type GetFilterOptions, type GoogleBasemap, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type KeplerMapConfig, type Layer, type LayerDescriptor, type LayerType, type MapLibreBasemap, type MapType, type NamedQueryParameter, OPACITY_MAP, OTHERS_CATEGORY_NAME, type ParseMapResult, type PositionalQueryParameter, Provider, type ProviderType, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterBandType, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RasterTile, type RemoveFilterOptions, SOURCE_DEFAULTS, type Scale, type ScaleKey, type ScaleType, type Scales, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SchemaField, SchemaFieldType, type SortColumnType, type SortDirection, type SourceOptionalOptions, type SourceOptions, type SourceRequiredOptions, type SpatialDataType, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, SpatialIndexColumn, type SpatialIndexFilter, type SpatialIndexTile, type StringSearchOptions, TEXT_LABEL_INDEX, TEXT_NUMBER_FORMATTER, TEXT_OUTLINE_OPACITY, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type Tilejson, type TilejsonResult, type TilesetSourceOptions, type Tilestats, type TimeSeriesRequestOptions, type TimeSeriesResponse, type TrajectoryQuerySourceOptions, type TrajectoryQuerySourceResponse, type TrajectoryTableSourceOptions, type TrajectoryTableSourceResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, type WidgetFeatureGeometryType, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRasterSource, type WidgetRasterSourceProps, type WidgetRasterSourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, ErrorCode as _ErrorCode, type VecExprResult as _VecExprResult, applyLayerGroupFilters as _applyLayerGroupFilters, _buildFeatureFilter, createVecExprEvaluator as _createVecExprEvaluator, domainFromValues as _domainFromValues, evaluateVecExpr as _evaluateVecExpr, fillInMapDatasets as _fillInMapDatasets, fillInTileStats as _fillInTileStats, _getHexagonResolution, getLog10ScaleSteps as _getLog10ScaleSteps, getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps, validateVecExprSyntax as _validateVecExprSyntax, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, calculateClusterRadius, calculateClusterTextFontSize, calculateLayerScale, clearDefaultRequestCache, clearFilters, compileCustomAggregation, configureSource, createColorScale, createPolygonSpatialFilter, createViewportSpatialFilter, fetchBasemapProps, fetchMap, filterFunctions, geojsonFeatures, getApplicableFilters, getClient, getColorAccessor, getColumnNameFromGeoColumn, getDataFilterExtensionProps, getDefaultAggregationExpColumnAliasForLayerType, getFilter, getIconUrlAccessor, getLayerDescriptor, getLayerProps, getMaxMarkerSize, getSizeAccessor, getSorter, getSpatialIndexFromGeoColumn, getTextAccessor, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, isSpatialIndexFilter, makeIntervalComplete, negateAccessor, opacityToAlpha, parseMap, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, scaleAggregationResLevel, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, trajectoryQuerySource, trajectoryTableSource, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };
2365
+ export { type APIErrorContext, type APIRequestType, AUDIT_TAGS, type AddFilterOptions, type AggregationFunction, type AggregationType, AggregationTypes, type AggregationsRequestOptions, type AggregationsResponse, ApiVersion, type Attribute, type AuthMode, type AuthOptions, _default as BASEMAP, type BaseRequestOptions, type Basemap, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CARTO_SOURCES, CartoAPIError, type CategoryOrderBy, type CategoryRequestOptions, type CategoryResponse, type CategoryResponseEntry, type CategoryResponseRaw, CellSet, type ColumnsOption, type D3Scale, DEFAULT_API_BASE_URL, type ExtentRequestOptions, type ExtentResponse, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type FetchMapOptions, type FetchMapResult, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, type FilterOptions, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GeometrySpatialFilter, type GetFilterOptions, type GoogleBasemap, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type KeplerMapConfig, type Layer, type LayerDescriptor, type LayerType, type MapLibreBasemap, type MapType, type NamedQueryParameter, OPACITY_MAP, OTHERS_CATEGORY_NAME, type ParseMapResult, type PositionalQueryParameter, Provider, type ProviderType, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterBandType, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RasterTile, type RemoveFilterOptions, SOURCE_DEFAULTS, type Scale, type ScaleKey, type ScaleType, type Scales, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SchemaField, SchemaFieldType, type SortColumnType, type SortDirection, type SourceOptionalOptions, type SourceOptions, type SourceRequiredOptions, type SpatialDataType, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, SpatialIndexColumn, type SpatialIndexFilter, type SpatialIndexTile, type StringSearchOptions, TEXT_LABEL_INDEX, TEXT_NUMBER_FORMATTER, TEXT_OUTLINE_OPACITY, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type Tilejson, type TilejsonResult, type TilesetSourceOptions, type Tilestats, type TimeSeriesRequestOptions, type TimeSeriesResponse, type TrajectoryQuerySourceOptions, type TrajectoryQuerySourceResponse, type TrajectoryTableSourceOptions, type TrajectoryTableSourceResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, type WidgetFeatureGeometryType, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRasterSource, type WidgetRasterSourceProps, type WidgetRasterSourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, ErrorCode as _ErrorCode, type VecExprResult as _VecExprResult, applyLayerGroupFilters as _applyLayerGroupFilters, _buildFeatureFilter, createVecExprEvaluator as _createVecExprEvaluator, domainFromValues as _domainFromValues, evaluateVecExpr as _evaluateVecExpr, fillInMapDatasets as _fillInMapDatasets, fillInTileStats as _fillInTileStats, _getHexagonResolution, getLog10ScaleSteps as _getLog10ScaleSteps, getPointsAggregationLevel as _getPointsAggregationLevel, getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps, validateVecExprSyntax as _validateVecExprSyntax, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildAuthHeaders, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, calculateClusterRadius, calculateClusterTextFontSize, calculateLayerScale, clearDefaultRequestCache, clearFilters, compileCustomAggregation, configureSource, createColorScale, createPolygonSpatialFilter, createViewportSpatialFilter, fetchBasemapProps, fetchMap, filterFunctions, geojsonFeatures, getApplicableFilters, getAuthCredentials, getClient, getColorAccessor, getColumnNameFromGeoColumn, getDataFilterExtensionProps, getDefaultAggregationExpColumnAliasForLayerType, getFilter, getIconUrlAccessor, getLayerDescriptor, getLayerProps, getMaxMarkerSize, getSizeAccessor, getSorter, getSpatialIndexFromGeoColumn, getTextAccessor, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, isSpatialIndexFilter, makeIntervalComplete, negateAccessor, opacityToAlpha, parseMap, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, rewriteUrlForSessionMode, scaleAggregationResLevel, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, trajectoryQuerySource, trajectoryTableSource, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };
@@ -187,21 +187,13 @@ type AggregationType = 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
187
187
  /** A spatial filter expressed as a GeoJSON polygon, applied client- or server-side. */
188
188
  type GeometrySpatialFilter = Polygon | MultiPolygon;
189
189
  /**
190
- * Filter restricting a widget query to a set of spatial-index cells (H3 or
191
- * Quadbin). Used for point-and-click selection on cell-rendered layers. Sent to
192
- * the server-side model API only; maps-api chooses the SQL strategy from
193
- * `spatialDataType`, so the same payload works for both natively-indexed
194
- * sources and point/geometry sources dynamically aggregated into cells.
195
- *
196
- * @privateRemarks Source: @carto/query-builder (SpatialIndexFilter)
190
+ * Filter restricting a widget query to a selection of spatial-index cells,
191
+ * e.g. from point-and-click on an H3 or Quadbin layer.
197
192
  */
198
193
  interface SpatialIndexFilter {
199
- /**
200
- * Selected cell ids. h3 = hex string; h3int = `BigInt(\`0x${id}\`)`; quadbin
201
- * = decimal or `0x`-hex string.
202
- */
194
+ /** Selected cell ids. */
203
195
  indexes: string[];
204
- /** Must match the column type; `h3` and `h3int` are interchangeable. */
196
+ /** Spatial index type of the filtered column. */
205
197
  type: 'h3' | 'h3int' | 'quadbin';
206
198
  }
207
199
  /** @privateRemarks Source: @carto/react-api */
@@ -311,6 +303,54 @@ type _DataFilterExtensionProps = {
311
303
  */
312
304
  declare function getDataFilterExtensionProps(filters: Filters, filtersLogicalOperator?: FilterLogicalOperator): _DataFilterExtensionProps;
313
305
 
306
+ /**
307
+ * How requests to the CARTO APIs are authenticated.
308
+ *
309
+ * - `'token'` (default): every request carries `Authorization: Bearer <accessToken>`.
310
+ * - `'session'`: requests carry NO Authorization header and are sent with
311
+ * `credentials: 'same-origin'`. Authentication is delegated to the server
312
+ * behind `apiBaseUrl` — typically a same-origin proxy that attaches the
313
+ * credential server-side from a session cookie. Used by CARTO hosted apps
314
+ * (`apiBaseUrl: '/app/_proxy/<slug>'`) and other single-origin deployments
315
+ * where the access token must never be exposed to JavaScript.
316
+ */
317
+ type AuthMode = 'token' | 'session';
318
+ /**
319
+ * Authentication options shared by sources, queries, widget sources and
320
+ * fetchMap:
321
+ *
322
+ * - token mode (default): `accessToken` is required.
323
+ * - session mode: `authMode: 'session'` and no `accessToken`.
324
+ *
325
+ * Validated at request time by {@link buildAuthHeaders}.
326
+ */
327
+ type AuthOptions = {
328
+ /** Carto platform access token. Required unless `authMode` is `'session'`. */
329
+ accessToken?: string;
330
+ /** @default 'token' */
331
+ authMode?: AuthMode;
332
+ };
333
+ /**
334
+ * Builds the Authorization headers for a request: a Bearer header in token
335
+ * mode, no auth headers at all in session mode (the server-side session
336
+ * middleware must see the header absent to engage). Also validates the
337
+ * options, so every request path fails fast on a misconfiguration.
338
+ */
339
+ declare function buildAuthHeaders(options: AuthOptions): Record<string, string>;
340
+ /**
341
+ * `fetch()` credentials for the given auth mode. Session mode must send the
342
+ * cookie explicitly; token mode preserves today's behavior (unset).
343
+ */
344
+ declare function getAuthCredentials(authMode?: AuthMode): RequestCredentials | undefined;
345
+ /**
346
+ * Rewrites an absolute CARTO API URL (e.g. a tilejson `tiles[]` template or
347
+ * the map-instantiation `dataUrl`, which always point at the tenant API host)
348
+ * onto the configured `apiBaseUrl`. In session mode the browser cannot reach
349
+ * the API host directly — every request must go through the same-origin
350
+ * proxy that `apiBaseUrl` points at. Relative URLs are returned unchanged.
351
+ */
352
+ declare function rewriteUrlForSessionMode(url: string, apiBaseUrl: string): string;
353
+
314
354
  type APIRequestType = 'Map data' | 'Map instantiation' | 'Public map' | 'Tile stats' | 'SQL' | 'Basemap style';
315
355
  type APIErrorContext = {
316
356
  requestType: APIRequestType;
@@ -360,9 +400,7 @@ declare enum RasterBandColorinterp {
360
400
  Palette = "palette"
361
401
  }
362
402
 
363
- type SourceRequiredOptions = {
364
- /** Carto platform access token. */
365
- accessToken: string;
403
+ type SourceRequiredOptions = AuthOptions & {
366
404
  /** Data warehouse connection name in Carto platform. */
367
405
  connectionName: string;
368
406
  };
@@ -734,7 +772,13 @@ type RasterMetadata = {
734
772
  pixel_resolution: number;
735
773
  };
736
774
  type TilejsonResult = Tilejson & {
737
- accessToken: string;
775
+ /**
776
+ * Access token used to fetch the tiles. Absent when the source was created
777
+ * with `authMode: 'session'` — tile URLs are then rewritten onto the
778
+ * configured `apiBaseUrl` and authenticated by the server (session cookie),
779
+ * so consumers must not attach an Authorization header.
780
+ */
781
+ accessToken?: string;
738
782
  schema: SchemaField[];
739
783
  };
740
784
  type QueryResult = {
@@ -762,7 +806,7 @@ type QueryOptions = SourceOptions & QuerySourceOptions & {
762
806
  };
763
807
  declare const query: (options: QueryOptions) => Promise<QueryResult>;
764
808
 
765
- declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, }: {
809
+ declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, signal, credentials, }: {
766
810
  baseUrl: string;
767
811
  parameters?: Record<string, unknown>;
768
812
  headers?: Record<string, string>;
@@ -770,6 +814,8 @@ declare function requestWithParameters<T = any>({ baseUrl, parameters, headers:
770
814
  maxLengthURL?: number;
771
815
  localCache?: LocalCacheOptions;
772
816
  signal?: AbortSignal;
817
+ /** Forwarded to `fetch()`. Session auth mode passes 'same-origin'. */
818
+ credentials?: RequestCredentials;
773
819
  }): Promise<T>;
774
820
  /**
775
821
  * Clears the HTTP response cache for all requests using the default cache.
@@ -1706,7 +1752,8 @@ interface ModelSource {
1706
1752
  type: MapType;
1707
1753
  apiVersion: ApiVersion;
1708
1754
  apiBaseUrl: string;
1709
- accessToken: string;
1755
+ accessToken?: string;
1756
+ authMode?: AuthMode;
1710
1757
  clientId: string;
1711
1758
  connectionName: string;
1712
1759
  data: string;
@@ -2159,6 +2206,22 @@ declare function _getHexagonResolution(viewport: {
2159
2206
  zoom: number;
2160
2207
  latitude: number;
2161
2208
  }, tileSize: number): number;
2209
+ /**
2210
+ * Quadbin level at which the maps-api dynamic tiler implicitly aggregates a
2211
+ * point source for a given tile zoom and resolution. Lets a client reproduce
2212
+ * that level — and so the aggregation cell a point falls into — without an
2213
+ * extra round-trip to the server.
2214
+ *
2215
+ * Ported verbatim from the maps-api dynamic tiler (`getPointsAggregationLevel`).
2216
+ * The base offset mirrors the server default of
2217
+ * `MAPS_API_V3_DYNAMIC_TILES_POINTS_AGGREGATION_LEVEL`; a deployment that
2218
+ * overrides that env var drifts from this computation.
2219
+ * @internal
2220
+ */
2221
+ declare function getPointsAggregationLevel({ tileResolution, zoomLevel, }: {
2222
+ tileResolution: TileResolution;
2223
+ zoomLevel: number;
2224
+ }): number;
2162
2225
 
2163
2226
  /** @privateRemarks Source: @carto/react-core */
2164
2227
  type AggregationFunction = (values: unknown[] | FeatureData[], keys?: string[] | string, joinOperation?: AggregationType) => number;
@@ -2299,4 +2362,4 @@ declare function getColumnNameFromGeoColumn(geoColumn: string | null | undefined
2299
2362
  */
2300
2363
  declare function getSpatialIndexFromGeoColumn(geoColumn: string): SpatialIndex | null;
2301
2364
 
2302
- export { type APIErrorContext, type APIRequestType, AUDIT_TAGS, type AddFilterOptions, type AggregationFunction, type AggregationType, AggregationTypes, type AggregationsRequestOptions, type AggregationsResponse, ApiVersion, type Attribute, _default as BASEMAP, type BaseRequestOptions, type Basemap, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CARTO_SOURCES, CartoAPIError, type CategoryOrderBy, type CategoryRequestOptions, type CategoryResponse, type CategoryResponseEntry, type CategoryResponseRaw, CellSet, type ColumnsOption, type D3Scale, DEFAULT_API_BASE_URL, type ExtentRequestOptions, type ExtentResponse, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type FetchMapOptions, type FetchMapResult, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, type FilterOptions, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GeometrySpatialFilter, type GetFilterOptions, type GoogleBasemap, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type KeplerMapConfig, type Layer, type LayerDescriptor, type LayerType, type MapLibreBasemap, type MapType, type NamedQueryParameter, OPACITY_MAP, OTHERS_CATEGORY_NAME, type ParseMapResult, type PositionalQueryParameter, Provider, type ProviderType, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterBandType, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RasterTile, type RemoveFilterOptions, SOURCE_DEFAULTS, type Scale, type ScaleKey, type ScaleType, type Scales, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SchemaField, SchemaFieldType, type SortColumnType, type SortDirection, type SourceOptionalOptions, type SourceOptions, type SourceRequiredOptions, type SpatialDataType, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, SpatialIndexColumn, type SpatialIndexFilter, type SpatialIndexTile, type StringSearchOptions, TEXT_LABEL_INDEX, TEXT_NUMBER_FORMATTER, TEXT_OUTLINE_OPACITY, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type Tilejson, type TilejsonResult, type TilesetSourceOptions, type Tilestats, type TimeSeriesRequestOptions, type TimeSeriesResponse, type TrajectoryQuerySourceOptions, type TrajectoryQuerySourceResponse, type TrajectoryTableSourceOptions, type TrajectoryTableSourceResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, type WidgetFeatureGeometryType, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRasterSource, type WidgetRasterSourceProps, type WidgetRasterSourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, ErrorCode as _ErrorCode, type VecExprResult as _VecExprResult, applyLayerGroupFilters as _applyLayerGroupFilters, _buildFeatureFilter, createVecExprEvaluator as _createVecExprEvaluator, domainFromValues as _domainFromValues, evaluateVecExpr as _evaluateVecExpr, fillInMapDatasets as _fillInMapDatasets, fillInTileStats as _fillInTileStats, _getHexagonResolution, getLog10ScaleSteps as _getLog10ScaleSteps, getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps, validateVecExprSyntax as _validateVecExprSyntax, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, calculateClusterRadius, calculateClusterTextFontSize, calculateLayerScale, clearDefaultRequestCache, clearFilters, compileCustomAggregation, configureSource, createColorScale, createPolygonSpatialFilter, createViewportSpatialFilter, fetchBasemapProps, fetchMap, filterFunctions, geojsonFeatures, getApplicableFilters, getClient, getColorAccessor, getColumnNameFromGeoColumn, getDataFilterExtensionProps, getDefaultAggregationExpColumnAliasForLayerType, getFilter, getIconUrlAccessor, getLayerDescriptor, getLayerProps, getMaxMarkerSize, getSizeAccessor, getSorter, getSpatialIndexFromGeoColumn, getTextAccessor, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, isSpatialIndexFilter, makeIntervalComplete, negateAccessor, opacityToAlpha, parseMap, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, scaleAggregationResLevel, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, trajectoryQuerySource, trajectoryTableSource, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };
2365
+ export { type APIErrorContext, type APIRequestType, AUDIT_TAGS, type AddFilterOptions, type AggregationFunction, type AggregationType, AggregationTypes, type AggregationsRequestOptions, type AggregationsResponse, ApiVersion, type Attribute, type AuthMode, type AuthOptions, _default as BASEMAP, type BaseRequestOptions, type Basemap, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CARTO_SOURCES, CartoAPIError, type CategoryOrderBy, type CategoryRequestOptions, type CategoryResponse, type CategoryResponseEntry, type CategoryResponseRaw, CellSet, type ColumnsOption, type D3Scale, DEFAULT_API_BASE_URL, type ExtentRequestOptions, type ExtentResponse, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type FetchMapOptions, type FetchMapResult, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, type FilterOptions, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GeometrySpatialFilter, type GetFilterOptions, type GoogleBasemap, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type KeplerMapConfig, type Layer, type LayerDescriptor, type LayerType, type MapLibreBasemap, type MapType, type NamedQueryParameter, OPACITY_MAP, OTHERS_CATEGORY_NAME, type ParseMapResult, type PositionalQueryParameter, Provider, type ProviderType, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterBandType, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RasterTile, type RemoveFilterOptions, SOURCE_DEFAULTS, type Scale, type ScaleKey, type ScaleType, type Scales, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SchemaField, SchemaFieldType, type SortColumnType, type SortDirection, type SourceOptionalOptions, type SourceOptions, type SourceRequiredOptions, type SpatialDataType, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, SpatialIndexColumn, type SpatialIndexFilter, type SpatialIndexTile, type StringSearchOptions, TEXT_LABEL_INDEX, TEXT_NUMBER_FORMATTER, TEXT_OUTLINE_OPACITY, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type Tilejson, type TilejsonResult, type TilesetSourceOptions, type Tilestats, type TimeSeriesRequestOptions, type TimeSeriesResponse, type TrajectoryQuerySourceOptions, type TrajectoryQuerySourceResponse, type TrajectoryTableSourceOptions, type TrajectoryTableSourceResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, type WidgetFeatureGeometryType, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRasterSource, type WidgetRasterSourceProps, type WidgetRasterSourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, ErrorCode as _ErrorCode, type VecExprResult as _VecExprResult, applyLayerGroupFilters as _applyLayerGroupFilters, _buildFeatureFilter, createVecExprEvaluator as _createVecExprEvaluator, domainFromValues as _domainFromValues, evaluateVecExpr as _evaluateVecExpr, fillInMapDatasets as _fillInMapDatasets, fillInTileStats as _fillInTileStats, _getHexagonResolution, getLog10ScaleSteps as _getLog10ScaleSteps, getPointsAggregationLevel as _getPointsAggregationLevel, getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps, validateVecExprSyntax as _validateVecExprSyntax, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildAuthHeaders, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, calculateClusterRadius, calculateClusterTextFontSize, calculateLayerScale, clearDefaultRequestCache, clearFilters, compileCustomAggregation, configureSource, createColorScale, createPolygonSpatialFilter, createViewportSpatialFilter, fetchBasemapProps, fetchMap, filterFunctions, geojsonFeatures, getApplicableFilters, getAuthCredentials, getClient, getColorAccessor, getColumnNameFromGeoColumn, getDataFilterExtensionProps, getDefaultAggregationExpColumnAliasForLayerType, getFilter, getIconUrlAccessor, getLayerDescriptor, getLayerProps, getMaxMarkerSize, getSizeAccessor, getSorter, getSpatialIndexFromGeoColumn, getTextAccessor, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, isSpatialIndexFilter, makeIntervalComplete, negateAccessor, opacityToAlpha, parseMap, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, rewriteUrlForSessionMode, scaleAggregationResLevel, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, trajectoryQuerySource, trajectoryTableSource, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };